diff options
Diffstat (limited to 'deps/npm/node_modules/socks-proxy-agent/dist/agent.js')
-rw-r--r-- | deps/npm/node_modules/socks-proxy-agent/dist/agent.js | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/deps/npm/node_modules/socks-proxy-agent/dist/agent.js b/deps/npm/node_modules/socks-proxy-agent/dist/agent.js index f779732bbc7..acdde177ecb 100644 --- a/deps/npm/node_modules/socks-proxy-agent/dist/agent.js +++ b/deps/npm/node_modules/socks-proxy-agent/dist/agent.js @@ -54,18 +54,18 @@ function parseSocksProxy(opts) { // figure out if we want socks v4 or v5, based on the "protocol" used. // Defaults to 5. if (opts.protocol) { - switch (opts.protocol) { - case 'socks4:': + switch (opts.protocol.replace(':', '')) { + case 'socks4': lookup = true; // pass through - case 'socks4a:': + case 'socks4a': type = 4; break; - case 'socks5:': + case 'socks5': lookup = true; // pass through - case 'socks:': // no version specified, default to 5h - case 'socks5h:': + case 'socks': // no version specified, default to 5h + case 'socks5h': type = 5; break; default: @@ -85,7 +85,7 @@ function parseSocksProxy(opts) { port, type }; - let userId = opts.userId; + let userId = opts.userId || opts.username; let password = opts.password; if (opts.auth) { const auth = opts.auth.split(':'); @@ -137,7 +137,7 @@ class SocksProxyAgent extends agent_base_1.Agent { callback(req, opts) { return __awaiter(this, void 0, void 0, function* () { const { lookup, proxy } = this; - let { host, port } = opts; + let { host, port, timeout } = opts; if (!host) { throw new Error('No `host` defined!'); } @@ -148,19 +148,17 @@ class SocksProxyAgent extends agent_base_1.Agent { const socksOpts = { proxy, destination: { host, port }, - command: 'connect' + command: 'connect', + timeout }; debug('Creating socks proxy connection: %o', socksOpts); const { socket } = yield socks_1.SocksClient.createConnection(socksOpts); debug('Successfully created socks proxy connection'); if (opts.secureEndpoint) { - const servername = opts.servername || opts.host; - if (!servername) { - throw new Error('Could not determine "servername"'); - } // The proxy is connecting to a TLS server, so upgrade // this socket connection to a TLS connection. debug('Upgrading socket connection to TLS'); + const servername = opts.servername || opts.host; return tls_1.default.connect(Object.assign(Object.assign({}, omit(opts, 'host', 'hostname', 'path', 'port')), { socket, servername })); } |