persistent-tunnel
HTTP Agent for tunneling proxies with persistent sockets
Motivation
This tunneling agent combines the latest http.Agent with a custom createConnection
function
that returns the socket of an established tunnel.
Inspired from
Use cases
Simple tunneling
var tunnel = require('persistent-tunnel');
var tunnelingAgent = new tunnel.Agent({
proxy: {
host: 'localhost',
port: 3128
}
});
tunnelingAgent.createConnection = tunnel.createConnection;
var req = http.request({
host: 'example.com',
port: 80,
agent: tunnelingAgent
});
Simple tunneling with persistent tunnels
var tunnel = require('persistent-tunnel');
var tunnelingAgent = new tunnel.Agent({
keepAlive: true
proxy: {
host: 'localhost',
port: 3128
},
});
tunnelingAgent.createConnection = tunnel.createConnection;
var req = http.request({
host: 'example.com',
port: 80,
agent: tunnelingAgent
});
Simple tunneling with persistent tunnels that expire after a timeout
var tunnel = require('persistent-tunnel');
var tunnelingAgent = new tunnel.Agent({
keepAlive: true,
proxy: {
host: 'localhost',
port: 3128
timeout: 2000
},
});
tunnelingAgent.createConnection = tunnel.createConnection;
var req = http.request({
host: 'example.com',
port: 80,
agent: tunnelingAgent
});
TODO
- https support
- proxy authorization
Support
If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.
License
Licensed under the MIT license.