Show more port cmdline when wide

And add pid.
Fixes #112796, microsoft/vscode-remote-release#4120
This commit is contained in:
Alex Ross
2020-12-24 11:54:07 +01:00
parent 0b1892f877
commit ed87c35de9
5 changed files with 88 additions and 49 deletions

View File

@@ -21,6 +21,7 @@ import { TunnelOptions, TunnelCreationOptions } from 'vs/platform/remote/common/
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { promisify } from 'util';
import { MovingAverage } from 'vs/base/common/numbers';
import { CandidatePort } from 'vs/workbench/services/remote/common/remoteExplorerService';
class ExtensionTunnel implements vscode.Tunnel {
private _onDispose: Emitter<void> = new Emitter();
@@ -106,7 +107,7 @@ function knownExcludeCmdline(command: string): boolean {
|| (command.indexOf('_productName=VSCode') !== -1);
}
export async function findPorts(tcp: string, tcp6: string, procSockets: string, processes: { pid: number, cwd: string, cmd: string }[]) {
export async function findPorts(tcp: string, tcp6: string, procSockets: string, processes: { pid: number, cwd: string, cmd: string }[]): Promise<CandidatePort[]> {
const connections: { socket: number, ip: string, port: number }[] = loadListeningPorts(tcp, tcp6);
const sockets = getSockets(procSockets);
@@ -119,11 +120,11 @@ export async function findPorts(tcp: string, tcp6: string, procSockets: string,
return m;
}, {} as Record<string, typeof processes[0]>);
const ports: { host: string, port: number, detail: string }[] = [];
const ports: CandidatePort[] = [];
connections.filter((connection => socketMap[connection.socket])).forEach(({ socket, ip, port }) => {
const command = processMap[socketMap[socket].pid].cmd;
if (!knownExcludeCmdline(command)) {
ports.push({ host: ip, port, detail: processMap[socketMap[socket].pid].cmd });
ports.push({ host: ip, port, detail: processMap[socketMap[socket].pid].cmd, pid: socketMap[socket].pid });
}
});
return ports;
@@ -238,7 +239,7 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe
return undefined;
}
async findCandidatePorts(): Promise<{ host: string, port: number, detail: string }[]> {
async findCandidatePorts(): Promise<CandidatePort[]> {
let tcp: string = '';
let tcp6: string = '';
try {