Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

proxy-chain

Package Overview
Dependencies
Maintainers
4
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxy-chain - npm Package Compare versions

Comparing version 0.1.26 to 0.1.27

28

build/handler_base.js

@@ -38,2 +38,3 @@ 'use strict';

srcRequest = _ref.srcRequest,
srcHead = _ref.srcHead,
srcResponse = _ref.srcResponse,

@@ -56,2 +57,3 @@ trgParsed = _ref.trgParsed,

_this.srcRequest = srcRequest;
_this.srcHead = srcHead;
_this.srcResponse = srcResponse;

@@ -73,3 +75,3 @@ _this.srcSocket = srcRequest.socket;

// Create ServerResponse for the client HTTP request if it doesn't exist
// NOTE: This is undocummented API, it might break in the future
// NOTE: This is undocumented API, it might break in the future
if (!_this.srcResponse) {

@@ -232,2 +234,6 @@ _this.srcResponse = new _http2.default.ServerResponse(srcRequest);

this.srcResponse.end('' + err);
} else if (err.code === 'ENOTFOUND' && !this.upstreamProxyUrlParsed) {
this.log('Target server not found, sending 404 to client');
this.srcResponse.writeHead(404);
this.srcResponse.end('Target server not found');
} else if (err.code === 'ENOTFOUND' && this.upstreamProxyUrlParsed) {

@@ -237,6 +243,18 @@ this.log('Upstream proxy not found, sending 502 to client');

this.srcResponse.end('Upstream proxy was not found');
} else if (err.code === 'ENOTFOUND' && !this.upstreamProxyUrlParsed) {
this.log('Target server not found, sending 404 to client');
this.srcResponse.writeHead(404);
this.srcResponse.end('Target server not found');
} else if (err.code === 'ECONNREFUSED') {
this.log('Upstream proxy refused connection, sending 502 to client');
this.srcResponse.writeHead(502);
this.srcResponse.end('Upstream proxy refused connection');
} else if (err.code === 'ETIMEDOUT') {
this.log('Connection timed out, sending 502 to client');
this.srcResponse.writeHead(502);
this.srcResponse.end('Connection to upstream proxy timed out');
} else if (err.code === 'ECONNRESET') {
this.log('Connection lost, sending 502 to client');
this.srcResponse.writeHead(502);
this.srcResponse.end('Connection lost');
} else if (err.code === 'EPIPE') {
this.log('Socket closed before write, sending 502 to client');
this.srcResponse.writeHead(502);
this.srcResponse.end('Connection interrupted');
} else {

@@ -243,0 +261,0 @@ this.log('Unknown error, sending 500 to client');

22

build/handler_tunnel_chain.js

@@ -73,3 +73,3 @@ 'use strict';

key: 'onTrgRequestConnect',
value: function onTrgRequestConnect(response, socket) {
value: function onTrgRequestConnect(response, socket, head) {
if (this.isClosed) return;

@@ -84,9 +84,5 @@ this.log('Connected to upstream proxy');

// TODO: ???
// this.response.writeHead(response.statusCode, response.statusMessage);
// TODO: attach handlers to trgSocket ???
this.trgSocket = socket;
// HACK: force a flush of the HTTP header
// HACK: force a flush of the HTTP header. This is to ensure 'head' is empty to avoid
// assert at https://github.com/request/tunnel-agent/blob/master/index.js#L160
// See also https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js#L217
this.srcResponse._send('');

@@ -101,7 +97,13 @@

// Forward pre-parsed parts of the first packets (if any)
if (head && head.length > 0) {
this.srcSocket.write(head);
}
if (this.srcHead && this.srcHead.length > 0) {
this.trgSocket.write(this.srcHead);
}
// Setup bi-directional tunnel
this.trgSocket.pipe(this.srcSocket);
this.srcSocket.pipe(this.trgSocket);
// this.trgSocket.pipe(tee('to src')).pipe(this.srcSocket);
// this.srcSocket.pipe(tee('to trg')).pipe(this.trgSocket);
}

@@ -108,0 +110,0 @@ }, {

@@ -52,3 +52,3 @@ 'use strict';

key: 'onTrgSocketConnect',
value: function onTrgSocketConnect() {
value: function onTrgSocketConnect(response, socket, head) {
if (this.isClosed) return;

@@ -62,3 +62,5 @@ this.log('Connected');

// HACK: force a flush of the HTTP header
// HACK: force a flush of the HTTP header. This is to ensure 'head' is empty to avoid
// assert at https://github.com/request/tunnel-agent/blob/master/index.js#L160
// See also https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js#L217
this.srcResponse._send('');

@@ -72,7 +74,13 @@

// Forward pre-parsed parts of the first packets (if any)
if (head && head.length > 0) {
this.srcSocket.write(head);
}
if (this.srcHead && this.srcHead.length > 0) {
this.trgSocket.write(this.srcHead);
}
// Setup bi-directional tunnel
this.trgSocket.pipe(this.srcSocket);
this.srcSocket.pipe(this.trgSocket);
// this.trgSocket.pipe(tee('to src')).pipe(this.srcSocket);
// this.srcSocket.pipe(tee('to trg')).pipe(this.trgSocket);
}

@@ -79,0 +87,0 @@ }]);

@@ -190,3 +190,4 @@ 'use strict';

* @param request
* @param head
* @param socket
* @param head The first packet of the tunneling stream (may be empty)
*/

@@ -196,3 +197,3 @@

key: 'onConnect',
value: function onConnect(request) {
value: function onConnect(request, socket, head) {
var _this4 = this;

@@ -203,2 +204,3 @@

handlerOptions = handlerOpts;
handlerOptions.srcHead = head;

@@ -239,2 +241,3 @@ var handler = void 0;

srcRequest: request,
srcHead: null,
trgParsed: null,

@@ -241,0 +244,0 @@ upstreamProxyUrlParsed: null

@@ -0,1 +1,6 @@

0.1.27 / 2018-03-05
===================
- Better error messages for common network errors
- Pass headers from target socket in https tunnel chains
0.1.26 / 2018-02-14

@@ -2,0 +7,0 @@ ===================

{
"name": "proxy-chain",
"version": "0.1.26",
"version": "0.1.27",
"description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication and upstream proxy chaining.",

@@ -5,0 +5,0 @@ "main": "build/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc