use proxy command

pull/290/head
nightwing 2016-04-12 00:46:39 +00:00
rodzic 48502343da
commit c1af528b87
1 zmienionych plików z 18 dodań i 9 usunięć

27
node_modules/c9/ssh.js wygenerowano vendored
Wyświetl plik

@ -12,6 +12,21 @@ var fs = require("fs");
var tmp = require("tmp"); var tmp = require("tmp");
var debug = require("debug")("ssh"); var debug = require("debug")("ssh");
function quote(str) {
return "'" + str.replace(/'/g, "'\\''") + "'";
}
function addProxyCommand(args, proxy) {
var m = /^(.+)(?::(\d+))?$/.exec(proxy);
if (!m)
return;
var proxyHost = m[1];
var proxyPort = parseInt(m[2], 10) || 22;
args.push(
"-o", "ProxyCommand=ssh -W %h:%p -p " + proxyPort + " " + quote(proxyHost)
);
}
exports.buildArgs = function(prvkeyFile, host, proxy) { exports.buildArgs = function(prvkeyFile, host, proxy) {
var args = [ var args = [
"-o", "PasswordAuthentication=no", "-o", "PasswordAuthentication=no",
@ -27,21 +42,15 @@ exports.buildArgs = function(prvkeyFile, host, proxy) {
"-o", "ConnectTimeout=10" // default timeout is 2 minutes, which is quite long "-o", "ConnectTimeout=10" // default timeout is 2 minutes, which is quite long
]; ];
if (proxy)
addProxyCommand(args, proxy);
if (host) { if (host) {
host = host.split(":"); host = host.split(":");
args.push("-p", host[1] || 22); args.push("-p", host[1] || 22);
args.push(host[0]); args.push(host[0]);
} }
if (proxy) {
args.push(
"ssh",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no",
"-o", "IdentitiesOnly=yes",
proxy
);
}
return args; return args;
}; };