push the uni-demo project
This commit is contained in:
152
uni-demo/node_modules/socks-proxy-agent/README.md
generated
vendored
Normal file
152
uni-demo/node_modules/socks-proxy-agent/README.md
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
socks-proxy-agent
|
||||
================
|
||||
### A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
|
||||
[](https://github.com/TooTallNate/node-socks-proxy-agent/actions?workflow=Node+CI)
|
||||
|
||||
This module provides an `http.Agent` implementation that connects to a
|
||||
specified SOCKS proxy server, and can be used with the built-in `http`
|
||||
and `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
|
||||
--------
|
||||
|
||||
#### TypeScript example
|
||||
|
||||
```ts
|
||||
import https from 'https';
|
||||
import { SocksProxyAgent } from 'socks-proxy-agent';
|
||||
|
||||
const info = {
|
||||
hostname: 'br41.nordvpn.com',
|
||||
userId: 'your-name@gmail.com',
|
||||
password: 'abcdef12345124'
|
||||
};
|
||||
const agent = new SocksProxyAgent(info);
|
||||
|
||||
https.get('https://ipinfo.io', { agent }, (res) => {
|
||||
console.log(res.headers);
|
||||
res.pipe(process.stdout);
|
||||
});
|
||||
```
|
||||
|
||||
#### `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:1080';
|
||||
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:1080';
|
||||
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
|
||||
var agent = new SocksProxyAgent(proxy);
|
||||
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:1080';
|
||||
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.
|
||||
38
uni-demo/node_modules/socks-proxy-agent/dist/index.d.ts
generated
vendored
Normal file
38
uni-demo/node_modules/socks-proxy-agent/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/// <reference types="node" />
|
||||
import { SocksProxy } from 'socks';
|
||||
import { Agent, ClientRequest, RequestOptions } from 'agent-base';
|
||||
import { AgentOptions } from 'agent-base';
|
||||
import { Url } from 'url';
|
||||
import net from 'net';
|
||||
import tls from 'tls';
|
||||
interface BaseSocksProxyAgentOptions {
|
||||
/**
|
||||
* hostname is preferred over host
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
host?: string | null;
|
||||
port?: string | number | null;
|
||||
username?: string | null;
|
||||
tls?: tls.ConnectionOptions | null;
|
||||
}
|
||||
interface SocksProxyAgentOptionsExtra {
|
||||
timeout?: number;
|
||||
}
|
||||
export interface SocksProxyAgentOptions extends AgentOptions, BaseSocksProxyAgentOptions, Partial<Omit<Url & SocksProxy, keyof BaseSocksProxyAgentOptions>> {
|
||||
}
|
||||
export declare class SocksProxyAgent extends Agent {
|
||||
private readonly shouldLookup;
|
||||
private readonly proxy;
|
||||
private readonly tlsConnectionOptions;
|
||||
timeout: number | null;
|
||||
constructor(input: string | SocksProxyAgentOptions, options?: SocksProxyAgentOptionsExtra);
|
||||
/**
|
||||
* Initiates a SOCKS connection to the specified SOCKS proxy server,
|
||||
* which in turn connects to the specified remote host and port.
|
||||
*
|
||||
* @api protected
|
||||
*/
|
||||
callback(req: ClientRequest, opts: RequestOptions): Promise<net.Socket>;
|
||||
}
|
||||
export {};
|
||||
197
uni-demo/node_modules/socks-proxy-agent/dist/index.js
generated
vendored
Normal file
197
uni-demo/node_modules/socks-proxy-agent/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SocksProxyAgent = void 0;
|
||||
const socks_1 = require("socks");
|
||||
const agent_base_1 = require("agent-base");
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const dns_1 = __importDefault(require("dns"));
|
||||
const tls_1 = __importDefault(require("tls"));
|
||||
const debug = (0, debug_1.default)('socks-proxy-agent');
|
||||
function parseSocksProxy(opts) {
|
||||
var _a;
|
||||
let port = 0;
|
||||
let lookup = false;
|
||||
let type = 5;
|
||||
const host = opts.hostname || opts.host;
|
||||
if (host == null) {
|
||||
throw new TypeError('No "hostname"');
|
||||
}
|
||||
if (typeof opts.port === 'number') {
|
||||
port = opts.port;
|
||||
}
|
||||
else if (typeof opts.port === 'string') {
|
||||
port = parseInt(opts.port, 10);
|
||||
}
|
||||
// From RFC 1928, Section 3: https://tools.ietf.org/html/rfc1928#section-3
|
||||
// "The SOCKS service is conventionally located on TCP port 1080"
|
||||
if (port == null) {
|
||||
port = 1080;
|
||||
}
|
||||
// figure out if we want socks v4 or v5, based on the "protocol" used.
|
||||
// Defaults to 5.
|
||||
if (opts.protocol != null) {
|
||||
switch (opts.protocol.replace(':', '')) {
|
||||
case 'socks4':
|
||||
lookup = true;
|
||||
// pass through
|
||||
case 'socks4a':
|
||||
type = 4;
|
||||
break;
|
||||
case 'socks5':
|
||||
lookup = true;
|
||||
// pass through
|
||||
case 'socks': // no version specified, default to 5h
|
||||
case 'socks5h':
|
||||
type = 5;
|
||||
break;
|
||||
default:
|
||||
throw new TypeError(`A "socks" protocol must be specified! Got: ${String(opts.protocol)}`);
|
||||
}
|
||||
}
|
||||
if (typeof opts.type !== 'undefined') {
|
||||
if (opts.type === 4 || opts.type === 5) {
|
||||
type = opts.type;
|
||||
}
|
||||
else {
|
||||
throw new TypeError(`"type" must be 4 or 5, got: ${String(opts.type)}`);
|
||||
}
|
||||
}
|
||||
const proxy = {
|
||||
host,
|
||||
port,
|
||||
type
|
||||
};
|
||||
let userId = (_a = opts.userId) !== null && _a !== void 0 ? _a : opts.username;
|
||||
let password = opts.password;
|
||||
if (opts.auth != null) {
|
||||
const auth = opts.auth.split(':');
|
||||
userId = auth[0];
|
||||
password = auth[1];
|
||||
}
|
||||
if (userId != null) {
|
||||
Object.defineProperty(proxy, 'userId', {
|
||||
value: userId,
|
||||
enumerable: false
|
||||
});
|
||||
}
|
||||
if (password != null) {
|
||||
Object.defineProperty(proxy, 'password', {
|
||||
value: password,
|
||||
enumerable: false
|
||||
});
|
||||
}
|
||||
return { lookup, proxy };
|
||||
}
|
||||
const normalizeProxyOptions = (input) => {
|
||||
let proxyOptions;
|
||||
if (typeof input === 'string') {
|
||||
proxyOptions = new URL(input);
|
||||
}
|
||||
else {
|
||||
proxyOptions = input;
|
||||
}
|
||||
if (proxyOptions == null) {
|
||||
throw new TypeError('a SOCKS proxy server `hostname` and `port` must be specified!');
|
||||
}
|
||||
return proxyOptions;
|
||||
};
|
||||
class SocksProxyAgent extends agent_base_1.Agent {
|
||||
constructor(input, options) {
|
||||
var _a;
|
||||
const proxyOptions = normalizeProxyOptions(input);
|
||||
super(proxyOptions);
|
||||
const parsedProxy = parseSocksProxy(proxyOptions);
|
||||
this.shouldLookup = parsedProxy.lookup;
|
||||
this.proxy = parsedProxy.proxy;
|
||||
this.tlsConnectionOptions = proxyOptions.tls != null ? proxyOptions.tls : {};
|
||||
this.timeout = (_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : null;
|
||||
}
|
||||
/**
|
||||
* Initiates a SOCKS connection to the specified SOCKS proxy server,
|
||||
* which in turn connects to the specified remote host and port.
|
||||
*
|
||||
* @api protected
|
||||
*/
|
||||
callback(req, opts) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const { shouldLookup, proxy, timeout } = this;
|
||||
let { host, port, lookup: lookupCallback } = opts;
|
||||
if (host == null) {
|
||||
throw new Error('No `host` defined!');
|
||||
}
|
||||
if (shouldLookup) {
|
||||
// Client-side DNS resolution for "4" and "5" socks proxy versions.
|
||||
host = yield new Promise((resolve, reject) => {
|
||||
// Use the request's custom lookup, if one was configured:
|
||||
const lookupFn = lookupCallback !== null && lookupCallback !== void 0 ? lookupCallback : dns_1.default.lookup;
|
||||
lookupFn(host, {}, (err, res) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
resolve(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
const socksOpts = {
|
||||
proxy,
|
||||
destination: { host, port },
|
||||
command: 'connect',
|
||||
timeout: timeout !== null && timeout !== void 0 ? timeout : undefined
|
||||
};
|
||||
const cleanup = (tlsSocket) => {
|
||||
req.destroy();
|
||||
socket.destroy();
|
||||
if (tlsSocket)
|
||||
tlsSocket.destroy();
|
||||
};
|
||||
debug('Creating socks proxy connection: %o', socksOpts);
|
||||
const { socket } = yield socks_1.SocksClient.createConnection(socksOpts);
|
||||
debug('Successfully created socks proxy connection');
|
||||
if (timeout !== null) {
|
||||
socket.setTimeout(timeout);
|
||||
socket.on('timeout', () => cleanup());
|
||||
}
|
||||
if (opts.secureEndpoint) {
|
||||
// The proxy is connecting to a TLS server, so upgrade
|
||||
// this socket connection to a TLS connection.
|
||||
debug('Upgrading socket connection to TLS');
|
||||
const servername = (_a = opts.servername) !== null && _a !== void 0 ? _a : opts.host;
|
||||
const tlsSocket = tls_1.default.connect(Object.assign(Object.assign(Object.assign({}, omit(opts, 'host', 'hostname', 'path', 'port')), { socket,
|
||||
servername }), this.tlsConnectionOptions));
|
||||
tlsSocket.once('error', (error) => {
|
||||
debug('socket TLS error', error.message);
|
||||
cleanup(tlsSocket);
|
||||
});
|
||||
return tlsSocket;
|
||||
}
|
||||
return socket;
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.SocksProxyAgent = SocksProxyAgent;
|
||||
function omit(obj, ...keys) {
|
||||
const ret = {};
|
||||
let key;
|
||||
for (key in obj) {
|
||||
if (!keys.includes(key)) {
|
||||
ret[key] = obj[key];
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
uni-demo/node_modules/socks-proxy-agent/dist/index.js.map
generated
vendored
Normal file
1
uni-demo/node_modules/socks-proxy-agent/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
181
uni-demo/node_modules/socks-proxy-agent/package.json
generated
vendored
Normal file
181
uni-demo/node_modules/socks-proxy-agent/package.json
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
{
|
||||
"name": "socks-proxy-agent",
|
||||
"description": "A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS",
|
||||
"homepage": "https://github.com/TooTallNate/node-socks-proxy-agent#readme",
|
||||
"version": "6.2.1",
|
||||
"main": "dist/index.js",
|
||||
"author": {
|
||||
"email": "nathan@tootallnate.net",
|
||||
"name": "Nathan Rajlich",
|
||||
"url": "http://n8.io/"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Kiko Beats",
|
||||
"email": "josefrancisco.verdu@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Josh Glazebrook",
|
||||
"email": "josh@joshglazebrook.com"
|
||||
},
|
||||
{
|
||||
"name": "talmobi",
|
||||
"email": "talmobi@users.noreply.github.com"
|
||||
},
|
||||
{
|
||||
"name": "Indospace.io",
|
||||
"email": "justin@indospace.io"
|
||||
},
|
||||
{
|
||||
"name": "Kilian von Pflugk",
|
||||
"email": "github@jumoog.io"
|
||||
},
|
||||
{
|
||||
"name": "Kyle",
|
||||
"email": "admin@hk1229.cn"
|
||||
},
|
||||
{
|
||||
"name": "Matheus Fernandes",
|
||||
"email": "matheus.frndes@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Ricky Miller",
|
||||
"email": "richardkazuomiller@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Shantanu Sharma",
|
||||
"email": "shantanu34@outlook.com"
|
||||
},
|
||||
{
|
||||
"name": "Tim Perry",
|
||||
"email": "pimterry@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Vadim Baryshev",
|
||||
"email": "vadimbaryshev@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "jigu",
|
||||
"email": "luo1257857309@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Alba Mendez",
|
||||
"email": "me@jmendeth.com"
|
||||
},
|
||||
{
|
||||
"name": "Дмитрий Гуденков",
|
||||
"email": "Dimangud@rambler.ru"
|
||||
},
|
||||
{
|
||||
"name": "Andrei Bitca",
|
||||
"email": "63638922+andrei-bitca-dc@users.noreply.github.com"
|
||||
},
|
||||
{
|
||||
"name": "Andrew Casey",
|
||||
"email": "amcasey@users.noreply.github.com"
|
||||
},
|
||||
{
|
||||
"name": "Brandon Ros",
|
||||
"email": "brandonros1@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Dang Duy Thanh",
|
||||
"email": "thanhdd.it@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Dimitar Nestorov",
|
||||
"email": "8790386+dimitarnestorov@users.noreply.github.com"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/TooTallNate/node-socks-proxy-agent.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/TooTallNate/node-socks-proxy-agent/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"agent",
|
||||
"http",
|
||||
"https",
|
||||
"proxy",
|
||||
"socks",
|
||||
"socks4",
|
||||
"socks4a",
|
||||
"socks5",
|
||||
"socks5h"
|
||||
],
|
||||
"dependencies": {
|
||||
"agent-base": "^6.0.2",
|
||||
"debug": "^4.3.3",
|
||||
"socks": "^2.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "latest",
|
||||
"@commitlint/config-conventional": "latest",
|
||||
"@types/debug": "latest",
|
||||
"@types/node": "latest",
|
||||
"cacheable-lookup": "^6.0.4",
|
||||
"conventional-github-releaser": "latest",
|
||||
"dns2": "latest",
|
||||
"finepack": "latest",
|
||||
"git-authors-cli": "latest",
|
||||
"mocha": "9",
|
||||
"nano-staged": "latest",
|
||||
"npm-check-updates": "latest",
|
||||
"prettier-standard": "latest",
|
||||
"raw-body": "latest",
|
||||
"rimraf": "latest",
|
||||
"simple-git-hooks": "latest",
|
||||
"socksv5": "github:TooTallNate/socksv5#fix/dstSock-close-event",
|
||||
"standard": "latest",
|
||||
"standard-markdown": "latest",
|
||||
"standard-version": "latest",
|
||||
"ts-standard": "latest",
|
||||
"typescript": "latest"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"clean": "rimraf node_modules",
|
||||
"contributors": "(git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
|
||||
"lint": "ts-standard",
|
||||
"postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
|
||||
"prebuild": "rimraf dist",
|
||||
"prepublishOnly": "npm run build",
|
||||
"prerelease": "npm run update:check && npm run contributors",
|
||||
"release": "standard-version -a",
|
||||
"release:github": "conventional-github-releaser -p angular",
|
||||
"release:tags": "git push --follow-tags origin HEAD:master",
|
||||
"test": "mocha --reporter spec",
|
||||
"update": "ncu -u",
|
||||
"update:check": "ncu -- --error-level 2"
|
||||
},
|
||||
"license": "MIT",
|
||||
"commitlint": {
|
||||
"extends": [
|
||||
"@commitlint/config-conventional"
|
||||
]
|
||||
},
|
||||
"nano-staged": {
|
||||
"*.js": [
|
||||
"prettier-standard"
|
||||
],
|
||||
"*.md": [
|
||||
"standard-markdown"
|
||||
],
|
||||
"package.json": [
|
||||
"finepack"
|
||||
]
|
||||
},
|
||||
"simple-git-hooks": {
|
||||
"commit-msg": "npx commitlint --edit",
|
||||
"pre-commit": "npx nano-staged"
|
||||
},
|
||||
"typings": "dist/index.d.ts"
|
||||
}
|
||||
Reference in New Issue
Block a user