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

proxy-chain

Package Overview
Dependencies
Maintainers
9
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 1.0.0-beta.1 to 1.0.0-beta.2

27

build/anonymize_proxy.js

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

});
exports.closeAnonymizedProxy = exports.anonymizeProxy = undefined;
exports.listenConnectAnonymizedProxy = exports.closeAnonymizedProxy = exports.anonymizeProxy = undefined;

@@ -92,2 +92,27 @@ var _server = require('./server');

return (0, _tools.nodeify)(promise, callback);
};
/**
* Add a callback on 'tunnelConnectResponded' Event in order to get headers from CONNECT tunnel to proxy
* Useful for some proxies that are using headers to send information like ProxyMesh
* @param anonymizedProxyUrl
* @param tunnelConnectRespondedCallback Callback to be invoked upon receiving the response. It
* shall take an object as its parameter, with three keys `response`, `socket`, and `head` as
* described here: https://nodejs.org/api/http.html#http_event_connect
* @returns `true` if the callback is successfully configured, otherwise `false` (e.g. when an
* invalid proxy URL is given).
*/
var listenConnectAnonymizedProxy = exports.listenConnectAnonymizedProxy = function listenConnectAnonymizedProxy(anonymizedProxyUrl, tunnelConnectRespondedCallback) {
var server = anonymizedProxyUrlToServer[anonymizedProxyUrl];
if (!server) {
return false;
}
server.on('tunnelConnectResponded', function (_ref) {
var response = _ref.response,
socket = _ref.socket,
head = _ref.head;
tunnelConnectRespondedCallback({ response: response, socket: socket, head: head });
});
return true;
};

@@ -91,2 +91,4 @@ 'use strict';

this.emit('tunnelConnectResponded', { response: response, socket: socket, head: head });
// HACK: force a flush of the HTTP header. This is to ensure 'head' is empty to avoid

@@ -93,0 +95,0 @@ // assert at https://github.com/request/tunnel-agent/blob/master/index.js#L160

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

closeAnonymizedProxy: _anonymize_proxy.closeAnonymizedProxy,
listenConnectAnonymizedProxy: _anonymize_proxy.listenConnectAnonymizedProxy,
createTunnel: _tcp_tunnel_tools.createTunnel,

@@ -22,0 +23,0 @@ closeTunnel: _tcp_tunnel_tools.closeTunnel

@@ -429,2 +429,15 @@ 'use strict';

handler.once('tunnelConnectResponded', function (_ref2) {
var response = _ref2.response,
socket = _ref2.socket,
head = _ref2.head;
_this6.emit('tunnelConnectResponded', {
connectionId: handler.id,
response: response,
socket: socket,
head: head
});
});
handler.run();

@@ -431,0 +444,0 @@ }

2

package.json
{
"name": "proxy-chain",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.",

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

@@ -211,2 +211,28 @@ # Programmable HTTP proxy server for Node.js

## Accessing the CONNECT response headers for proxy tunneling
Some upstream proxy providers might include valuable debugging information in the CONNECT response
headers when establishing the proxy tunnel, for they may not modify future data in the tunneled
connection.
The proxy server would emit a `tunnelConnectResponded` event for exposing such information, where
the parameter types of the event callback are described in [Node.js's documentation][1]. Example:
[1]: https://nodejs.org/api/http.html#http_event_connect
```javascript
server.on('tunnelConnectResponded', ({ response, socket, head }) => {
console.log(`CONNECT response headers received: ${response.headers}`);
});
```
Alternatively a [helper function](##helper-functions) may be used:
```javascript
listenConnectAnonymizedProxy(anonymizedProxyUrl, ({ response, socket, head }) => {
console.log(`CONNECT response headers received: ${response.headers}`);
});
```
## Helper functions

@@ -311,2 +337,8 @@

### `listenConnectAnonymizedProxy(anonymizedProxyUrl, tunnelConnectRespondedCallback)`
Allows to configure a callback on the anonymized proxy URL for the CONNECT response headers. See the
above section [Accessing the CONNECT response headers for proxy tunneling](#accessing-the-connect-response-headers-for-proxy-tunneling)
for details.
### `parseUrl(url)`

@@ -313,0 +345,0 @@

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