Skip to content

np-maintain/global-tunnel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

global-tunnel

Uses node-tunnel to configure the global http and https agents to use an upstream HTTP proxy.

Build Status

Works transparently to tunnel modules that use node's default http.request() method as well as the popular request module.

Usage

To make all HTTP and HTTPS connections go through an outbound HTTP proxy:

var globalTunnel = require('global-tunnel');

globalTunnel.initialize({
  host: '127.0.0.1',
  port: 3129,
  sockets: 50 // for each http and https
});

Please Note: HTTPS connections are tunnelled insecurely over HTTP, not using the CONNECT method that a browser would use.

Then to tear-down the global agent and restore node's default global agents:

globalTunnel.end();

Any active connections will be allowed to run to completion, but new connections will use the default global agents.

Options

  • host the hostname or IP of the HTTP proxy to use
  • port the TCP port to use on that proxy
  • sockets (optional) maximum number of TCP sockets to use in each pool. There are two pools: one for HTTP and one for HTTPS. Uses node's default (5) if falsy.

Compatibility

Any module that doesn't specify an explicit agent: option to http.request will also work with global-tunnel.

The unit tests for this module verify that the popular request module works with global-tunnel active.

Auto-Config

The http_proxy environment variable will be used if the first parameter to globalTunnel.initialize is null or an empty object.

process.env.http_proxy = 'http:https://10.0.0.1:3129';
globalTunnel.initialize();

Contributing

If you'd like to contribute to or modify global-tunnel, here's a quick guide to get you started.

Development Dependencies

Set-Up

Download via GitHub and install npm dependencies:

git clone [email protected]:goinstant/global-tunnel.git
cd global-tunnel

npm install

Testing

Testing is with the mocha framework. Tests are located in the test/ directory.

To run the tests:

npm test

Support

Email GoInstant Support or stop by #goinstant on freenode.

For responsible disclosures, email GoInstant Security.

To file a bug or propose a patch, please use github directly.

Legal

© 2014 GoInstant Inc., a salesforce.com company

Licensed under the BSD 3-clause license.