131
}
132
133
>
export async function findPorts(connections: { socket: number; ip: string; port: number }[], socketMap: Record<string, { pid: number; socket: number }>, processes: { pid: number; cwd: string; cmd: string }[]): Promise<CandidatePort[]> {
extHostTunnelService.ts
134
>
const processMap = processes.reduce((m: Record<string, typeof processes[0]>, process) => {
135
>
m[process.pid] = process;
136
>
return m;
137
>
}, {});
138
>
139
>
const ports: CandidatePort[] = [];
140
>
connections.forEach(({ socket, ip, port }) => {
141
>
const pid = socketMap[socket] ? socketMap[socket].pid : undefined;
142
>
const command: string | undefined = pid ? processMap[pid]?.cmd : undefined;
143
>
if (pid && command && !knownExcludeCmdline(command)) {
144
>
ports.push({ host: ip, port, detail: command, pid });
145
>
}
146
>
});
147
>
return ports;
148
>
}
149
150
export function tryFindRootPorts(connections: { socket: number; ip: string; port: number }[], rootProcessesStdout: string, previousPorts: Map<number, CandidatePort & { ppid: number }>): Map<number, CandidatePort & { ppid: number }> {