diff options
author | Rebecca Turner <me@re-becca.org> | 2018-05-24 23:31:26 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2018-05-24 23:31:38 +0300 |
commit | 0483f5c5deaf18c968a128657923103e49f4e67a (patch) | |
tree | 210f154da2f60938471d96a844dcb32cbda09e2a /node_modules/socks-proxy-agent | |
parent | 6c294614d800cb95a49ef1c422fbdde65b0731a2 (diff) |
Flatten dependencies and add dev deps to git
Diffstat (limited to 'node_modules/socks-proxy-agent')
-rw-r--r-- | node_modules/socks-proxy-agent/.travis.yml | 21 | ||||
-rw-r--r-- | node_modules/socks-proxy-agent/History.md | 96 | ||||
-rw-r--r-- | node_modules/socks-proxy-agent/README.md | 134 | ||||
-rw-r--r-- | node_modules/socks-proxy-agent/index.js | 145 | ||||
-rw-r--r-- | node_modules/socks-proxy-agent/package.json | 69 | ||||
-rw-r--r-- | node_modules/socks-proxy-agent/test/ssl-cert-snakeoil.key | 15 | ||||
-rw-r--r-- | node_modules/socks-proxy-agent/test/ssl-cert-snakeoil.pem | 12 | ||||
-rw-r--r-- | node_modules/socks-proxy-agent/test/test.js | 144 |
8 files changed, 636 insertions, 0 deletions
diff --git a/node_modules/socks-proxy-agent/.travis.yml b/node_modules/socks-proxy-agent/.travis.yml new file mode 100644 index 000000000..1ff82daa2 --- /dev/null +++ b/node_modules/socks-proxy-agent/.travis.yml @@ -0,0 +1,21 @@ +sudo: false + +language: node_js + +node_js: + - "6" + - "7" + - "8" + - "9" + +install: + - PATH="`npm bin`:`npm bin -g`:$PATH" + # Install dependencies and build + - npm install + +script: + # Output useful info for debugging + - node --version + - npm --version + # Run tests + - npm test diff --git a/node_modules/socks-proxy-agent/History.md b/node_modules/socks-proxy-agent/History.md new file mode 100644 index 000000000..b0266b5e3 --- /dev/null +++ b/node_modules/socks-proxy-agent/History.md @@ -0,0 +1,96 @@ + +3.0.1 / 2017-09-18 +================== + + * update "agent-base" to v4.1.0 + +3.0.0 / 2017-06-13 +================== + + * [BREAKING] drop support for Node < 4 + * update deps, remove `extend` dependency + * rename `socks-proxy-agent.js` to `index.js` + +2.1.1 / 2017-06-13 +================== + + * fix a bug where `close` would emit before `end` + * use "raw-body" module for tests + * prettier + +2.1.0 / 2017-05-24 +================== + + * DRY post-lookup logic + * Fix an error in readme (#13, @599316527) + * travis: test node v5 + * travis: test iojs v1, 2, 3 and node.js v4 + * test: use ssl-cert-snakeoil cert files + * Authentication support (#9, @baryshev) + +2.0.0 / 2015-07-10 +================== + + * API CHANGE! Removed `secure` boolean second argument in constructor + * upgrade to "agent-base" v2 API + * package: update "extend" to v3 + +1.0.2 / 2015-07-01 +================== + + * remove "v4a" from description + * socks-proxy-agent: cast `port` to a Number + * travis: attempt to make node v0.8 work + * travis: test node v0.12, don't test v0.11 + * test: pass `rejectUnauthorized` as a proxy opt + * test: catch http.ClientRequest errors + * test: add self-signed SSL server cert files + * test: refactor to use local SOCKS, HTTP and HTTPS servers + * README: use SVG for Travis-CI badge + +1.0.1 / 2015-03-01 +================== + + * switched from using "socks-client" to "socks" (#5, @JoshGlazebrook) + +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 +================== + + * package: update "rainbowsocks" to v0.1.2 + * travis: don't test node v0.9 + +0.1.1 / 2014-04-09 +================== + + * package: update outdated dependencies + * socks-proxy-agent: pass `secure` flag when no `new` + * socks-proxy-agent: small code cleanup + +0.1.0 / 2013-11-19 +================== + + * add .travis.yml file + * socks-proxy-agent: properly mix in the proxy options + * socks-proxy-agent: coerce the `secureEndpoint` into a Boolean + * socks-proxy-agent: use "extend" module + * socks-proxy-agent: update to "agent-base" v1 API + +0.0.2 / 2013-07-24 +================== + + * socks-proxy-agent: properly set the `defaultPort` property + +0.0.1 / 2013-07-11 +================== + + * Initial release diff --git a/node_modules/socks-proxy-agent/README.md b/node_modules/socks-proxy-agent/README.md new file mode 100644 index 000000000..30d33500a --- /dev/null +++ b/node_modules/socks-proxy-agent/README.md @@ -0,0 +1,134 @@ +socks-proxy-agent +================ +### A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS +[![Build Status](https://travis-ci.org/TooTallNate/node-socks-proxy-agent.svg?branch=master)](https://travis-ci.org/TooTallNate/node-socks-proxy-agent) + +This module provides an `http.Agent` implementation that connects to a +specified SOCKS proxy server, and can be used with the built-in `http` +or `https` modules. + +It can also be used in conjunction with the `ws` module to establish a WebSocket +connection over a SOCKS proxy. See the "Examples" section below. + +Installation +------------ + +Install with `npm`: + +``` bash +$ npm install socks-proxy-agent +``` + + +Examples +-------- + +#### `http` module example + +``` js +var url = require('url'); +var http = require('http'); +var SocksProxyAgent = require('socks-proxy-agent'); + +// SOCKS proxy to connect to +var proxy = process.env.socks_proxy || 'socks://127.0.0.1:9050'; +console.log('using proxy server %j', proxy); + +// HTTP endpoint for the proxy to connect to +var endpoint = process.argv[2] || 'http://nodejs.org/api/'; +console.log('attempting to GET %j', endpoint); +var opts = url.parse(endpoint); + +// create an instance of the `SocksProxyAgent` class with the proxy server information +var agent = new SocksProxyAgent(proxy); +opts.agent = agent; + +http.get(opts, function (res) { + console.log('"response" event!', res.headers); + res.pipe(process.stdout); +}); +``` + +#### `https` module example + +``` js +var url = require('url'); +var https = require('https'); +var SocksProxyAgent = require('socks-proxy-agent'); + +// SOCKS proxy to connect to +var proxy = process.env.socks_proxy || 'socks://127.0.0.1:9050'; +console.log('using proxy server %j', proxy); + +// HTTP endpoint for the proxy to connect to +var endpoint = process.argv[2] || 'https://encrypted.google.com/'; +console.log('attempting to GET %j', endpoint); +var opts = url.parse(endpoint); + +// create an instance of the `SocksProxyAgent` class with the proxy server information +// NOTE: the `true` second argument! Means to use TLS encryption on the socket +var agent = new SocksProxyAgent(proxy, true); +opts.agent = agent; + +https.get(opts, function (res) { + console.log('"response" event!', res.headers); + res.pipe(process.stdout); +}); +``` + +#### `ws` WebSocket connection example + +``` js +var WebSocket = require('ws'); +var SocksProxyAgent = require('socks-proxy-agent'); + +// SOCKS proxy to connect to +var proxy = process.env.socks_proxy || 'socks://127.0.0.1:9050'; +console.log('using proxy server %j', proxy); + +// WebSocket endpoint for the proxy to connect to +var endpoint = process.argv[2] || 'ws://echo.websocket.org'; +console.log('attempting to connect to WebSocket %j', endpoint); + +// create an instance of the `SocksProxyAgent` class with the proxy server information +var agent = new SocksProxyAgent(proxy); + +// initiate the WebSocket connection +var socket = new WebSocket(endpoint, { agent: agent }); + +socket.on('open', function () { + console.log('"open" event!'); + socket.send('hello world'); +}); + +socket.on('message', function (data, flags) { + console.log('"message" event! %j %j', data, flags); + socket.close(); +}); +``` + +License +------- + +(The MIT License) + +Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/socks-proxy-agent/index.js b/node_modules/socks-proxy-agent/index.js new file mode 100644 index 000000000..5c0f13ae1 --- /dev/null +++ b/node_modules/socks-proxy-agent/index.js @@ -0,0 +1,145 @@ +/** + * Module dependencies. + */ + +var tls; // lazy-loaded... +var url = require('url'); +var dns = require('dns'); +var Agent = require('agent-base'); +var SocksClient = require('socks').SocksClient; +var inherits = require('util').inherits; + +/** + * Module exports. + */ + +module.exports = SocksProxyAgent; + +/** + * The `SocksProxyAgent`. + * + * @api public + */ + +function SocksProxyAgent(opts) { + if (!(this instanceof SocksProxyAgent)) return new SocksProxyAgent(opts); + if ('string' == typeof opts) opts = url.parse(opts); + if (!opts) + throw new Error( + 'a SOCKS proxy server `host` and `port` must be specified!' + ); + Agent.call(this, opts); + + var proxy = Object.assign({}, opts); + + // prefer `hostname` over `host`, because of `url.parse()` + proxy.host = proxy.hostname || proxy.host; + + // SOCKS doesn't *technically* have a default port, but this is + // the same default that `curl(1)` uses + proxy.port = +proxy.port || 1080; + + if (proxy.host && proxy.path) { + // if both a `host` and `path` are specified then it's most likely the + // result of a `url.parse()` call... we need to remove the `path` portion so + // that `net.connect()` doesn't attempt to open that as a unix socket file. + delete proxy.path; + delete proxy.pathname; + } + + // 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 + ); + } + + if (proxy.auth) { + var auth = proxy.auth.split(':'); + proxy.authentication = { username: auth[0], password: auth[1] }; + proxy.userid = auth[0]; + } + this.proxy = proxy; +} +inherits(SocksProxyAgent, Agent); + +/** + * Initiates a SOCKS connection to the specified SOCKS proxy server, + * which in turn connects to the specified remote host and port. + * + * @api public + */ + +SocksProxyAgent.prototype.callback = function connect(req, opts, fn) { + var proxy = this.proxy; + + // called once the SOCKS proxy has connected to the specified remote endpoint + function onhostconnect(err, result) { + if (err) return fn(err); + + var socket = result.socket; + + var s = socket; + if (opts.secureEndpoint) { + // since the proxy is connecting to an SSL server, we have + // to upgrade this socket connection to an SSL connection + if (!tls) tls = require('tls'); + opts.socket = socket; + opts.servername = opts.host; + opts.host = null; + opts.hostname = null; + opts.port = null; + s = tls.connect(opts); + } + + fn(null, s); + } + + // called for the `dns.lookup()` callback + function onlookup(err, ip) { + if (err) return fn(err); + options.destination.host = ip; + SocksClient.createConnection(options, onhostconnect); + } + + var options = { + proxy: { + ipaddress: proxy.host, + port: +proxy.port, + type: proxy.version + }, + destination: { + port: +opts.port + }, + command: 'connect' + }; + + if (proxy.authentication) { + options.proxy.authentication = proxy.authentication; + options.proxy.userid = proxy.userid; + } + + 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 + onlookup(null, opts.host); + } +} diff --git a/node_modules/socks-proxy-agent/package.json b/node_modules/socks-proxy-agent/package.json new file mode 100644 index 000000000..02ca38c79 --- /dev/null +++ b/node_modules/socks-proxy-agent/package.json @@ -0,0 +1,69 @@ +{ + "_from": "socks-proxy-agent@^4.0.0", + "_id": "socks-proxy-agent@4.0.1", + "_inBundle": false, + "_integrity": "sha512-Kezx6/VBguXOsEe5oU3lXYyKMi4+gva72TwJ7pQY5JfqUx2nMk7NXA6z/mpNqIlfQjWYVfeuNvQjexiTaTn6Nw==", + "_location": "/socks-proxy-agent", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "socks-proxy-agent@^4.0.0", + "name": "socks-proxy-agent", + "escapedName": "socks-proxy-agent", + "rawSpec": "^4.0.0", + "saveSpec": null, + "fetchSpec": "^4.0.0" + }, + "_requiredBy": [ + "/make-fetch-happen" + ], + "_resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-4.0.1.tgz", + "_shasum": "5936bf8b707a993079c6f37db2091821bffa6473", + "_spec": "socks-proxy-agent@^4.0.0", + "_where": "/Users/rebecca/code/npm/node_modules/make-fetch-happen", + "author": { + "name": "Nathan Rajlich", + "email": "nathan@tootallnate.net", + "url": "http://n8.io/" + }, + "bugs": { + "url": "https://github.com/TooTallNate/node-socks-proxy-agent/issues" + }, + "bundleDependencies": false, + "dependencies": { + "agent-base": "~4.2.0", + "socks": "~2.2.0" + }, + "deprecated": false, + "description": "A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS", + "devDependencies": { + "mocha": "~5.1.0", + "raw-body": "~2.3.2", + "socksv5": "0.0.6" + }, + "engines": { + "node": ">= 6" + }, + "homepage": "https://github.com/TooTallNate/node-socks-proxy-agent#readme", + "keywords": [ + "socks", + "socks4", + "socks4a", + "proxy", + "http", + "https", + "agent" + ], + "license": "MIT", + "main": "./index.js", + "name": "socks-proxy-agent", + "repository": { + "type": "git", + "url": "git://github.com/TooTallNate/node-socks-proxy-agent.git" + }, + "scripts": { + "test": "mocha --reporter spec" + }, + "version": "4.0.1" +} diff --git a/node_modules/socks-proxy-agent/test/ssl-cert-snakeoil.key b/node_modules/socks-proxy-agent/test/ssl-cert-snakeoil.key new file mode 100644 index 000000000..fd1250122 --- /dev/null +++ b/node_modules/socks-proxy-agent/test/ssl-cert-snakeoil.key @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICWwIBAAKBgQCzURxIqzer0ACAbX/lHdsn4Gd9PLKrf7EeDYfIdV0HZKPD8WDr +bBx2/fBu0OW2sjnzv/SVZbJ0DAuPE/p0+eT0qb2qC10iz9iTD7ribd7gxhirVb8y +b3fBjXsxc8V8p4Ny1LcvNSqCjwUbJqdRogfoJeTiqPM58z5sNzuv5iq7iwIDAQAB +AoGAPMQy4olrP0UotlzlJ36bowLP70ffgHCwU+/f4NWs5fF78c3du0oSx1w820Dd +Z7E0JF8bgnlJJTxjumPZz0RUCugrEHBKJmzEz3cxF5E3+7NvteZcjKn9D67RrM5x +1/uSZ9cqKE9cYvY4fSuHx18diyZ4axR/wB1Pea2utjjDM+ECQQDb9ZbmmaWMiRpQ +5Up+loxP7BZNPsEVsm+DVJmEFbaFgGfncWBqSIqnPNjMwTwj0OigTwCAEGPkfRVW +T0pbYWCxAkEA0LK7SCTwzyDmhASUalk0x+3uCAA6ryFdwJf/wd8TRAvVOmkTEldX +uJ7ldLvfrONYO3v56uKTU/SoNdZYzKtO+wJAX2KM4ctXYy5BXztPpr2acz4qHa1N +Bh+vBAC34fOYhyQ76r3b1btHhWZ5jbFuZwm9F2erC94Ps5IaoqcX07DSwQJAPKGw +h2U0EPkd/3zVIZCJJQya+vgWFIs9EZcXVtvYXQyTBkVApTN66MhBIYjzkub5205J +bVQmOV37AKklY1DhwQJAA1wos0cYxro02edzatxd0DIR2r4qqOqLkw6BhYHhq6HJ +ZvIcQkHqdSXzdETFc01I1znDGGIrJHcnvKWgBPoEUg== +-----END RSA PRIVATE KEY----- diff --git a/node_modules/socks-proxy-agent/test/ssl-cert-snakeoil.pem b/node_modules/socks-proxy-agent/test/ssl-cert-snakeoil.pem new file mode 100644 index 000000000..b115a5e91 --- /dev/null +++ b/node_modules/socks-proxy-agent/test/ssl-cert-snakeoil.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIB1TCCAT4CCQDV5mPlzm9+izANBgkqhkiG9w0BAQUFADAvMS0wKwYDVQQDEyQ3 +NTI3YmQ3Ny1hYjNlLTQ3NGItYWNlNy1lZWQ2MDUzOTMxZTcwHhcNMTUwNzA2MjI0 +NTA3WhcNMjUwNzAzMjI0NTA3WjAvMS0wKwYDVQQDEyQ3NTI3YmQ3Ny1hYjNlLTQ3 +NGItYWNlNy1lZWQ2MDUzOTMxZTcwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB +ALNRHEirN6vQAIBtf+Ud2yfgZ308sqt/sR4Nh8h1XQdko8PxYOtsHHb98G7Q5bay +OfO/9JVlsnQMC48T+nT55PSpvaoLXSLP2JMPuuJt3uDGGKtVvzJvd8GNezFzxXyn +g3LUty81KoKPBRsmp1GiB+gl5OKo8znzPmw3O6/mKruLAgMBAAEwDQYJKoZIhvcN +AQEFBQADgYEACzoHUF8UV2Z6541Q2wKEA0UFUzmUjf/E1XwBO+1P15ZZ64uw34B4 +1RwMPtAo9RY/PmICTWtNxWGxkzwb2JtDWtnxVER/lF8k2XcXPE76fxTHJF/BKk9J +QU8OTD1dd9gHCBviQB9TqntRZ5X7axjtuWjb2umY+owBYzAHZkp1HKI= +-----END CERTIFICATE----- diff --git a/node_modules/socks-proxy-agent/test/test.js b/node_modules/socks-proxy-agent/test/test.js new file mode 100644 index 000000000..968ef650f --- /dev/null +++ b/node_modules/socks-proxy-agent/test/test.js @@ -0,0 +1,144 @@ + +/** + * Module dependencies. + */ + +var fs = require('fs'); +var url = require('url'); +var http = require('http'); +var https = require('https'); +var assert = require('assert'); +var socks = require('socksv5'); +var getRawBody = require('raw-body'); +var SocksProxyAgent = require('../'); + +describe('SocksProxyAgent', function () { + var httpServer, httpPort; + var httpsServer, httpsPort; + var socksServer, socksPort; + + before(function (done) { + // setup SOCKS proxy server + socksServer = socks.createServer(function(info, accept, deny) { + accept(); + }); + socksServer.listen(0, '127.0.0.1', function() { + socksPort = socksServer.address().port; + //console.log('SOCKS server listening on port %d', socksPort); + done(); + }); + socksServer.useAuth(socks.auth.None()); + //socksServer.useAuth(socks.auth.UserPassword(function(user, password, cb) { + // cb(user === 'nodejs' && password === 'rules!'); + //})); + }); + + before(function (done) { + // setup target HTTP server + httpServer = http.createServer(); + httpServer.listen(function () { + httpPort = httpServer.address().port; + done(); + }); + }); + + before(function (done) { + // setup target SSL HTTPS server + var options = { + key: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.key'), + cert: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.pem') + }; + httpsServer = https.createServer(options); + httpsServer.listen(function () { + httpsPort = httpsServer.address().port; + done(); + }); + }); + + after(function (done) { + socksServer.once('close', function () { done(); }); + socksServer.close(); + }); + + after(function (done) { + httpServer.once('close', function () { done(); }); + httpServer.close(); + }); + + after(function (done) { + httpsServer.once('close', function () { done(); }); + httpsServer.close(); + }); + + describe('constructor', function () { + it('should throw an Error if no "proxy" argument is given', function () { + assert.throws(function () { + new SocksProxyAgent(); + }); + }); + it('should accept a "string" proxy argument', function () { + var agent = new SocksProxyAgent('socks://127.0.0.1:' + socksPort); + assert.equal('127.0.0.1', agent.proxy.host); + assert.equal(socksPort, agent.proxy.port); + }); + it('should accept a `url.parse()` result object argument', function () { + var opts = url.parse('socks://127.0.0.1:' + socksPort); + var agent = new SocksProxyAgent(opts); + assert.equal('127.0.0.1', agent.proxy.host); + assert.equal(socksPort, agent.proxy.port); + }); + }); + + describe('"http" module', function () { + it('should work against an HTTP endpoint', function (done) { + httpServer.once('request', function (req, res) { + assert.equal('/foo', req.url); + res.statusCode = 404; + res.end(JSON.stringify(req.headers)); + }); + + var agent = new SocksProxyAgent('socks://127.0.0.1:' + socksPort); + var opts = url.parse('http://127.0.0.1:' + httpPort + '/foo'); + opts.agent = agent; + opts.headers = { foo: 'bar' }; + var req = http.get(opts, function (res) { + assert.equal(404, res.statusCode); + getRawBody(res, 'utf8', function (err, buf) { + if (err) return done(err); + var data = JSON.parse(buf); + assert.equal('bar', data.foo); + done(); + }); + }); + req.once('error', done); + }); + }); + + describe('"https" module', function () { + it('should work against an HTTPS endpoint', function (done) { + httpsServer.once('request', function (req, res) { + assert.equal('/foo', req.url); + res.statusCode = 404; + res.end(JSON.stringify(req.headers)); + }); + + var agent = new SocksProxyAgent('socks://127.0.0.1:' + socksPort); + var opts = url.parse('https://127.0.0.1:' + httpsPort + '/foo'); + opts.agent = agent; + opts.rejectUnauthorized = false; + + opts.headers = { foo: 'bar' }; + var req = https.get(opts, function (res) { + assert.equal(404, res.statusCode); + getRawBody(res, 'utf8', function (err, buf) { + if (err) return done(err); + var data = JSON.parse(buf); + assert.equal('bar', data.foo); + done(); + }); + }); + req.once('error', done); + }); + }); + +}); |