Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
agent.https = tunnel.httpsOverHttp({
proxy: {
host: config.proxy.host,
port: parseInt(config.proxy.port),
},
});
break;
case 'https':
agent.http = tunnel.httpOverHttps({
proxy: {
host: config.proxy.host,
port: parseInt(config.proxy.port),
},
});
agent.https = tunnel.httpsOverHttps({
proxy: {
host: config.proxy.host,
port: parseInt(config.proxy.port),
},
});
break;
}
}
const requestWrapper = (url, options) => {
// agent
if (agent && new RegExp(config.proxy.url_regex).test(url)) {
let agentResult;
try {
agentResult = agent[(options.protocol || url.match(/(https?:)/)[1]).slice(0, -1)];
} catch (error) {
if (!!this.options.connectionPolicy.ProxyUrl) {
const proxyUrl = url.parse(this.options.connectionPolicy.ProxyUrl);
const port = parseInt(proxyUrl.port, 10);
requestAgentOptions.proxy = {
host: proxyUrl.hostname,
port,
headers: {}
};
if (!!proxyUrl.auth) {
requestAgentOptions.proxy.proxyAuth = proxyUrl.auth;
}
this.options.agent =
proxyUrl.protocol.toLowerCase() === "https:"
? tunnel.httpsOverHttps(requestAgentOptions)
: tunnel.httpsOverHttp(requestAgentOptions); // TODO: type coersion
} else {
this.options.agent = new Agent(requestAgentOptions); // TODO: Move to request?
}
}
const globalEndpointManager = new GlobalEndpointManager(this.options, async (opts: RequestOptions) =>
this.getDatabaseAccount(opts)
);
this.clientContext = new ClientContext(options, globalEndpointManager);
this.databases = new Databases(this, this.clientContext);
this.offers = new Offers(this, this.clientContext);
}
proxy: pick(conf, 'host', 'port', 'protocol', 'localAddress', 'proxyAuth'),
maxSockets: conf.sockets
};
opts.proxy.innerProtocol = innerProtocol;
if (useCONNECT) {
if (conf.proxyHttpsOptions) {
assign(opts.proxy, conf.proxyHttpsOptions);
}
if (conf.originHttpsOptions) {
assign(opts, conf.originHttpsOptions);
}
if (outerProtocol === 'https:') {
if (innerProtocol === 'https:') {
return tunnel.httpsOverHttps(opts);
}
return tunnel.httpOverHttps(opts);
}
if (innerProtocol === 'https:') {
return tunnel.httpsOverHttp(opts);
}
return tunnel.httpOverHttp(opts);
}
if (conf.originHttpsOptions) {
throw new Error('originHttpsOptions must be combined with a tunnel:true option');
}
if (conf.proxyHttpsOptions) {
// NB: not opts.
assign(opts, conf.proxyHttpsOptions);
}
export function createTunnel(isRequestHttps: boolean, isProxyHttps: boolean, tunnelOptions: tunnel.HttpsOverHttpsOptions): http.Agent | https.Agent {
if (isRequestHttps && isProxyHttps) {
return tunnel.httpsOverHttps(tunnelOptions);
} else if (isRequestHttps && !isProxyHttps) {
return tunnel.httpsOverHttp(tunnelOptions);
} else if (!isRequestHttps && isProxyHttps) {
return tunnel.httpOverHttps(tunnelOptions);
} else {
return tunnel.httpOverHttp(tunnelOptions);
}
}
var agentinfo = {
proxy: proxy
};
if (resource.key) {
agentinfo.key = resource.key;
}
if (resource.cert) {
agentinfo.cert = resource.cert;
}
var isOverHTTPS = utils.urlIsHTTPS(proxy);
if (isHTTPS) {
if (isOverHTTPS) {
resource.agent = tunnel.httpsOverHttps(agentinfo);
} else {
resource.agent = tunnel.httpsOverHttp(agentinfo);
}
} else {
if (isOverHTTPS) {
resource.agent = tunnel.httpOverHttps(agentinfo);
} else {
resource.agent = tunnel.httpOverHttp(agentinfo);
}
}
} else if (isHTTPS) {
resource.agent = new https.Agent(resource);
}
};
export function createTunnel(isRequestHttps: boolean, isProxyHttps: boolean, tunnelOptions: tunnel.HttpsOverHttpsOptions): http.Agent | https.Agent {
if (isRequestHttps && isProxyHttps) {
return tunnel.httpsOverHttps(tunnelOptions);
} else if (isRequestHttps && !isProxyHttps) {
return tunnel.httpsOverHttp(tunnelOptions);
} else if (!isRequestHttps && isProxyHttps) {
return tunnel.httpOverHttps(tunnelOptions);
} else {
return tunnel.httpOverHttp(tunnelOptions);
}
}
var agentinfo = {
proxy: proxy
};
if (resource.key) {
agentinfo.key = resource.key;
}
if (resource.cert) {
agentinfo.cert = resource.cert;
}
var isOverHTTPS = utils.urlIsHTTPS(proxy);
if (isHTTPS) {
if (isOverHTTPS) {
resource.agent = tunnel.httpsOverHttps(agentinfo);
} else {
resource.agent = tunnel.httpsOverHttp(agentinfo);
}
} else {
if (isOverHTTPS) {
resource.agent = tunnel.httpOverHttps(agentinfo);
} else {
resource.agent = tunnel.httpOverHttp(agentinfo);
}
}
} else if (isHTTPS) {
resource.agent = new https.Agent(resource);
}
};
var agentinfo = {
proxy: proxy
};
if (resource.key) {
agentinfo.key = resource.key;
}
if (resource.cert) {
agentinfo.cert = resource.cert;
}
var isOverHTTPS = azureutil.urlIsHTTPS(proxy);
if (isHTTPS) {
if (isOverHTTPS) {
resource.agent = tunnel.httpsOverHttps(agentinfo);
} else {
resource.agent = tunnel.httpsOverHttp(agentinfo);
}
} else {
if (isOverHTTPS) {
resource.agent = tunnel.httpOverHttps(agentinfo);
} else {
resource.agent = tunnel.httpOverHttp(agentinfo);
}
}
} else if (isHTTPS) {
resource.agent = new https.Agent(resource);
}
};