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.27 to 0.1.28

build/handler_tunnel_tcp_chain.js

33

build/anonymize_proxy.js

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

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

@@ -13,6 +13,2 @@ var _bluebird = require('bluebird');

var _portastic = require('portastic');
var _portastic2 = _interopRequireDefault(_portastic);
var _server = require('./server');

@@ -27,25 +23,2 @@

var ANONYMIZED_PROXY_PORTS = exports.ANONYMIZED_PROXY_PORTS = {
FROM: 20000,
TO: 60000,
RETRY_COUNT: 10
};
var _findFreePort = function _findFreePort() {
// Let 'min' be a random value in the first half of the PORT_FROM-PORT_TO range,
// to reduce a chance of collision if other ProxyChain is started at the same time.
var half = Math.floor((ANONYMIZED_PROXY_PORTS.TO - ANONYMIZED_PROXY_PORTS.FROM) / 2);
var opts = {
min: ANONYMIZED_PROXY_PORTS.FROM + Math.floor(Math.random() * half),
max: ANONYMIZED_PROXY_PORTS.TO,
retrieve: 1
};
return _portastic2.default.find(opts).then(function (ports) {
if (ports.length < 1) throw new Error('There are no more free ports in range from ' + ANONYMIZED_PROXY_PORTS.FROM + ' to ' + ANONYMIZED_PROXY_PORTS.TO); // eslint-disable-line max-len
return ports[0];
});
};
/**

@@ -78,3 +51,3 @@ * Parses and validates a HTTP proxy URL. If the proxy requires authentication, then the function

return _bluebird2.default.resolve().then(function () {
return _findFreePort();
return (0, _tools.findFreePort)();
}).then(function (result) {

@@ -104,3 +77,3 @@ port = result;

return startServer(ANONYMIZED_PROXY_PORTS.RETRY_COUNT).then(function () {
return startServer(_tools.PORT_SELECTION_CONFIG.RETRY_COUNT).then(function () {
var url = 'http://127.0.0.1:' + port;

@@ -107,0 +80,0 @@ anonymizedProxyUrlToServer[url] = server;

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

var _tcp_tunnel = require('./tcp_tunnel');
/* globals module */

@@ -20,5 +22,7 @@

anonymizeProxy: _anonymize_proxy.anonymizeProxy,
closeAnonymizedProxy: _anonymize_proxy.closeAnonymizedProxy
closeAnonymizedProxy: _anonymize_proxy.closeAnonymizedProxy,
createTunnel: _tcp_tunnel.createTunnel,
closeTunnel: _tcp_tunnel.closeTunnel
};
module.exports = ProxyChain;

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

* If `prepareRequestFunction` is not set, the proxy server will not require any authentication
* and with not use any upstream proxy.
* and will not use any upstream proxy.
* @param [options.authRealm] Realm used in the Proxy-Authenticate header and also in the 'Server' HTTP header. By default it's `ProxyChain`.

@@ -122,0 +122,0 @@ * @param [options.verbose] If true, the server logs

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

});
exports.addHeader = exports.parseProxyAuthorizationHeader = exports.redactParsedUrl = exports.redactUrl = exports.parseUrl = exports.isInvalidHeader = exports.isHopByHopHeader = exports.parseHostHeader = undefined;
exports.findFreePort = exports.PORT_SELECTION_CONFIG = exports.addHeader = exports.parseProxyAuthorizationHeader = exports.redactParsedUrl = exports.redactUrl = exports.parseUrl = exports.isInvalidHeader = exports.isHopByHopHeader = exports.parseHostHeader = undefined;

@@ -15,5 +15,8 @@ var _url = require('url');

var _portastic = require('portastic');
var _portastic2 = _interopRequireDefault(_portastic);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// eslint-disable-line
// import through from 'through';

@@ -32,2 +35,3 @@

*/
// eslint-disable-line
var parseHostHeader = exports.parseHostHeader = function parseHostHeader(hostHeader) {

@@ -188,2 +192,25 @@ var matches = HOST_HEADER_REGEX.exec(hostHeader || '');

}
};
var PORT_SELECTION_CONFIG = exports.PORT_SELECTION_CONFIG = {
FROM: 20000,
TO: 60000,
RETRY_COUNT: 10
};
var findFreePort = exports.findFreePort = function findFreePort() {
// Let 'min' be a random value in the first half of the PORT_FROM-PORT_TO range,
// to reduce a chance of collision if other ProxyChain is started at the same time.
var half = Math.floor((PORT_SELECTION_CONFIG.TO - PORT_SELECTION_CONFIG.FROM) / 2);
var opts = {
min: PORT_SELECTION_CONFIG.FROM + Math.floor(Math.random() * half),
max: PORT_SELECTION_CONFIG.TO,
retrieve: 1
};
return _portastic2.default.find(opts).then(function (ports) {
if (ports.length < 1) throw new Error('There are no more free ports in range from ' + PORT_SELECTION_CONFIG.FROM + ' to ' + PORT_SELECTION_CONFIG.TO); // eslint-disable-line max-len
return ports[0];
});
};

@@ -0,1 +1,5 @@

0.1.27 / 2018-03-27
===================
- Added option to create tunnels through http proxies for tcp network connections (eq. connection to mongodb/sql database through http proxy)
0.1.27 / 2018-03-05

@@ -2,0 +6,0 @@ ===================

{
"name": "proxy-chain",
"version": "0.1.27",
"version": "0.1.28",
"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",

@@ -116,3 +116,29 @@ # proxy-chain

### `createTunnel(proxyUrl, target, options, callback)`
Attempts to create a network tunnel through proxy server specified in param "proxyUrl" to a network service
specified in param "target".
The function takes optional callback that receives the path to local service.
If no callback is supplied, the function returns a promise that resolves to a String with
the path to local service.
Example usage:
```javascript
const tunnel = await createTunnel('http://<username>:<password>@<proxy-server>:<port>', '<service-host>:<service-port>');
// tunnel will be in format "localhost:<randomly-assigned-port>" and while it's running
// it can be used instead of '<service-host>:<service-port>' to proxy requests.
```
### `closeTunnel(tunnelString, closeConnections, callback)`
Closes tunnel previously started by `createTunnel()`.
Returns false if tunnel is not found or running. Otherwise the result is `true`.
The `closeConnections` parameter indicates whether pending connections are forcibly closed.
The function takes optional callback that receives the result Boolean from the function.
If callback is not provided, the function returns a promise instead.
### `parseUrl(url)`

@@ -119,0 +145,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