Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Added dirty hack for support ssh-proxy.
Browse files Browse the repository at this point in the history
  • Loading branch information
inafact committed Jul 6, 2017
1 parent 0c5b90b commit b012722
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion lib/transport/ssh.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,25 @@ function SSH(context) {
return fiber.throwInto(err);
});

this._connection.connect(config);
this._PROXY = null;

if (config.hasOwnProperty('proxyTo')) {
self._PROXY = new Connection();
self._PROXY.on('ready', function() {
self._PROXY.exec(`nc ${config.proxyTo.host} ${config.proxyTo.port}`, function(err, stream) {
if (err) {
console.err('proxy error');
return self._PROXY.end();
}
var proxyConfig = config.proxyTo;
proxyConfig.sock = stream;
self._connection.connect(proxyConfig);
});
});
self._PROXY.connect(config);
} else {
this._connection.connect(config);
}

return Fiber.yield();
}
Expand Down Expand Up @@ -117,6 +135,10 @@ SSH.prototype._exec = function(command, options) {
return fiber.throwInto(error);
}

if (self._PROXY !== null) {
self._PROXY.end();
}

fiber.run(result);
});
});
Expand Down

0 comments on commit b012722

Please sign in to comment.