How to use the tunnel.httpOverHttp function in tunnel

To help you get started, we’ve selected a few tunnel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alibaba / anyproxy / test / util / HttpUtil.js View on Github external
function doWebSocket(url, headers = {}, isProxy) {
  let ws;
  if (isProxy) {
    headers['via-proxy'] = 'true';
    let agent = new tunnel.httpOverHttp({
      proxy: {
        hostname: SOCKE_PROXY_URL_OBJ.hostname,
        port: SOCKE_PROXY_URL_OBJ.port
      }
    })

    if (url.indexOf('wss') === 0) {
      agent = new tunnel.httpsOverHttp({
        rejectUnauthorized: false,
        proxy: {
          hostname: SOCKE_PROXY_URL_OBJ.hostname,
          port: SOCKE_PROXY_URL_OBJ.port
        }
      })
    }
github hainproject / hain / app / main / worker / global-proxy-agent.js View on Github external
function createHttpProxyAgent(host, port) {
  return tunnel.httpOverHttp({
    proxy: { host, port }
  });
}
github Azure / azure-sdk-for-node / lib / services / core / filters / proxyfilter.js View on Github external
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);
  }
};
github yarnpkg / berry / packages / yarnpkg-core / sources / httpUtils.ts View on Github external
async function request(target: string, body: Body, {configuration, headers, json, method = Method.GET}: Options) {
  if (!configuration.get(`enableNetwork`))
    throw new Error(`Network access have been disabled by configuration (${method} ${target})`);

  const url = new URL(target);
  if (url.protocol === `http:` && !micromatch.isMatch(url.hostname, configuration.get(`unsafeHttpWhitelist`)))
    throw new Error(`Unsafe http requests must be explicitly whitelisted in your configuration (${url.hostname})`);

  let agent;

  const httpProxy = configuration.get(`httpProxy`);
  const httpsProxy = configuration.get(`httpsProxy`);

  if (url.protocol === `http:`)
    agent = httpProxy
      ? tunnel.httpOverHttp(parseProxy(httpProxy))
      : globalHttpAgent;

  if (url.protocol === `https:`)
    agent = httpsProxy
      ? tunnel.httpsOverHttp(parseProxy(httpsProxy))
      : globalHttpsAgent;

  const gotOptions: GotOptions = {agent, headers, method};
  let hostname: string | undefined;

  gotOptions.responseType = json
    ? `json`
    : `buffer`;

  if (body !== null) {
    if (typeof body === `string` || Buffer.isBuffer(body)) {
github Azure / ms-rest-js / lib / proxyAgent.ts View on Github external
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);
  }
}
github electrode-io / electrode-native / ern-core / src / createProxyAgent.ts View on Github external
const protocol = proxyUrl.protocol
  if (!supportedProtocols.includes(protocol)) {
    throw new Error(
      `Only http and https protocols are supported (protocol: ${protocol})`
    )
  }
  if (!proxyUrl.port) {
    throw new Error(`port is missing from proxy url ${proxyUrl.toString()}`)
  }
  const proxy = {
    host: proxyUrl.hostname,
    port: parseInt(proxyUrl.port, 10),
  }

  return protocol === 'http:'
    ? tunnel.httpOverHttp({ proxy })
    : tunnel.httpOverHttps({ proxy })
}
github Azure / ms-rest-js / lib / axiosHttpClient.ts View on Github external
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);
  }
}
github launchdarkly / node-server-sdk / index.js View on Github external
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);
  }
}
github dtolstyi / node-chromium / utils.js View on Github external
port: proxyUrl.port
                    }
                };
                if (proxyUrl.username && proxyUrl.password) {
                    tunnelOptions.proxy.proxyAuth = `${proxyUrl.username}:${proxyUrl.password}`;
                }
                if (url.startsWith('https://')) {
                    if (proxy.startsWith('https://')) {
                        requestOptions.agent = tunnel.httpsOverHttps(tunnelOptions);
                    } else {
                        requestOptions.agent = tunnel.httpsOverHttp(tunnelOptions);
                    }
                } else if (proxy.startsWith('https://')) {
                    requestOptions.agent = tunnel.httpOverHttps(tunnelOptions);
                } else {
                    requestOptions.agent = tunnel.httpOverHttp(tunnelOptions);
                }
            }
        }
        return requestOptions;
    }
};

tunnel

Node HTTP/HTTPS Agents for tunneling proxies

MIT
Latest version published 6 years ago

Package Health Score

55 / 100
Full package analysis