proxy-chain
Advanced tools
Comparing version 0.4.5 to 0.4.6
@@ -37,13 +37,9 @@ 'use strict'; | ||
var port = void 0; | ||
var server = void 0; | ||
var startServer = function startServer(maxRecursion) { | ||
var startServer = function startServer() { | ||
return Promise.resolve().then(function () { | ||
return (0, _tools.findFreePort)(); | ||
}).then(function (result) { | ||
port = result; | ||
server = new _server.Server({ | ||
// verbose: true, | ||
port: port, | ||
port: 0, | ||
prepareRequestFunction: function prepareRequestFunction() { | ||
@@ -58,17 +54,11 @@ return { | ||
return server.listen(); | ||
}).catch(function (err) { | ||
// It might happen that the port was taken in the meantime, | ||
// in which case retry the search | ||
if (err.code === 'EADDRINUSE' && maxRecursion > 0) { | ||
return startServer(maxRecursion - 1); | ||
} | ||
throw err; | ||
}); | ||
}; | ||
var promise = startServer(_tools.PORT_SELECTION_CONFIG.RETRY_COUNT).then(function () { | ||
var url = 'http://127.0.0.1:' + port; | ||
var promise = startServer().then(function () { | ||
var url = 'http://127.0.0.1:' + server.port; | ||
anonymizedProxyUrlToServer[url] = server; | ||
return url; | ||
}); | ||
return (0, _tools.nodeify)(promise, callback); | ||
@@ -75,0 +65,0 @@ }; |
@@ -149,3 +149,7 @@ 'use strict'; | ||
_this2.port = options.port || DEFAULT_PROXY_SERVER_PORT; | ||
if (options.port === undefined || options.port === null) { | ||
_this2.port = DEFAULT_PROXY_SERVER_PORT; | ||
} else { | ||
_this2.port = options.port; | ||
} | ||
_this2.prepareRequestFunction = options.prepareRequestFunction; | ||
@@ -529,2 +533,3 @@ _this2.authRealm = options.authRealm || DEFAULT_AUTH_REALM; | ||
var onListening = function onListening() { | ||
_this7.port = _this7.server.address().port; | ||
_this7.log(null, 'Listening...'); | ||
@@ -531,0 +536,0 @@ removeListeners(); |
@@ -52,2 +52,3 @@ 'use strict'; | ||
if (options.port) return resolve(options.port); | ||
// TODO: Use port: 0 instead! | ||
(0, _tools.findFreePort)().then(resolve).catch(reject); | ||
@@ -54,0 +55,0 @@ }).then(function (port) { |
@@ -22,3 +22,2 @@ 'use strict'; | ||
var HOST_HEADER_REGEX = /^((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]))(:([0-9]+))?$/; | ||
@@ -25,0 +24,0 @@ |
@@ -0,4 +1,11 @@ | ||
0.4.6 / 2020-11-09 | ||
=================== | ||
- `Proxy.Server` now supports `port: 0` option to assign the port randomly, | ||
see PR [#98](https://github.com/apify/proxy-chain/pull/98). | ||
- `anonymizeProxy()` now uses the above port assignment rather than polling for random port => better performance | ||
- Updated NPM packages | ||
0.4.5 / 2020-05-15 | ||
=================== | ||
- Added checks for closed handlers, to prevent the `Cannot read property 'pipe' of null` errors | ||
- Added checks for closed handlers, in order to prevent the `Cannot read property 'pipe' of null` errors | ||
(see issue [#64](https://github.com/apifytech/proxy-chain/issues/64)) | ||
@@ -5,0 +12,0 @@ |
{ | ||
"name": "proxy-chain", | ||
"version": "0.4.5", | ||
"version": "0.4.6", | ||
"description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.", | ||
@@ -59,3 +59,3 @@ "main": "build/index.js", | ||
"chai": "^4.0.2", | ||
"eslint": "^6.3.0", | ||
"eslint": "^7.13.0", | ||
"eslint-config-airbnb": "^18.0.1", | ||
@@ -70,3 +70,3 @@ "eslint-config-airbnb-base": "^14.0.0", | ||
"isparta": "^4.0.0", | ||
"mocha": "^7.0.1", | ||
"mocha": "^8.2.1", | ||
"phantomjs-prebuilt": "^2.1.16", | ||
@@ -73,0 +73,0 @@ "proxy": "^1.0.1", |
# Programmable HTTP proxy server for Node.js | ||
[![npm version](https://badge.fury.io/js/proxy-chain.svg)](http://badge.fury.io/js/proxy-chain) | ||
[![Build Status](https://travis-ci.com/apifytech/proxy-chain.svg)](https://travis-ci.com/apifytech/proxy-chain) | ||
[![Build Status](https://travis-ci.com/apify/proxy-chain.svg?branch=master)](https://travis-ci.com/apify/proxy-chain) | ||
@@ -6,0 +6,0 @@ Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, |
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
129966
1911