How to use the global-tunnel-ng.initialize function in global-tunnel-ng

To help you get started, we’ve selected a few global-tunnel-ng 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 solid / node-solid-server / lib / create-server.js View on Github external
// Removing ending '/'
  if (mount.length > 1 &&
    mount[mount.length - 1] === '/') {
    mount = mount.slice(0, -1)
  }
  app.use(mount, ldpApp)
  debug.settings('Base URL (--mount): ' + mount)

  if (argv.idp) {
    console.warn('The idp configuration option has been renamed to multiuser.')
    argv.multiuser = argv.idp
    delete argv.idp
  }

  if (argv.httpProxy) {
    globalTunnel.initialize(argv.httpProxy)
  }

  let server
  const needsTLS = argv.sslKey || argv.sslCert
  if (!needsTLS) {
    server = http.createServer(app)
  } else {
    debug.settings('SSL Private Key path: ' + argv.sslKey)
    debug.settings('SSL Certificate path: ' + argv.sslCert)

    if (!argv.sslCert && !argv.sslKey) {
      throw new Error('Missing SSL cert and SSL key to enable WebIDs')
    }

    if (!argv.sslKey && argv.sslCert) {
      throw new Error('Missing path for SSL key')
github yeoman / doctor / lib / cli.js View on Github external
#!/usr/bin/env node
'use strict';
require('.')();

// Override http networking to go through a proxy if one is configured.
const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);

if (MAJOR_NODEJS_VERSION >= 10) {
  // `global-agent` works with Node.js v10 and above.
  require('global-agent').bootstrap();
} else {
  // `global-tunnel-ng` works only with Node.js v10 and below.
  require('global-tunnel-ng').initialize();
}
github cyclosproject / ng-swagger-gen / ng-swagger-gen.js View on Github external
function setupProxy() {
  var globalAgent = require('global-agent');
  var globalTunnel = require('global-tunnel-ng');
  var proxyAddress = getProxyAndSetupEnv();

  const NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
  if (NODEJS_VERSION >= 10 && proxyAddress) {
    // `global-agent` works with Node.js v10 and above.
    globalAgent.bootstrap();
    global.GLOBAL_AGENT.HTTP_PROXY = proxyAddress;
  } else {
    // `global-tunnel-ng` works only with Node.js v10 and below.
    globalTunnel.initialize();
  }
}
github yeoman / yo / lib / cli.js View on Github external
const list = require('cli-list');
const Tabtab = require('tabtab');
const pkg = require('../package.json');
const Router = require('./router');

const gens = list(process.argv.slice(2));

// Override http networking to go through a proxy ifone is configured
const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);

if (MAJOR_NODEJS_VERSION >= 10) {
  // `global-agent` works with Node.js v10 and above.
  require('global-agent').bootstrap();
} else {
  // `global-tunnel-ng` works only with Node.js v10 and below.
  require('global-tunnel-ng').initialize();
}

/* eslint new-cap: 0, no-extra-parens: 0 */
const tabtab = new Tabtab.Commands.default({
  name: 'yo',
  completer: 'yo-complete'
});

const cli = gens.map(gen => {
  const minicli = meow({help: false, pkg, argv: gen});
  const opts = minicli.flags;
  const args = minicli.input;

  // Add un-camelized options too, for legacy
  // TODO: Remove some time in the future when generators have upgraded
  for (const key of Object.keys(opts)) {
github balena-io / balena-cli / lib / app-common.ts View on Github external
// Doing this before requiring any other modules,
	// including the 'balena-sdk', to prevent any module from reading the http proxy config
	// before us
	const globalTunnel = require('global-tunnel-ng');
	const settings = require('balena-settings-client');
	let proxy;
	try {
		proxy = settings.get('proxy') || null;
	} catch (error1) {
		proxy = null;
	}

	// Init the tunnel even if the proxy is not configured
	// because it can also get the proxy from the http(s)_proxy env var
	// If that is not set as well the initialize will do nothing
	globalTunnel.initialize(proxy);

	// TODO: make this a feature of capitano https://github.com/balena-io/capitano/issues/48
	(global as any).PROXY_CONFIG = globalTunnel.proxyConfig;
}
github nusr / FBIWarning / src / base.ts View on Github external
startProxy(proxy: string) {
        if (!proxy) {
            return;
        }
        let proxyConfig: any = urlUtil.parse(proxy);
        const {port, hostname, protocol} = proxyConfig;
        if (COMMON_CONFIG.proxy.includes(protocol)) {
            if (proxyConfig.protocol === COMMON_CONFIG.proxy[0]) {
                this.isSocksProxy = true;
            } else {
                globalTunnel.initialize({
                    connect: 'both',
                    host: hostname,
                    port,
                    protocol
                });
            }
        } else {
            console.log(COMMON_CONFIG.errorText);
            process.exit();
        }
    }

global-tunnel-ng

Global HTTP & HTTPS tunneling

BSD-3-Clause
Latest version published 6 years ago

Package Health Score

56 / 100
Full package analysis