Comparing version 0.0.3 to 0.0.4
# Changelog | ||
- 0.0.4 (2016/01/23) | ||
- supported Node v0.12 or later. | ||
- 0.0.3 (2014/01/20) | ||
@@ -4,0 +7,0 @@ - fixed package.json |
@@ -53,6 +53,7 @@ 'use strict'; | ||
self.on('free', function onFree(socket, host, port) { | ||
self.on('free', function onFree(socket, host, port, localAddress) { | ||
var options = toOptions(host, port, localAddress); | ||
for (var i = 0, len = self.requests.length; i < len; ++i) { | ||
var pending = self.requests[i]; | ||
if (pending.host === host && pending.port === port) { | ||
if (pending.host === options.host && pending.port === options.port) { | ||
// Detect the request to connect same origin server, | ||
@@ -71,8 +72,9 @@ // reuse the connection. | ||
TunnelingAgent.prototype.addRequest = function addRequest(req, host, port) { | ||
TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { | ||
var self = this; | ||
var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); | ||
if (self.sockets.length >= this.maxSockets) { | ||
// We are over limit so we'll add it to the queue. | ||
self.requests.push({host: host, port: port, request: req}); | ||
self.requests.push(options); | ||
return; | ||
@@ -82,3 +84,3 @@ } | ||
// If we are under maxSockets create a new one. | ||
self.createSocket({host: host, port: port, request: req}, function(socket) { | ||
self.createSocket(options, function(socket) { | ||
socket.on('free', onFree); | ||
@@ -90,3 +92,3 @@ socket.on('close', onCloseOrRemove); | ||
function onFree() { | ||
self.emit('free', socket, host, port); | ||
self.emit('free', socket, options); | ||
} | ||
@@ -153,3 +155,3 @@ | ||
var error = new Error('tunneling socket could not be established, ' + | ||
'sutatusCode=' + res.statusCode); | ||
'statusCode=' + res.statusCode); | ||
error.code = 'ECONNRESET'; | ||
@@ -208,2 +210,13 @@ options.request.emit('error', error); | ||
function toOptions(host, port, localAddress) { | ||
if (typeof host === 'string') { // since v0.10 | ||
return { | ||
host: host, | ||
port: port, | ||
localAddress: localAddress | ||
}; | ||
} | ||
return host; // for v0.11 or later | ||
} | ||
function mergeOptions(target) { | ||
@@ -210,0 +223,0 @@ for (var i = 1, len = arguments.length; i < len; ++i) { |
{ | ||
"name": "tunnel", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Node HTTP/HTTPS Agents for tunneling proxies", | ||
@@ -9,17 +9,19 @@ "keywords": [ | ||
"agent", | ||
"proxy" | ||
"proxy", | ||
"tunnel" | ||
], | ||
"homepage": "https://github.com/koichik/node-tunnel/", | ||
"bugs": "https://github.com/koichik/node-tunnel/issues", | ||
"license": "MIT", | ||
"author": "Koichi Kobayashi <koichik@improvement.jp>", | ||
"main": "./index.js", | ||
"licenses": { | ||
"type": "The MIT License", | ||
"url": "http://www.opensource.org/licenses/mit-license.php" | ||
"directories": { | ||
"lib": "./lib" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/koichik/node-tunnel" | ||
"url": "https://github.com/koichik/node-tunnel.git" | ||
}, | ||
"engines": { | ||
"node": ">=0.6.11 <=0.7.0 || >=0.7.3" | ||
"scripts": { | ||
"test": "./node_modules/mocha/bin/mocha" | ||
}, | ||
@@ -30,5 +32,5 @@ "devDependencies": { | ||
}, | ||
"scripts": { | ||
"test": "./node_modules/mocha/bin/mocha" | ||
"engines": { | ||
"node": ">=0.6.11 <=0.7.0 || >=0.7.3" | ||
} | ||
} |
@@ -174,4 +174,7 @@ # node-tunnel - HTTP/HTTPS Agents for tunneling proxies | ||
## CONTRIBUTORS | ||
* [Aleksis Brezas (abresas)](https://github.com/abresas) | ||
## License | ||
This module is released under the [MIT License](http://www.opensource.org/licenses/mit-license.php). | ||
Licensed under the [MIT](https://github.com/koichik/node-tunnel/blob/master/LICENSE) license. |
@@ -13,2 +13,9 @@ var http = require('http'); | ||
var proxyKey = readPem('proxy1-key'); | ||
var proxyCert = readPem('proxy1-cert'); | ||
var proxyCA = readPem('ca2-cert'); | ||
var clientKey = readPem('client1-key'); | ||
var clientCert = readPem('client1-cert'); | ||
var clientCA = readPem('ca3-cert'); | ||
describe('HTTP over HTTPS', function() { | ||
@@ -38,5 +45,5 @@ it('should finish without error', function(done) { | ||
proxy = https.createServer({ | ||
key: readPem('agent4-key'), | ||
cert: readPem('agent4-cert'), | ||
ca: [readPem('ca2-cert')], // ca for agent3 | ||
key: proxyKey, | ||
cert: proxyCert, | ||
ca: [clientCA], | ||
requestCert: true, | ||
@@ -79,5 +86,6 @@ rejectUnauthorized: true | ||
port: proxyPort, | ||
// client certification for proxy | ||
key: readPem('agent3-key'), | ||
cert: readPem('agent3-cert') | ||
key: clientKey, | ||
cert: clientCert, | ||
ca: [proxyCA], | ||
rejectUnauthorized: true | ||
} | ||
@@ -84,0 +92,0 @@ }); |
@@ -13,2 +13,10 @@ var http = require('http'); | ||
var serverKey = readPem('server1-key'); | ||
var serverCert = readPem('server1-cert'); | ||
var serverCA = readPem('ca1-cert'); | ||
var clientKey = readPem('client1-key'); | ||
var clientCert = readPem('client1-cert'); | ||
var clientCA = readPem('ca3-cert'); | ||
describe('HTTPS over HTTP', function() { | ||
@@ -28,5 +36,5 @@ it('should finish without error', function(done) { | ||
server = https.createServer({ | ||
key: readPem('agent2-key'), | ||
cert: readPem('agent2-cert'), | ||
ca: [readPem('ca1-cert')], // ca for agent1 | ||
key: serverKey, | ||
cert: serverCert, | ||
ca: [clientCA], | ||
requestCert: true, | ||
@@ -76,5 +84,6 @@ rejectUnauthorized: true | ||
maxSockets: poolSize, | ||
// client certification for origin server | ||
key: readPem('agent1-key'), | ||
cert: readPem('agent1-cert'), | ||
key: clientKey, | ||
cert: clientCert, | ||
ca: [serverCA], | ||
rejectUnauthorized: true, | ||
proxy: { | ||
@@ -81,0 +90,0 @@ port: proxyPort |
@@ -13,2 +13,15 @@ var http = require('http'); | ||
var serverKey = readPem('server2-key'); | ||
var serverCert = readPem('server2-cert'); | ||
var serverCA = readPem('ca1-cert'); | ||
var proxyKey = readPem('proxy2-key'); | ||
var proxyCert = readPem('proxy2-cert'); | ||
var proxyCA = readPem('ca2-cert'); | ||
var client1Key = readPem('client1-key'); | ||
var client1Cert = readPem('client1-cert'); | ||
var client1CA = readPem('ca3-cert'); | ||
var client2Key = readPem('client2-key'); | ||
var client2Cert = readPem('client2-cert'); | ||
var client2CA = readPem('ca4-cert'); | ||
describe('HTTPS over HTTPS authentication failed', function() { | ||
@@ -27,14 +40,24 @@ it('should finish without error', function(done) { | ||
server = https.createServer({ | ||
key: readPem('agent1-key'), // agent1 is signed by ca1 | ||
cert: readPem('agent1-cert'), | ||
ca: [ readPem('ca2-cert') ], // ca for agent3 | ||
key: serverKey, | ||
cert: serverCert, | ||
ca: [client1CA], | ||
requestCert: true, | ||
rejectUnauthorized: true | ||
}, function(req, res) { | ||
tunnel.debug('SERVER: got request'); | ||
tunnel.debug('SERVER: got request', req.url); | ||
++serverConnect; | ||
res.writeHead(200); | ||
res.end('Hello, ' + serverConnect); | ||
tunnel.debug('SERVER: sending response'); | ||
req.on('data', function(data) { | ||
}); | ||
req.on('end', function() { | ||
res.writeHead(200); | ||
res.end('Hello, ' + serverConnect); | ||
tunnel.debug('SERVER: sending response'); | ||
}); | ||
req.resume(); | ||
}); | ||
//server.addContext('server2', { | ||
// key: serverKey, | ||
// cert: serverCert, | ||
// ca: [client1CA], | ||
//}); | ||
server.listen(serverPort, setupProxy); | ||
@@ -44,5 +67,5 @@ | ||
proxy = https.createServer({ | ||
key: readPem('agent3-key'), // agent3 is signed by ca2 | ||
cert: readPem('agent3-cert'), | ||
ca: [ readPem('ca1-cert') ], // ca for agent1 | ||
key: proxyKey, | ||
cert: proxyCert, | ||
ca: [client2CA], | ||
requestCert: true, | ||
@@ -53,2 +76,7 @@ rejectUnauthorized: true | ||
}); | ||
//proxy.addContext('proxy2', { | ||
// key: proxyKey, | ||
// cert: proxyCert, | ||
// ca: [client2CA], | ||
//}); | ||
proxy.on('upgrade', onConnect); // for v0.6 | ||
@@ -84,6 +112,9 @@ proxy.on('connect', onConnect); // for v0.7 or later | ||
var req = https.get({ | ||
host: 'localhost', | ||
port: serverPort, | ||
path: '/' + encodeURIComponent(name), | ||
headers: { | ||
host: host ? host : 'localhost', | ||
}, | ||
rejectUnauthorized: true, | ||
agent: agent | ||
@@ -93,3 +124,8 @@ }, function(res) { | ||
++clientConnect; | ||
req.emit('finish'); | ||
res.on('data', function(data) { | ||
}); | ||
res.on('end', function() { | ||
req.emit('finish'); | ||
}); | ||
res.resume(); | ||
}); | ||
@@ -111,3 +147,3 @@ req.on('error', function(err) { | ||
maxSockets: 1, | ||
ca: [ readPem('ca1-cert') ], // ca for origin server (agent1) | ||
ca: [serverCA], | ||
rejectUnauthorized: true, | ||
@@ -117,28 +153,32 @@ // no certificate for origin server | ||
port: proxyPort, | ||
servername: 'agent3', | ||
ca: [ readPem('ca2-cert') ], // ca for proxy server (agent3) | ||
rejectUnauthorized: true | ||
ca: [proxyCA], | ||
rejectUnauthorized: true, | ||
headers: { | ||
host: 'proxy2' | ||
} | ||
// no certificate for proxy | ||
} | ||
}, 'agent1'); | ||
}, 'server2'); | ||
doRequest('no cert proxy', { // invalid | ||
maxSockets: 1, | ||
ca: [ readPem('ca1-cert') ], // ca for origin server (agent1) | ||
ca: [serverCA], | ||
rejectUnauthorized: true, | ||
// client certification for origin server | ||
key: readPem('agent3-key'), | ||
cert: readPem('agent3-cert'), | ||
key: client1Key, | ||
cert: client1Cert, | ||
proxy: { | ||
port: proxyPort, | ||
servername: 'agent3', | ||
ca: [ readPem('ca2-cert') ], // ca for proxy server (agent3) | ||
rejectUnauthorized: true | ||
ca: [proxyCA], | ||
rejectUnauthorized: true, | ||
headers: { | ||
host: 'proxy2' | ||
} | ||
// no certificate for proxy | ||
} | ||
}, 'agent1'); | ||
}, 'server2'); | ||
doRequest('no cert origin', { // invalid | ||
maxSockets: 1, | ||
ca: [ readPem('ca1-cert') ], // ca for origin server (agent1) | ||
ca: [serverCA], | ||
rejectUnauthorized: true, | ||
@@ -148,43 +188,49 @@ // no certificate for origin server | ||
port: proxyPort, | ||
servername: 'agent3', | ||
ca: [ readPem('ca2-cert') ], // ca for proxy server (agent3) | ||
servername: 'proxy2', | ||
ca: [proxyCA], | ||
rejectUnauthorized: true, | ||
headers: { | ||
host: 'proxy2' | ||
}, | ||
// client certification for proxy | ||
key: readPem('agent1-key'), | ||
cert: readPem('agent1-cert') | ||
key: client2Key, | ||
cert: client2Cert | ||
} | ||
}, 'agent1'); | ||
}, 'server2'); | ||
doRequest('invalid proxy server name', { // invalid | ||
maxSockets: 1, | ||
ca: [ readPem('ca1-cert') ], // ca for origin server (agent1) | ||
ca: [serverCA], | ||
rejectUnauthorized: true, | ||
// client certification for origin server | ||
key: readPem('agent3-key'), | ||
cert: readPem('agent3-cert'), | ||
key: client1Key, | ||
cert: client1Cert, | ||
proxy: { | ||
port: proxyPort, | ||
ca: [ readPem('ca2-cert') ], // ca for agent3 | ||
ca: [proxyCA], | ||
rejectUnauthorized: true, | ||
// client certification for proxy | ||
key: readPem('agent1-key'), | ||
cert: readPem('agent1-cert') | ||
key: client2Key, | ||
cert: client2Cert, | ||
} | ||
}, 'agent1'); | ||
}, 'server2'); | ||
doRequest('invalid origin server name', { // invalid | ||
maxSockets: 1, | ||
ca: [ readPem('ca1-cert') ], // ca for agent1 | ||
ca: [serverCA], | ||
rejectUnauthorized: true, | ||
// client certification for origin server | ||
key: readPem('agent3-key'), | ||
cert: readPem('agent3-cert'), | ||
key: client1Key, | ||
cert: client1Cert, | ||
proxy: { | ||
port: proxyPort, | ||
servername: 'agent3', | ||
ca: [ readPem('ca2-cert') ], // ca for proxy server (agent3) | ||
servername: 'proxy2', | ||
ca: [proxyCA], | ||
rejectUnauthorized: true, | ||
headers: { | ||
host: 'proxy2' | ||
}, | ||
// client certification for proxy | ||
key: readPem('agent1-key'), | ||
cert: readPem('agent1-cert') | ||
key: client2Key, | ||
cert: client2Cert | ||
} | ||
@@ -195,17 +241,20 @@ }); | ||
maxSockets: 1, | ||
ca: [ readPem('ca1-cert') ], // ca for origin server (agent1) | ||
ca: [serverCA], | ||
rejectUnauthorized: true, | ||
// client certification for origin server | ||
key: readPem('agent3-key'), | ||
cert: readPem('agent3-cert'), | ||
key: client1Key, | ||
cert: client1Cert, | ||
proxy: { | ||
port: proxyPort, | ||
servername: 'agent3', | ||
ca: [ readPem('ca2-cert') ], // ca for proxy server (agent3) | ||
servername: 'proxy2', | ||
ca: [proxyCA], | ||
rejectUnauthorized: true, | ||
headers: { | ||
host: 'proxy2' | ||
}, | ||
// client certification for proxy | ||
key: readPem('agent1-key'), | ||
cert: readPem('agent1-cert') | ||
key: client2Key, | ||
cert: client2Cert | ||
} | ||
}, 'agent1'); | ||
}, 'server2'); | ||
} | ||
@@ -212,0 +261,0 @@ |
@@ -13,2 +13,15 @@ var http = require('http'); | ||
var serverKey = readPem('server1-key'); | ||
var serverCert = readPem('server1-cert'); | ||
var serverCA = readPem('ca1-cert'); | ||
var proxyKey = readPem('proxy1-key'); | ||
var proxyCert = readPem('proxy1-cert'); | ||
var proxyCA = readPem('ca2-cert'); | ||
var client1Key = readPem('client1-key'); | ||
var client1Cert = readPem('client1-cert'); | ||
var client1CA = readPem('ca3-cert'); | ||
var client2Key = readPem('client2-key'); | ||
var client2Cert = readPem('client2-cert'); | ||
var client2CA = readPem('ca4-cert'); | ||
describe('HTTPS over HTTPS', function() { | ||
@@ -28,5 +41,5 @@ it('should finish without error', function(done) { | ||
server = https.createServer({ | ||
key: readPem('agent2-key'), | ||
cert: readPem('agent2-cert'), | ||
ca: [readPem('ca1-cert')], // ca for agent1 | ||
key: serverKey, | ||
cert: serverCert, | ||
ca: [client1CA], | ||
requestCert: true, | ||
@@ -45,5 +58,5 @@ rejectUnauthorized: true | ||
proxy = https.createServer({ | ||
key: readPem('agent4-key'), | ||
cert: readPem('agent4-cert'), | ||
ca: [readPem('ca2-cert')], // ca for agent3 | ||
key: proxyKey, | ||
cert: proxyCert, | ||
ca: [client2CA], | ||
requestCert: true, | ||
@@ -83,9 +96,13 @@ rejectUnauthorized: true | ||
// client certification for origin server | ||
key: readPem('agent1-key'), | ||
cert: readPem('agent1-cert'), | ||
key: client1Key, | ||
cert: client1Cert, | ||
ca: [serverCA], | ||
rejectUnauthroized: true, | ||
proxy: { | ||
port: proxyPort, | ||
// client certification for proxy | ||
key: readPem('agent3-key'), | ||
cert: readPem('agent3-cert') | ||
key: client2Key, | ||
cert: client2Cert, | ||
ca: [proxyCA], | ||
rejectUnauthroized: true | ||
} | ||
@@ -92,0 +109,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
77237
0
960
180