How to use the global-tunnel-ng.proxyConfig 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 balena-io / balena-cli / lib / app-common.ts View on Github external
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 balena-io / balena-cli / lib / actions / ssh_direct.ts View on Github external
async action(params, options) {
		normalizeUuidProp(params);

		const proxyConfig = globalTunnel.proxyConfig;
		const useProxy = !!proxyConfig && !options.noproxy;

		const tunnelViaSocket = (
			socket: net.Socket,
			host: string,
			port: number,
			proxyAuth?: Buffer,
		): Bluebird =>
			new Bluebird((resolve, reject) => {
				let tunnelProxyResponse = '';
				socket.write(`CONNECT ${host}:${port} HTTP/1.0\r\n`);
				if (proxyAuth != null) {
					socket.write(
						`Proxy-Authorization: Basic ${proxyAuth.toString('base64')}\r\n`,
					);
				}

global-tunnel-ng

Global HTTP & HTTPS tunneling

BSD-3-Clause
Latest version published 5 years ago

Package Health Score

56 / 100
Full package analysis