Use random port if privileged in test resolver
parent
bdc3b07f42
commit
e8f6c27381
|
@ -377,10 +377,15 @@ async function tunnelFactory(tunnelOptions: vscode.TunnelOptions, tunnelCreation
|
|||
proxySocket.pipe(remoteSocket);
|
||||
});
|
||||
let localPort: number | undefined;
|
||||
// When the tunnelOptions include a localAddressPort, we should use that.
|
||||
// However, the test resolver all runs on one machine, so if the localAddressPort is the same as the remote port,
|
||||
// then we must use a different port number.
|
||||
if (tunnelOptions.localAddressPort) {
|
||||
|
||||
if (tunnelCreationOptions.elevationRequired) {
|
||||
// If elevation is required, we can't use the requeseted local port, because this tunnel factory
|
||||
// only pretends to support elevation for testing purposes
|
||||
localPort = 0;
|
||||
} else if (tunnelOptions.localAddressPort) {
|
||||
// When the tunnelOptions include a localAddressPort, we should use that.
|
||||
// However, the test resolver all runs on one machine, so if the localAddressPort is the same as the remote port,
|
||||
// then we must use a different port number.
|
||||
if (tunnelOptions.localAddressPort === tunnelOptions.remoteAddress.port) {
|
||||
localPort = tunnelOptions.localAddressPort + 1;
|
||||
} else {
|
||||
|
@ -390,7 +395,7 @@ async function tunnelFactory(tunnelOptions: vscode.TunnelOptions, tunnelCreation
|
|||
// Best practice is to use the same remote port as local port when no local port is provided.
|
||||
// However, everything is running on one machine here, so we can't do that.
|
||||
// In this case, we will just increment the port number by 1.
|
||||
localPort = tunnelOptions.remoteAddress.port + 1;
|
||||
localPort = tunnelOptions.remoteAddress.port < 1024 ? 0 : tunnelOptions.remoteAddress.port + 1;
|
||||
}
|
||||
proxyServer.listen(localPort, () => {
|
||||
const localPort = (<net.AddressInfo>proxyServer.address()).port;
|
||||
|
|
Loading…
Reference in New Issue