Skip to content

Commit

Permalink
Make port auto forwarding more sequential
Browse files Browse the repository at this point in the history
  • Loading branch information
alexr00 committed May 5, 2021
1 parent a8a7127 commit dbb9eb4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/vs/workbench/contrib/remote/browser/remoteExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,33 +544,36 @@ class ProcAutomaticPortForwarding extends Disposable {

private async forwardCandidates(): Promise<RemoteTunnel[] | undefined> {
const attributes = await this.remoteExplorerService.tunnelModel.getAttributes(this.remoteExplorerService.tunnelModel.candidates.map(candidate => candidate.port));
const allTunnels = <RemoteTunnel[]>(await Promise.all(this.remoteExplorerService.tunnelModel.candidates.map(async (value) => {
const allTunnels: RemoteTunnel[] = [];
for (const value of this.remoteExplorerService.tunnelModel.candidates) {
if (!value.detail) {
return undefined;
continue;
}

const address = makeAddress(value.host, value.port);
if (this.initialCandidates.has(address)) {
return undefined;
continue;
}
if (this.notifiedOnly.has(address) || this.autoForwarded.has(address)) {
return undefined;
continue;
}
const alreadyForwarded = mapHasAddressLocalhostOrAllInterfaces(this.remoteExplorerService.tunnelModel.forwarded, value.host, value.port);
if (mapHasAddressLocalhostOrAllInterfaces(this.remoteExplorerService.tunnelModel.detected, value.host, value.port)) {
return undefined;
continue;
}
if (attributes?.get(value.port)?.onAutoForward === OnPortForward.Ignore) {
return undefined;
continue;
}
const forwarded = await this.remoteExplorerService.forward(value, undefined, undefined, undefined, undefined, undefined, false);
if (!alreadyForwarded && forwarded) {
this.autoForwarded.add(address);
} else if (forwarded) {
this.notifiedOnly.add(address);
}
return forwarded;
}))).filter(tunnel => !!tunnel);
if (forwarded) {
allTunnels.push(forwarded);
}
}
if (allTunnels.length === 0) {
return undefined;
}
Expand Down

0 comments on commit dbb9eb4

Please sign in to comment.