socks-proxy-agent
Advanced tools
Comparing version 0.1.2 to 1.0.0
1.0.0 / 2015-02-11 | ||
================== | ||
* add client-side DNS lookup logic for 4 and 5 version socks proxies | ||
* remove dead `onproxyconnect()` code function | ||
* use a switch statement to decide the socks `version` | ||
* refactor to use "socks-client" instead of "rainbowsocks" | ||
* package: remove "rainbowsocks" dependency | ||
* package: allow any "mocha" v2 | ||
0.1.2 / 2014-06-11 | ||
@@ -3,0 +13,0 @@ ================== |
{ | ||
"name": "socks-proxy-agent", | ||
"version": "0.1.2", | ||
"version": "1.0.0", | ||
"description": "A SOCKS (v4a) proxy `http.Agent` implementation for HTTP and HTTPS", | ||
@@ -29,8 +29,8 @@ "main": "socks-proxy-agent.js", | ||
"agent-base": "~1.0.1", | ||
"rainbowsocks": "~0.1.2", | ||
"extend": "~1.2.1" | ||
"extend": "~1.2.1", | ||
"socks-client": "~1.1.2" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.18.2" | ||
"mocha": "2" | ||
} | ||
} |
@@ -8,5 +8,6 @@ | ||
var url = require('url'); | ||
var dns = require('dns'); | ||
var extend = require('extend'); | ||
var Agent = require('agent-base'); | ||
var RainbowSocks = require('rainbowsocks'); | ||
var SocksClient = require('socks-client'); | ||
var inherits = require('util').inherits; | ||
@@ -54,2 +55,23 @@ | ||
// figure out if we want socks v4 or v5, based on the "protocol" used. | ||
// Defaults to 5. | ||
proxy.lookup = false; | ||
switch (proxy.protocol) { | ||
case 'socks4:': | ||
proxy.lookup = true; | ||
// pass through | ||
case 'socks4a:': | ||
proxy.version = 4; | ||
break; | ||
case 'socks5:': | ||
proxy.lookup = true; | ||
// pass through | ||
case 'socks:': // no version specified, default to 5h | ||
case 'socks5h:': | ||
proxy.version = 5; | ||
break; | ||
default: | ||
throw new TypeError('A "socks" protocol must be specified! Got: ' + proxy.protocol); | ||
} | ||
this.proxy = proxy; | ||
@@ -87,8 +109,2 @@ } | ||
// called once the SOCKS proxy has been connected to | ||
function onproxyconnect (err) { | ||
if (err) return fn(err); | ||
socks.connect(opts.host, opts.port, onhostconnect); | ||
} | ||
// called once the SOCKS proxy has connected to the specified remote endpoint | ||
@@ -108,2 +124,3 @@ function onhostconnect (err, socket) { | ||
s = tls.connect(opts); | ||
socket.resume(); | ||
} | ||
@@ -113,4 +130,29 @@ fn(null, s); | ||
var socks = new RainbowSocks(proxy.port, proxy.host); | ||
socks.once('connect', onproxyconnect); | ||
// called for the `dns.lookup()` callback | ||
function onlookup (err, ip, type) { | ||
if (err) return fn(err); | ||
options.target.host = ip; | ||
SocksClient.createConnection(options, onhostconnect); | ||
} | ||
var options = { | ||
proxy: { | ||
ipaddress: proxy.host, | ||
port: proxy.port, | ||
type: proxy.version | ||
}, | ||
target: { | ||
port: opts.port | ||
}, | ||
command: 'connect' | ||
}; | ||
if (proxy.lookup) { | ||
// client-side DNS resolution for "4" and "5" socks proxy versions | ||
dns.lookup(opts.host, onlookup); | ||
} else { | ||
// proxy hostname DNS resolution for "4a" and "5h" socks proxy servers | ||
options.target.host = opts.host; | ||
SocksClient.createConnection(options, onhostconnect); | ||
} | ||
} |
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
Network access
Supply chain riskThis module accesses the network.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
12074
183
1
5
+ Addedsocks-client@~1.1.2
+ Addedip@0.3.3(transitive)
+ Addedsmart-buffer@1.1.15(transitive)
+ Addedsocks-client@1.1.4(transitive)
- Removedrainbowsocks@~0.1.2
- Removeddebug@2.2.0(transitive)
- Removedms@0.7.1(transitive)
- Removedrainbowsocks@0.1.3(transitive)