extHostTunnelService.ts ×4

Frontier kind: Joint frontier

unlabeled · c_b0a4b5211f68

1 test · 79130 LOC · 274 files · introduces 1 test · 38 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
4 ranges38 lines · 1 files
Tests
1 test

Contains — complete concept membership

All code (extent)
5401 ranges79130 lines · 274 files · Browse complete extent
All tests (intent)
1 testBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 38 introduced LOC across 4 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/api/node/extHostTunnelService.ts 38 introduced LOC · 4 ranges

Open complete file

116
117 export function getRootProcesses(stdout: string) {
118 > const lines = stdout.trim().split('\n'); extHostTunnelService.ts
119 > const mapped: { pid: number; cmd: string; ppid: number }[] = [];
120 > lines.forEach(line => {
121 > const match = /^\d+\s+\D+\s+root\s+(\d+)\s+(\d+).+\d+\:\d+\:\d+\s+(.+)$/.exec(line)!;
122 > if (match && match.length >= 4) {
123 > mapped.push({
124 > pid: parseInt(match[1], 10),
125 > ppid: parseInt(match[2]),
126 > cmd: match[3]
127 > });
128 > }
129 > });
130 > return mapped;
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[]> {
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 }> {
151 > const ports: Map<number, CandidatePort & { ppid: number }> = new Map(); extHostTunnelService.ts
152 > const rootProcesses = getRootProcesses(rootProcessesStdout);
153 >
154 > for (const connection of connections) {
155 > const previousPort = previousPorts.get(connection.port);
156 > if (previousPort) {
157 ports.set(connection.port, previousPort);
158 continue;
159 }
160 > const rootProcessMatch = rootProcesses.find((value) => value.cmd.includes(`${connection.port}`)); extHostTunnelService.ts
161 > if (rootProcessMatch) {
162 > let bestMatch = rootProcessMatch;
163 > // There are often several processes that "look" like they could match the port.
164 > // The one we want is usually the child of the other. Find the most child process.
165 > let mostChild: { pid: number; cmd: string; ppid: number } | undefined;
166 > do {
167 > mostChild = rootProcesses.find(value => value.ppid === bestMatch.pid);
168 > if (mostChild) {
169 > bestMatch = mostChild;
170 > }
171 > } while (mostChild);
172 > ports.set(connection.port, { host: connection.ip, port: connection.port, pid: bestMatch.pid, detail: bestMatch.cmd, ppid: bestMatch.ppid });
173 > } else {
174 ports.set(connection.port, { host: connection.ip, port: connection.port, ppid: Number.MAX_VALUE });
175 }
177 >
178 > return ports;
179 > }
180
181 export class NodeExtHostTunnelService extends ExtHostTunnelService {