Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
}
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
agent.http = tunnel.httpOverHttp({
proxy: {
host: config.proxy.host,
port: parseInt(config.proxy.port),
},
});
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) => {
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);
}
}
function createProxyAgent(config) {
const options = {
proxy: {
host: config.proxyHost,
port: config.proxyPort,
proxyAuth: config.proxyAuth
}
};
if (config.proxyScheme === 'https') {
if (!config.baseUri || config.baseUri.startsWith('https')) {
return tunnel.httpsOverHttps(options);
} else {
return tunnel.httpOverHttps(options);
}
} else if (!config.baseUri || config.baseUri.startsWith('https')) {
return tunnel.httpsOverHttp(options);
} else {
return tunnel.httpOverHttp(options);
}
}
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);
}
}
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);
}
}
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);
}
};