Intial Commit
This commit is contained in:
2
nodered/rootfs/data/node_modules/socks5-https-client/.npmignore
generated
vendored
Normal file
2
nodered/rootfs/data/node_modules/socks5-https-client/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
7
nodered/rootfs/data/node_modules/socks5-https-client/.travis.yml
generated
vendored
Normal file
7
nodered/rootfs/data/node_modules/socks5-https-client/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- "0.12"
|
||||
- "0.10"
|
||||
|
||||
script: make test
|
||||
11
nodered/rootfs/data/node_modules/socks5-https-client/Makefile
generated
vendored
Normal file
11
nodered/rootfs/data/node_modules/socks5-https-client/Makefile
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
test: index.js lib/*.js node_modules
|
||||
./node_modules/.bin/mocha \
|
||||
--reporter dot \
|
||||
--check-leaks \
|
||||
--ui tdd
|
||||
|
||||
node_modules: package.json
|
||||
npm install
|
||||
touch $@
|
||||
|
||||
.PHONY: test
|
||||
60
nodered/rootfs/data/node_modules/socks5-https-client/README.md
generated
vendored
Normal file
60
nodered/rootfs/data/node_modules/socks5-https-client/README.md
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# SOCKS5 HTTPS Client #
|
||||
|
||||
[](https://travis-ci.org/mattcg/socks5-https-client)
|
||||
|
||||
SOCKS v5 HTTPS client implementation in JavaScript for Node.js.
|
||||
|
||||
```js
|
||||
var shttps = require('socks5-https-client');
|
||||
|
||||
shttps.get({
|
||||
hostname: 'encrypted.google.com',
|
||||
path: '/',
|
||||
rejectUnauthorized: true // This is the default.
|
||||
}, function(res) {
|
||||
res.setEncoding('utf8');
|
||||
res.on('readable', function() {
|
||||
console.log(res.read()); // Log response to console.
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
Specify the `socksHost` and `socksPort` options if your SOCKS server isn't running on `localhost:1080`. Tor runs its SOCKS server on port `9050` by default, for example.
|
||||
|
||||
Username and password authentication is supported with the `socksUsername` and `socksPassword` options.
|
||||
|
||||
You may also pass a URL as the first argument to `get` or `request`, which will be parsed using `url.parse`.
|
||||
|
||||
## Using with Tor ##
|
||||
|
||||
Works great for making HTTPS requests through [Tor](https://www.torproject.org/).
|
||||
|
||||
Make sure a Tor server is running locally and run `node example/tor https://check.torproject.org/` to test.
|
||||
|
||||
## Using with Request ##
|
||||
|
||||
To use with [Request](https://github.com/mikeal/request), just pass a reference to the `Agent` constructor..
|
||||
|
||||
```js
|
||||
var Agent = require('socks5-https-client/lib/Agent');
|
||||
|
||||
request({
|
||||
url: 'https://encrypted.google.com/',
|
||||
strictSSL: true,
|
||||
agentClass: Agent,
|
||||
agentOptions: {
|
||||
socksHost: 'my-tor-proxy-host', // Defaults to 'localhost'.
|
||||
socksPort: 9050 // Defaults to 1080.
|
||||
}
|
||||
}, function(err, res) {
|
||||
console.log(err || res.body);
|
||||
});
|
||||
```
|
||||
|
||||
## HTTP ##
|
||||
|
||||
This client only provides support for making HTTPS requests. See [socks5-http-client](https://github.com/mattcg/socks5-http-client) for an HTTP implementation.
|
||||
|
||||
## License ##
|
||||
|
||||
Copyright © 2013 [Matthew Caruana Galizia](http://twitter.com/mcaruanagalizia), licensed under an [MIT license](http://mattcg.mit-license.org/).
|
||||
17
nodered/rootfs/data/node_modules/socks5-https-client/example/tor-request.js
generated
vendored
Normal file
17
nodered/rootfs/data/node_modules/socks5-https-client/example/tor-request.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
/*jshint node:true*/
|
||||
|
||||
var request = require('request');
|
||||
|
||||
var Agent = require('../lib/Agent');
|
||||
|
||||
request({
|
||||
url: process.argv[2],
|
||||
agentClass: Agent,
|
||||
agentOptions: {
|
||||
socksPort: 9050 // Defaults to 1080.
|
||||
}
|
||||
}, function(err, res) {
|
||||
console.log(res.body);
|
||||
});
|
||||
33
nodered/rootfs/data/node_modules/socks5-https-client/example/tor.js
generated
vendored
Normal file
33
nodered/rootfs/data/node_modules/socks5-https-client/example/tor.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
/*jshint node:true*/
|
||||
|
||||
var url = require('url');
|
||||
var shttps = require('../');
|
||||
|
||||
var options = url.parse(process.argv[2]);
|
||||
|
||||
options.socksPort = 9050; // Tor default port.
|
||||
|
||||
var req = shttps.get(options, function(res) {
|
||||
res.setEncoding('utf8');
|
||||
|
||||
res.on('readable', function() {
|
||||
var data = res.read();
|
||||
|
||||
// Check for the end of stream signal.
|
||||
if (null === data) {
|
||||
process.stdout.write('\n');
|
||||
return;
|
||||
}
|
||||
|
||||
process.stdout.write(data);
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', function(e) {
|
||||
console.error('Problem with request: ' + e.message);
|
||||
});
|
||||
|
||||
// GET request, so end without sending any data.
|
||||
req.end();
|
||||
47
nodered/rootfs/data/node_modules/socks5-https-client/index.js
generated
vendored
Normal file
47
nodered/rootfs/data/node_modules/socks5-https-client/index.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @overview
|
||||
* @author Matthew Caruana Galizia <m@m.cg>
|
||||
* @license MIT
|
||||
* @copyright Copyright (c) 2013, Matthew Caruana Galizia
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/*jshint node:true*/
|
||||
|
||||
var https = require('https');
|
||||
var url = require('url');
|
||||
|
||||
var Agent = require('./lib/Agent');
|
||||
|
||||
exports.request = function(options, cb) {
|
||||
var agent, version;
|
||||
|
||||
if (typeof options === 'string') {
|
||||
options = url.parse(options);
|
||||
}
|
||||
|
||||
options.protocol = 'https:';
|
||||
|
||||
// Node v0.12.0 requires the port to be specified.
|
||||
if (!options.port && options.host) {
|
||||
options.port = options.host.split(':')[1];
|
||||
}
|
||||
|
||||
if (!options.port) {
|
||||
options.port = 443;
|
||||
}
|
||||
|
||||
agent = new Agent(options);
|
||||
options.agent = agent;
|
||||
|
||||
return https.request(options, cb);
|
||||
};
|
||||
|
||||
exports.get = function(options, cb) {
|
||||
var req = exports.request(options, cb);
|
||||
|
||||
req.end();
|
||||
|
||||
return req;
|
||||
};
|
||||
59
nodered/rootfs/data/node_modules/socks5-https-client/lib/Agent.js
generated
vendored
Normal file
59
nodered/rootfs/data/node_modules/socks5-https-client/lib/Agent.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @overview
|
||||
* @author Matthew Caruana Galizia <m@m.cg>
|
||||
* @license MIT
|
||||
* @copyright Copyright (c) 2013, Matthew Caruana Galizia
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/*jshint node:true*/
|
||||
|
||||
var tls = require('tls');
|
||||
var https = require('https');
|
||||
var inherits = require('util').inherits;
|
||||
|
||||
var socksClient = require('socks5-client');
|
||||
|
||||
function createConnection(options) {
|
||||
var socksSocket, onProxied;
|
||||
|
||||
socksSocket = socksClient.createConnection(options);
|
||||
|
||||
onProxied = socksSocket.onProxied;
|
||||
socksSocket.onProxied = function() {
|
||||
options.socket = socksSocket.socket;
|
||||
|
||||
if (options.hostname) {
|
||||
options.servername = options.hostname;
|
||||
} else if (options.host) {
|
||||
options.servername = options.host.split(':')[0];
|
||||
}
|
||||
|
||||
socksSocket.socket = tls.connect(options, function() {
|
||||
|
||||
// Set the 'authorized flag for clients that check it.
|
||||
socksSocket.authorized = socksSocket.socket.authorized;
|
||||
onProxied.call(socksSocket);
|
||||
});
|
||||
|
||||
socksSocket.socket.on('error', function(err) {
|
||||
socksSocket.emit('error', err);
|
||||
});
|
||||
};
|
||||
|
||||
return socksSocket;
|
||||
}
|
||||
|
||||
function Agent(options) {
|
||||
https.Agent.call(this, options);
|
||||
|
||||
this.socksHost = options.socksHost || 'localhost';
|
||||
this.socksPort = options.socksPort || 1080;
|
||||
|
||||
this.createConnection = createConnection;
|
||||
}
|
||||
|
||||
inherits(Agent, https.Agent);
|
||||
|
||||
module.exports = Agent;
|
||||
72
nodered/rootfs/data/node_modules/socks5-https-client/package.json
generated
vendored
Normal file
72
nodered/rootfs/data/node_modules/socks5-https-client/package.json
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"_from": "socks5-https-client@1.2.1",
|
||||
"_id": "socks5-https-client@1.2.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-FbZ/X/2Xq3DAMhuRA4bnN0jy1QxaPTVPLFvyv6CEj0QDKSTdWp9yRxo1JhqXmWKhPQeJyUMajHJB2UjT43pFcw==",
|
||||
"_location": "/socks5-https-client",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "socks5-https-client@1.2.1",
|
||||
"name": "socks5-https-client",
|
||||
"escapedName": "socks5-https-client",
|
||||
"rawSpec": "1.2.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.2.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/node-red-contrib-telegrambot"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/socks5-https-client/-/socks5-https-client-1.2.1.tgz",
|
||||
"_shasum": "c8d4a000e39cdc1651d90245af04a735d75d8b09",
|
||||
"_spec": "socks5-https-client@1.2.1",
|
||||
"_where": "/data/node_modules/node-red-contrib-telegrambot",
|
||||
"author": {
|
||||
"name": "Matthew Caruana Galizia",
|
||||
"email": "mattcg@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mattcg/socks5-https-client/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"socks5-client": "~1.2.3"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "SOCKS v5 HTTPS client.",
|
||||
"devDependencies": {
|
||||
"mocha": "~3.1.2",
|
||||
"node-socks": "~0.1.0",
|
||||
"request": "~2.72.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.4.0"
|
||||
},
|
||||
"homepage": "https://github.com/mattcg/socks5-https-client",
|
||||
"implements": [
|
||||
"CommonJS/Modules/1.0"
|
||||
],
|
||||
"keywords": [
|
||||
"socks5",
|
||||
"socksv5",
|
||||
"socks",
|
||||
"v5",
|
||||
"https",
|
||||
"ssl",
|
||||
"tls",
|
||||
"tor",
|
||||
"client"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "socks5-https-client",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mattcg/socks5-https-client.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "1.2.1"
|
||||
}
|
||||
106
nodered/rootfs/data/node_modules/socks5-https-client/test/index.js
generated
vendored
Normal file
106
nodered/rootfs/data/node_modules/socks5-https-client/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @overview
|
||||
* @author Matthew Caruana Galizia <m@m.cg>
|
||||
* @copyright Copyright (c) 2013, Matthew Caruana Galizia
|
||||
* @license MIT
|
||||
* @preserve
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/*jshint node:true*/
|
||||
/*global test, suite, setup*/
|
||||
|
||||
var assert = require('assert');
|
||||
var net = require('net');
|
||||
var request = require('request');
|
||||
var socks = require('node-socks/socks.js');
|
||||
var https = require('../');
|
||||
var Agent = require('../lib/Agent');
|
||||
|
||||
suite('socks5-https-client tests', function() {
|
||||
var server;
|
||||
|
||||
this.timeout(5000);
|
||||
|
||||
suiteSetup(function(done) {
|
||||
server = socks.createServer(function(socket, port, address, proxyReady) {
|
||||
var proxy;
|
||||
|
||||
proxy = net.createConnection(port, address, proxyReady);
|
||||
|
||||
proxy.on('data', function(data) {
|
||||
socket.write(data);
|
||||
});
|
||||
|
||||
socket.on('data', function(data) {
|
||||
proxy.write(data);
|
||||
});
|
||||
|
||||
proxy.on('close', function() {
|
||||
socket.end();
|
||||
});
|
||||
|
||||
socket.on('close', function() {
|
||||
proxy.removeAllListeners('data');
|
||||
proxy.end();
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(1080, 'localhost', 511, function() {
|
||||
done();
|
||||
});
|
||||
|
||||
server.on('error', function(err) {
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
|
||||
test('simple request', function(done) {
|
||||
var req;
|
||||
|
||||
req = https.request('https://en.wikipedia.org/wiki/Main_Page', function(res, err) {
|
||||
var data = '';
|
||||
|
||||
assert.ifError(err);
|
||||
assert.equal(res.statusCode, 200);
|
||||
|
||||
res.setEncoding('utf8');
|
||||
res.on('readable', function() {
|
||||
data += res.read();
|
||||
});
|
||||
|
||||
res.on('end', function() {
|
||||
assert(-1 !== data.indexOf('<html'));
|
||||
assert(-1 !== data.indexOf('</html>'));
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', function(err) {
|
||||
assert.fail(err);
|
||||
});
|
||||
|
||||
// GET request, so end without sending any data.
|
||||
req.end();
|
||||
});
|
||||
|
||||
test('using request', function(done) {
|
||||
var req;
|
||||
|
||||
request({
|
||||
url: 'https://encrypted.google.com/',
|
||||
agentClass: Agent,
|
||||
strictSSL: true
|
||||
}, function(err, res, data) {
|
||||
assert.ifError(err);
|
||||
assert.equal(res.statusCode, 200);
|
||||
|
||||
assert(-1 !== data.indexOf('<html'));
|
||||
assert(-1 !== data.indexOf('</html>'));
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user