48
49
export function loadListeningPorts(...stdouts: string[]): { socket: number; ip: string; port: number }[] {
50
>
const table = ([] as Record<string, string>[]).concat(...stdouts.map(loadConnectionTable));
extHostTunnelService.ts
51
>
return [
52
>
...new Map(
53
>
table.filter(row => row.st === '0A')
54
>
.map(row => {
55
>
const address = row.local_address.split(':');
56
>
return {
57
>
socket: parseInt(row.inode, 10),
58
>
ip: parseIpAddress(address[0]),
59
>
port: parseInt(address[1], 16)
60
>
};
61
>
}).map(port => [port.ip + ':' + port.port, port])
62
>
).values()
63
>
];
64
>
}
65
66
export function parseIpAddress(hex: string): string {
67
let result = '';
68
if (hex.length === 8) {
70
>
result += parseInt(hex.substr(i, 2), 16);
71
>
if (i !== 0) {
72
>
result += '.';
73
>
}
74
>
}
75
} else {
76
// Nice explanation of host format in tcp6 file: https://serverfault.com/questions/592574/why-does-proc-net-tcp6-represents-1-as-1000