Make port auto forwarding more sequential
This commit is contained in:
parent
a8a71273d9
commit
dbb9eb455e
1 changed files with 11 additions and 8 deletions
|
@ -544,24 +544,25 @@ 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) {
|
||||
|
@ -569,8 +570,10 @@ class ProcAutomaticPortForwarding extends Disposable {
|
|||
} else if (forwarded) {
|
||||
this.notifiedOnly.add(address);
|
||||
}
|
||||
return forwarded;
|
||||
}))).filter(tunnel => !!tunnel);
|
||||
if (forwarded) {
|
||||
allTunnels.push(forwarded);
|
||||
}
|
||||
}
|
||||
if (allTunnels.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue