How to use the tunnel.httpsOverHttps 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 DIYgod / RSSHub / lib / utils / request-wrapper.js View on Github external
});
            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) {
github Azure / azure-sdk-for-js / sdk / cosmosdb / cosmos / src / CosmosClient.ts View on Github external
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);
  }
github np-maintain / global-tunnel / index.js View on Github external
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);
  }
github Azure / azure-sdk-for-js / sdk / core / core-http / 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 Azure / azure-sdk-for-node / runtime / ms-rest / lib / filters / proxyFilter.js View on Github external
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);
  }
};
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 Azure / azure-sdk-for-java / ClientRuntimes / NodeJS / ms-rest / lib / filters / proxyFilter.js View on Github external
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);
  }
};
github Azure / azure-sdk-for-node / lib / services / core / filters / proxyfilter.js View on Github external
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);
  }
};

tunnel

Node HTTP/HTTPS Agents for tunneling proxies

MIT
Latest version published 6 years ago

Package Health Score

55 / 100
Full package analysis