提交 17682edf 编写于 作者: J Joao Moreno

use auth in proxies

related to #1942
上级 5273e353
...@@ -5,8 +5,16 @@ ...@@ -5,8 +5,16 @@
declare module 'http-proxy-agent' { declare module 'http-proxy-agent' {
interface IHttpProxyAgentOptions {
host: string;
port: number;
auth?: string;
}
class HttpProxyAgent { class HttpProxyAgent {
constructor(proxy: string); constructor(proxy: string);
constructor(opts: IHttpProxyAgentOptions);
} }
export = HttpProxyAgent; export = HttpProxyAgent;
} }
\ No newline at end of file
...@@ -10,6 +10,7 @@ declare module 'https-proxy-agent' { ...@@ -10,6 +10,7 @@ declare module 'https-proxy-agent' {
interface IHttpsProxyAgentOptions extends tls.ConnectionOptions { interface IHttpsProxyAgentOptions extends tls.ConnectionOptions {
host: string; host: string;
port: number; port: number;
auth?: string;
secureProxy?: boolean; secureProxy?: boolean;
secureEndpoint?: boolean; secureEndpoint?: boolean;
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import { Url, parse as parseUrl } from 'url'; import { Url, parse as parseUrl } from 'url';
import { isBoolean } from 'vs/base/common/types'; import { isBoolean } from 'vs/base/common/types';
import { assign } from 'vs/base/common/objects';
import HttpProxyAgent = require('http-proxy-agent'); import HttpProxyAgent = require('http-proxy-agent');
import HttpsProxyAgent = require('https-proxy-agent'); import HttpsProxyAgent = require('https-proxy-agent');
...@@ -39,13 +40,12 @@ export function getProxyAgent(rawRequestURL: string, options: IOptions = {}): an ...@@ -39,13 +40,12 @@ export function getProxyAgent(rawRequestURL: string, options: IOptions = {}): an
return null; return null;
} }
if (requestURL.protocol === 'http:') { const opts = {
return new HttpProxyAgent(proxyURL);
}
return new HttpsProxyAgent({
host: proxyEndpoint.hostname, host: proxyEndpoint.hostname,
port: Number(proxyEndpoint.port), port: Number(proxyEndpoint.port),
auth: proxyEndpoint.auth,
rejectUnauthorized: isBoolean(options.strictSSL) ? options.strictSSL : true rejectUnauthorized: isBoolean(options.strictSSL) ? options.strictSSL : true
}); };
return requestURL.protocol === 'http:' ? new HttpProxyAgent(opts) : new HttpsProxyAgent(opts);
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册