Skip to content

Commit

Permalink
Proper fix ProxyCommand on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanp413 committed Oct 1, 2023
1 parent 78781fb commit 72a43e1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/authResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,19 @@ export class RemoteSSHResolver implements vscode.RemoteAuthorityResolver, vscode
proxyStream = await proxyConnection.forwardOut('127.0.0.1', 0, destIP, destPort);
}
} else if (sshHostConfig['ProxyCommand']) {
const proxyArgs = (sshHostConfig['ProxyCommand'] as unknown as string[])
.map((arg) => `"${arg.replace('%h', sshHostName).replace('%p', sshPort.toString()).replace('%r', sshUser)}"`);
const proxyCommand = proxyArgs.shift()!;

this.logger.trace(`Spawning ProxyCommand: ${proxyCommand} ${proxyArgs.join(' ')}`);
let proxyArgs = (sshHostConfig['ProxyCommand'] as unknown as string[])
.map((arg) => arg.replace('%h', sshHostName).replace('%p', sshPort.toString()).replace('%r', sshUser));
let proxyCommand = proxyArgs.shift()!;

let options = {};
if (isWindows && /\.(bat|cmd)"$/.test(proxyCommand)) {
if (isWindows && /\.(bat|cmd)$/.test(proxyCommand)) {
proxyCommand = `"${proxyCommand}"`;
proxyArgs = proxyArgs.map((arg) => arg.includes(' ') ? `"${arg}"` : arg);
options = { shell: true, windowsHide: true, windowsVerbatimArguments: true };
}

this.logger.trace(`Spawning ProxyCommand: ${proxyCommand} ${proxyArgs.join(' ')}`);

const child = cp.spawn(proxyCommand, proxyArgs, options);
proxyStream = stream.Duplex.from({ readable: child.stdout, writable: child.stdin });
this.proxyCommandProcess = child;
Expand Down

0 comments on commit 72a43e1

Please sign in to comment.