This commit is contained in:
2025-08-18 23:06:34 +08:00
parent 0bc04fb659
commit ed18af0cad
1926 changed files with 275098 additions and 0 deletions

22
package/node_modules/socks-proxy-agent/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
(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.

185
package/node_modules/socks-proxy-agent/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,185 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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 = __importStar(require("dns"));
const tls = __importStar(require("tls"));
const url_1 = require("url");
const debug = (0, debug_1.default)('socks-proxy-agent');
function parseSocksURL(url) {
let lookup = false;
let type = 5;
const host = url.hostname;
// From RFC 1928, Section 3: https://tools.ietf.org/html/rfc1928#section-3
// "The SOCKS service is conventionally located on TCP port 1080"
const port = parseInt(url.port, 10) || 1080;
// figure out if we want socks v4 or v5, based on the "protocol" used.
// Defaults to 5.
switch (url.protocol.replace(':', '')) {
case 'socks4':
lookup = true;
type = 4;
break;
// pass through
case 'socks4a':
type = 4;
break;
case 'socks5':
lookup = true;
type = 5;
break;
// pass through
case 'socks': // no version specified, default to 5h
type = 5;
break;
case 'socks5h':
type = 5;
break;
default:
throw new TypeError(`A "socks" protocol must be specified! Got: ${String(url.protocol)}`);
}
const proxy = {
host,
port,
type,
};
if (url.username) {
Object.defineProperty(proxy, 'userId', {
value: decodeURIComponent(url.username),
enumerable: false,
});
}
if (url.password != null) {
Object.defineProperty(proxy, 'password', {
value: decodeURIComponent(url.password),
enumerable: false,
});
}
return { lookup, proxy };
}
class SocksProxyAgent extends agent_base_1.Agent {
constructor(uri, opts) {
super(opts);
const url = typeof uri === 'string' ? new url_1.URL(uri) : uri;
const { proxy, lookup } = parseSocksURL(url);
this.shouldLookup = lookup;
this.proxy = proxy;
this.timeout = opts?.timeout ?? null;
this.socketOptions = opts?.socketOptions ?? null;
}
/**
* Initiates a SOCKS connection to the specified SOCKS proxy server,
* which in turn connects to the specified remote host and port.
*/
async connect(req, opts) {
const { shouldLookup, proxy, timeout } = this;
if (!opts.host) {
throw new Error('No `host` defined!');
}
let { host } = opts;
const { port, lookup: lookupFn = dns.lookup } = opts;
if (shouldLookup) {
// Client-side DNS resolution for "4" and "5" socks proxy versions.
host = await new Promise((resolve, reject) => {
// Use the request's custom lookup, if one was configured:
lookupFn(host, {}, (err, res) => {
if (err) {
reject(err);
}
else {
resolve(res);
}
});
});
}
const socksOpts = {
proxy,
destination: {
host,
port: typeof port === 'number' ? port : parseInt(port, 10),
},
command: 'connect',
timeout: timeout ?? undefined,
// @ts-expect-error the type supplied by socks for socket_options is wider
// than necessary since socks will always override the host and port
socket_options: this.socketOptions ?? undefined,
};
const cleanup = (tlsSocket) => {
req.destroy();
socket.destroy();
if (tlsSocket)
tlsSocket.destroy();
};
debug('Creating socks proxy connection: %o', socksOpts);
const { socket } = await 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 = opts.servername || opts.host;
const tlsSocket = tls.connect({
...omit(opts, 'host', 'path', 'port'),
socket,
servername,
});
tlsSocket.once('error', (error) => {
debug('Socket TLS error', error.message);
cleanup(tlsSocket);
});
return tlsSocket;
}
return socket;
}
}
SocksProxyAgent.protocols = [
'socks',
'socks4',
'socks4a',
'socks5',
'socks5h',
];
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

142
package/node_modules/socks-proxy-agent/package.json generated vendored Normal file
View File

@@ -0,0 +1,142 @@
{
"name": "socks-proxy-agent",
"version": "8.0.4",
"description": "A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"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": "https://github.com/TooTallNate/proxy-agents.git",
"directory": "packages/socks-proxy-agent"
},
"keywords": [
"agent",
"http",
"https",
"proxy",
"socks",
"socks4",
"socks4a",
"socks5",
"socks5h"
],
"dependencies": {
"agent-base": "^7.1.1",
"debug": "^4.3.4",
"socks": "^2.8.3"
},
"devDependencies": {
"@types/async-retry": "^1.4.5",
"@types/debug": "^4.1.7",
"@types/dns2": "^2.0.3",
"@types/jest": "^29.5.1",
"@types/node": "^14.18.45",
"async-listen": "^3.0.0",
"async-retry": "^1.3.3",
"cacheable-lookup": "^6.1.0",
"dns2": "^2.1.0",
"jest": "^29.5.0",
"socksv5": "github:TooTallNate/socksv5#fix/dstSock-close-event",
"ts-jest": "^29.1.0",
"typescript": "^5.0.4",
"proxy": "2.2.0",
"tsconfig": "0.0.0"
},
"engines": {
"node": ">= 14"
},
"license": "MIT",
"scripts": {
"build": "tsc",
"test": "jest --env node --verbose --bail test/test.ts",
"test-e2e": "jest --env node --verbose --bail test/e2e.test.ts",
"lint": "eslint . --ext .ts",
"pack": "node ../../scripts/pack.mjs"
}
}