$
This commit is contained in:
11
node_modules/socks/.eslintrc.cjs
generated
vendored
Normal file
11
node_modules/socks/.eslintrc.cjs
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: [
|
||||
'@typescript-eslint',
|
||||
],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
],
|
||||
};
|
7
node_modules/socks/.prettierrc.yaml
generated
vendored
Normal file
7
node_modules/socks/.prettierrc.yaml
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
parser: typescript
|
||||
printWidth: 80
|
||||
tabWidth: 2
|
||||
singleQuote: true
|
||||
trailingComma: all
|
||||
arrowParens: always
|
||||
bracketSpacing: false
|
20
node_modules/socks/LICENSE
generated
vendored
Normal file
20
node_modules/socks/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Josh Glazebrook
|
||||
|
||||
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.
|
686
node_modules/socks/README.md
generated
vendored
Normal file
686
node_modules/socks/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
793
node_modules/socks/build/client/socksclient.js
generated
vendored
Normal file
793
node_modules/socks/build/client/socksclient.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/socks/build/client/socksclient.js.map
generated
vendored
Normal file
1
node_modules/socks/build/client/socksclient.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
114
node_modules/socks/build/common/constants.js
generated
vendored
Normal file
114
node_modules/socks/build/common/constants.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SOCKS5_NO_ACCEPTABLE_AUTH = exports.SOCKS5_CUSTOM_AUTH_END = exports.SOCKS5_CUSTOM_AUTH_START = exports.SOCKS_INCOMING_PACKET_SIZES = exports.SocksClientState = exports.Socks5Response = exports.Socks5HostType = exports.Socks5Auth = exports.Socks4Response = exports.SocksCommand = exports.ERRORS = exports.DEFAULT_TIMEOUT = void 0;
|
||||
const DEFAULT_TIMEOUT = 30000;
|
||||
exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
|
||||
// prettier-ignore
|
||||
const ERRORS = {
|
||||
InvalidSocksCommand: 'An invalid SOCKS command was provided. Valid options are connect, bind, and associate.',
|
||||
InvalidSocksCommandForOperation: 'An invalid SOCKS command was provided. Only a subset of commands are supported for this operation.',
|
||||
InvalidSocksCommandChain: 'An invalid SOCKS command was provided. Chaining currently only supports the connect command.',
|
||||
InvalidSocksClientOptionsDestination: 'An invalid destination host was provided.',
|
||||
InvalidSocksClientOptionsExistingSocket: 'An invalid existing socket was provided. This should be an instance of stream.Duplex.',
|
||||
InvalidSocksClientOptionsProxy: 'Invalid SOCKS proxy details were provided.',
|
||||
InvalidSocksClientOptionsTimeout: 'An invalid timeout value was provided. Please enter a value above 0 (in ms).',
|
||||
InvalidSocksClientOptionsProxiesLength: 'At least two socks proxies must be provided for chaining.',
|
||||
InvalidSocksClientOptionsCustomAuthRange: 'Custom auth must be a value between 0x80 and 0xFE.',
|
||||
InvalidSocksClientOptionsCustomAuthOptions: 'When a custom_auth_method is provided, custom_auth_request_handler, custom_auth_response_size, and custom_auth_response_handler must also be provided and valid.',
|
||||
NegotiationError: 'Negotiation error',
|
||||
SocketClosed: 'Socket closed',
|
||||
ProxyConnectionTimedOut: 'Proxy connection timed out',
|
||||
InternalError: 'SocksClient internal error (this should not happen)',
|
||||
InvalidSocks4HandshakeResponse: 'Received invalid Socks4 handshake response',
|
||||
Socks4ProxyRejectedConnection: 'Socks4 Proxy rejected connection',
|
||||
InvalidSocks4IncomingConnectionResponse: 'Socks4 invalid incoming connection response',
|
||||
Socks4ProxyRejectedIncomingBoundConnection: 'Socks4 Proxy rejected incoming bound connection',
|
||||
InvalidSocks5InitialHandshakeResponse: 'Received invalid Socks5 initial handshake response',
|
||||
InvalidSocks5IntiailHandshakeSocksVersion: 'Received invalid Socks5 initial handshake (invalid socks version)',
|
||||
InvalidSocks5InitialHandshakeNoAcceptedAuthType: 'Received invalid Socks5 initial handshake (no accepted authentication type)',
|
||||
InvalidSocks5InitialHandshakeUnknownAuthType: 'Received invalid Socks5 initial handshake (unknown authentication type)',
|
||||
Socks5AuthenticationFailed: 'Socks5 Authentication failed',
|
||||
InvalidSocks5FinalHandshake: 'Received invalid Socks5 final handshake response',
|
||||
InvalidSocks5FinalHandshakeRejected: 'Socks5 proxy rejected connection',
|
||||
InvalidSocks5IncomingConnectionResponse: 'Received invalid Socks5 incoming connection response',
|
||||
Socks5ProxyRejectedIncomingBoundConnection: 'Socks5 Proxy rejected incoming bound connection',
|
||||
};
|
||||
exports.ERRORS = ERRORS;
|
||||
const SOCKS_INCOMING_PACKET_SIZES = {
|
||||
Socks5InitialHandshakeResponse: 2,
|
||||
Socks5UserPassAuthenticationResponse: 2,
|
||||
// Command response + incoming connection (bind)
|
||||
Socks5ResponseHeader: 5,
|
||||
Socks5ResponseIPv4: 10,
|
||||
Socks5ResponseIPv6: 22,
|
||||
Socks5ResponseHostname: (hostNameLength) => hostNameLength + 7,
|
||||
// Command response + incoming connection (bind)
|
||||
Socks4Response: 8, // 2 header + 2 port + 4 ip
|
||||
};
|
||||
exports.SOCKS_INCOMING_PACKET_SIZES = SOCKS_INCOMING_PACKET_SIZES;
|
||||
var SocksCommand;
|
||||
(function (SocksCommand) {
|
||||
SocksCommand[SocksCommand["connect"] = 1] = "connect";
|
||||
SocksCommand[SocksCommand["bind"] = 2] = "bind";
|
||||
SocksCommand[SocksCommand["associate"] = 3] = "associate";
|
||||
})(SocksCommand || (SocksCommand = {}));
|
||||
exports.SocksCommand = SocksCommand;
|
||||
var Socks4Response;
|
||||
(function (Socks4Response) {
|
||||
Socks4Response[Socks4Response["Granted"] = 90] = "Granted";
|
||||
Socks4Response[Socks4Response["Failed"] = 91] = "Failed";
|
||||
Socks4Response[Socks4Response["Rejected"] = 92] = "Rejected";
|
||||
Socks4Response[Socks4Response["RejectedIdent"] = 93] = "RejectedIdent";
|
||||
})(Socks4Response || (Socks4Response = {}));
|
||||
exports.Socks4Response = Socks4Response;
|
||||
var Socks5Auth;
|
||||
(function (Socks5Auth) {
|
||||
Socks5Auth[Socks5Auth["NoAuth"] = 0] = "NoAuth";
|
||||
Socks5Auth[Socks5Auth["GSSApi"] = 1] = "GSSApi";
|
||||
Socks5Auth[Socks5Auth["UserPass"] = 2] = "UserPass";
|
||||
})(Socks5Auth || (Socks5Auth = {}));
|
||||
exports.Socks5Auth = Socks5Auth;
|
||||
const SOCKS5_CUSTOM_AUTH_START = 0x80;
|
||||
exports.SOCKS5_CUSTOM_AUTH_START = SOCKS5_CUSTOM_AUTH_START;
|
||||
const SOCKS5_CUSTOM_AUTH_END = 0xfe;
|
||||
exports.SOCKS5_CUSTOM_AUTH_END = SOCKS5_CUSTOM_AUTH_END;
|
||||
const SOCKS5_NO_ACCEPTABLE_AUTH = 0xff;
|
||||
exports.SOCKS5_NO_ACCEPTABLE_AUTH = SOCKS5_NO_ACCEPTABLE_AUTH;
|
||||
var Socks5Response;
|
||||
(function (Socks5Response) {
|
||||
Socks5Response[Socks5Response["Granted"] = 0] = "Granted";
|
||||
Socks5Response[Socks5Response["Failure"] = 1] = "Failure";
|
||||
Socks5Response[Socks5Response["NotAllowed"] = 2] = "NotAllowed";
|
||||
Socks5Response[Socks5Response["NetworkUnreachable"] = 3] = "NetworkUnreachable";
|
||||
Socks5Response[Socks5Response["HostUnreachable"] = 4] = "HostUnreachable";
|
||||
Socks5Response[Socks5Response["ConnectionRefused"] = 5] = "ConnectionRefused";
|
||||
Socks5Response[Socks5Response["TTLExpired"] = 6] = "TTLExpired";
|
||||
Socks5Response[Socks5Response["CommandNotSupported"] = 7] = "CommandNotSupported";
|
||||
Socks5Response[Socks5Response["AddressNotSupported"] = 8] = "AddressNotSupported";
|
||||
})(Socks5Response || (Socks5Response = {}));
|
||||
exports.Socks5Response = Socks5Response;
|
||||
var Socks5HostType;
|
||||
(function (Socks5HostType) {
|
||||
Socks5HostType[Socks5HostType["IPv4"] = 1] = "IPv4";
|
||||
Socks5HostType[Socks5HostType["Hostname"] = 3] = "Hostname";
|
||||
Socks5HostType[Socks5HostType["IPv6"] = 4] = "IPv6";
|
||||
})(Socks5HostType || (Socks5HostType = {}));
|
||||
exports.Socks5HostType = Socks5HostType;
|
||||
var SocksClientState;
|
||||
(function (SocksClientState) {
|
||||
SocksClientState[SocksClientState["Created"] = 0] = "Created";
|
||||
SocksClientState[SocksClientState["Connecting"] = 1] = "Connecting";
|
||||
SocksClientState[SocksClientState["Connected"] = 2] = "Connected";
|
||||
SocksClientState[SocksClientState["SentInitialHandshake"] = 3] = "SentInitialHandshake";
|
||||
SocksClientState[SocksClientState["ReceivedInitialHandshakeResponse"] = 4] = "ReceivedInitialHandshakeResponse";
|
||||
SocksClientState[SocksClientState["SentAuthentication"] = 5] = "SentAuthentication";
|
||||
SocksClientState[SocksClientState["ReceivedAuthenticationResponse"] = 6] = "ReceivedAuthenticationResponse";
|
||||
SocksClientState[SocksClientState["SentFinalHandshake"] = 7] = "SentFinalHandshake";
|
||||
SocksClientState[SocksClientState["ReceivedFinalResponse"] = 8] = "ReceivedFinalResponse";
|
||||
SocksClientState[SocksClientState["BoundWaitingForConnection"] = 9] = "BoundWaitingForConnection";
|
||||
SocksClientState[SocksClientState["Established"] = 10] = "Established";
|
||||
SocksClientState[SocksClientState["Disconnected"] = 11] = "Disconnected";
|
||||
SocksClientState[SocksClientState["Error"] = 99] = "Error";
|
||||
})(SocksClientState || (SocksClientState = {}));
|
||||
exports.SocksClientState = SocksClientState;
|
||||
//# sourceMappingURL=constants.js.map
|
1
node_modules/socks/build/common/constants.js.map
generated
vendored
Normal file
1
node_modules/socks/build/common/constants.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
128
node_modules/socks/build/common/helpers.js
generated
vendored
Normal file
128
node_modules/socks/build/common/helpers.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.validateSocksClientChainOptions = exports.validateSocksClientOptions = void 0;
|
||||
const util_1 = require("./util");
|
||||
const constants_1 = require("./constants");
|
||||
const stream = require("stream");
|
||||
/**
|
||||
* Validates the provided SocksClientOptions
|
||||
* @param options { SocksClientOptions }
|
||||
* @param acceptedCommands { string[] } A list of accepted SocksProxy commands.
|
||||
*/
|
||||
function validateSocksClientOptions(options, acceptedCommands = ['connect', 'bind', 'associate']) {
|
||||
// Check SOCKs command option.
|
||||
if (!constants_1.SocksCommand[options.command]) {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksCommand, options);
|
||||
}
|
||||
// Check SocksCommand for acceptable command.
|
||||
if (acceptedCommands.indexOf(options.command) === -1) {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksCommandForOperation, options);
|
||||
}
|
||||
// Check destination
|
||||
if (!isValidSocksRemoteHost(options.destination)) {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsDestination, options);
|
||||
}
|
||||
// Check SOCKS proxy to use
|
||||
if (!isValidSocksProxy(options.proxy)) {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsProxy, options);
|
||||
}
|
||||
// Validate custom auth (if set)
|
||||
validateCustomProxyAuth(options.proxy, options);
|
||||
// Check timeout
|
||||
if (options.timeout && !isValidTimeoutValue(options.timeout)) {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsTimeout, options);
|
||||
}
|
||||
// Check existing_socket (if provided)
|
||||
if (options.existing_socket &&
|
||||
!(options.existing_socket instanceof stream.Duplex)) {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsExistingSocket, options);
|
||||
}
|
||||
}
|
||||
exports.validateSocksClientOptions = validateSocksClientOptions;
|
||||
/**
|
||||
* Validates the SocksClientChainOptions
|
||||
* @param options { SocksClientChainOptions }
|
||||
*/
|
||||
function validateSocksClientChainOptions(options) {
|
||||
// Only connect is supported when chaining.
|
||||
if (options.command !== 'connect') {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksCommandChain, options);
|
||||
}
|
||||
// Check destination
|
||||
if (!isValidSocksRemoteHost(options.destination)) {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsDestination, options);
|
||||
}
|
||||
// Validate proxies (length)
|
||||
if (!(options.proxies &&
|
||||
Array.isArray(options.proxies) &&
|
||||
options.proxies.length >= 2)) {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsProxiesLength, options);
|
||||
}
|
||||
// Validate proxies
|
||||
options.proxies.forEach((proxy) => {
|
||||
if (!isValidSocksProxy(proxy)) {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsProxy, options);
|
||||
}
|
||||
// Validate custom auth (if set)
|
||||
validateCustomProxyAuth(proxy, options);
|
||||
});
|
||||
// Check timeout
|
||||
if (options.timeout && !isValidTimeoutValue(options.timeout)) {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsTimeout, options);
|
||||
}
|
||||
}
|
||||
exports.validateSocksClientChainOptions = validateSocksClientChainOptions;
|
||||
function validateCustomProxyAuth(proxy, options) {
|
||||
if (proxy.custom_auth_method !== undefined) {
|
||||
// Invalid auth method range
|
||||
if (proxy.custom_auth_method < constants_1.SOCKS5_CUSTOM_AUTH_START ||
|
||||
proxy.custom_auth_method > constants_1.SOCKS5_CUSTOM_AUTH_END) {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsCustomAuthRange, options);
|
||||
}
|
||||
// Missing custom_auth_request_handler
|
||||
if (proxy.custom_auth_request_handler === undefined ||
|
||||
typeof proxy.custom_auth_request_handler !== 'function') {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsCustomAuthOptions, options);
|
||||
}
|
||||
// Missing custom_auth_response_size
|
||||
if (proxy.custom_auth_response_size === undefined) {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsCustomAuthOptions, options);
|
||||
}
|
||||
// Missing/invalid custom_auth_response_handler
|
||||
if (proxy.custom_auth_response_handler === undefined ||
|
||||
typeof proxy.custom_auth_response_handler !== 'function') {
|
||||
throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsCustomAuthOptions, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Validates a SocksRemoteHost
|
||||
* @param remoteHost { SocksRemoteHost }
|
||||
*/
|
||||
function isValidSocksRemoteHost(remoteHost) {
|
||||
return (remoteHost &&
|
||||
typeof remoteHost.host === 'string' &&
|
||||
typeof remoteHost.port === 'number' &&
|
||||
remoteHost.port >= 0 &&
|
||||
remoteHost.port <= 65535);
|
||||
}
|
||||
/**
|
||||
* Validates a SocksProxy
|
||||
* @param proxy { SocksProxy }
|
||||
*/
|
||||
function isValidSocksProxy(proxy) {
|
||||
return (proxy &&
|
||||
(typeof proxy.host === 'string' || typeof proxy.ipaddress === 'string') &&
|
||||
typeof proxy.port === 'number' &&
|
||||
proxy.port >= 0 &&
|
||||
proxy.port <= 65535 &&
|
||||
(proxy.type === 4 || proxy.type === 5));
|
||||
}
|
||||
/**
|
||||
* Validates a timeout value.
|
||||
* @param value { Number }
|
||||
*/
|
||||
function isValidTimeoutValue(value) {
|
||||
return typeof value === 'number' && value > 0;
|
||||
}
|
||||
//# sourceMappingURL=helpers.js.map
|
1
node_modules/socks/build/common/helpers.js.map
generated
vendored
Normal file
1
node_modules/socks/build/common/helpers.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
43
node_modules/socks/build/common/receivebuffer.js
generated
vendored
Normal file
43
node_modules/socks/build/common/receivebuffer.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ReceiveBuffer = void 0;
|
||||
class ReceiveBuffer {
|
||||
constructor(size = 4096) {
|
||||
this.buffer = Buffer.allocUnsafe(size);
|
||||
this.offset = 0;
|
||||
this.originalSize = size;
|
||||
}
|
||||
get length() {
|
||||
return this.offset;
|
||||
}
|
||||
append(data) {
|
||||
if (!Buffer.isBuffer(data)) {
|
||||
throw new Error('Attempted to append a non-buffer instance to ReceiveBuffer.');
|
||||
}
|
||||
if (this.offset + data.length >= this.buffer.length) {
|
||||
const tmp = this.buffer;
|
||||
this.buffer = Buffer.allocUnsafe(Math.max(this.buffer.length + this.originalSize, this.buffer.length + data.length));
|
||||
tmp.copy(this.buffer);
|
||||
}
|
||||
data.copy(this.buffer, this.offset);
|
||||
return (this.offset += data.length);
|
||||
}
|
||||
peek(length) {
|
||||
if (length > this.offset) {
|
||||
throw new Error('Attempted to read beyond the bounds of the managed internal data.');
|
||||
}
|
||||
return this.buffer.slice(0, length);
|
||||
}
|
||||
get(length) {
|
||||
if (length > this.offset) {
|
||||
throw new Error('Attempted to read beyond the bounds of the managed internal data.');
|
||||
}
|
||||
const value = Buffer.allocUnsafe(length);
|
||||
this.buffer.slice(0, length).copy(value);
|
||||
this.buffer.copyWithin(0, length, length + this.offset - length);
|
||||
this.offset -= length;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
exports.ReceiveBuffer = ReceiveBuffer;
|
||||
//# sourceMappingURL=receivebuffer.js.map
|
1
node_modules/socks/build/common/receivebuffer.js.map
generated
vendored
Normal file
1
node_modules/socks/build/common/receivebuffer.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
25
node_modules/socks/build/common/util.js
generated
vendored
Normal file
25
node_modules/socks/build/common/util.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.shuffleArray = exports.SocksClientError = void 0;
|
||||
/**
|
||||
* Error wrapper for SocksClient
|
||||
*/
|
||||
class SocksClientError extends Error {
|
||||
constructor(message, options) {
|
||||
super(message);
|
||||
this.options = options;
|
||||
}
|
||||
}
|
||||
exports.SocksClientError = SocksClientError;
|
||||
/**
|
||||
* Shuffles a given array.
|
||||
* @param array The array to shuffle.
|
||||
*/
|
||||
function shuffleArray(array) {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
}
|
||||
}
|
||||
exports.shuffleArray = shuffleArray;
|
||||
//# sourceMappingURL=util.js.map
|
1
node_modules/socks/build/common/util.js.map
generated
vendored
Normal file
1
node_modules/socks/build/common/util.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/common/util.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAM,gBAAiB,SAAQ,KAAK;IAClC,YACE,OAAe,EACR,OAAqD;QAE5D,KAAK,CAAC,OAAO,CAAC,CAAC;QAFR,YAAO,GAAP,OAAO,CAA8C;IAG9D,CAAC;CACF;AAuBuB,4CAAgB;AArBxC;;;GAGG;AACH,SAAS,YAAY,CAAC,KAAgB;IACpC,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACzC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7C;AACH,CAAC;AAYyC,oCAAY"}
|
18
node_modules/socks/build/index.js
generated
vendored
Normal file
18
node_modules/socks/build/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./client/socksclient"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/socks/build/index.js.map
generated
vendored
Normal file
1
node_modules/socks/build/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC"}
|
17
node_modules/socks/docs/examples/index.md
generated
vendored
Normal file
17
node_modules/socks/docs/examples/index.md
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# socks examples
|
||||
|
||||
## TypeScript Examples
|
||||
|
||||
[Connect command](typescript/connectExample.md)
|
||||
|
||||
[Bind command](typescript/bindExample.md)
|
||||
|
||||
[Associate command](typescript/associateExample.md)
|
||||
|
||||
## JavaScript Examples
|
||||
|
||||
[Connect command](javascript/connectExample.md)
|
||||
|
||||
[Bind command](javascript/bindExample.md)
|
||||
|
||||
[Associate command](javascript/associateExample.md)
|
90
node_modules/socks/docs/examples/javascript/associateExample.md
generated
vendored
Normal file
90
node_modules/socks/docs/examples/javascript/associateExample.md
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
# socks examples
|
||||
|
||||
## Example for SOCKS 'associate' command
|
||||
|
||||
The associate command tells the SOCKS proxy server to establish a UDP relay. The server binds to a new UDP port and communicates the newly opened port back to the origin client. From here, any SOCKS UDP frame packets sent to this special UDP port on the Proxy server will be forwarded to the desired destination, and any responses will be forwarded back to the origin client (you).
|
||||
|
||||
This can be used for things such as DNS queries, and other UDP communicates.
|
||||
|
||||
**Connection Steps**
|
||||
|
||||
1. Client -(associate)-> Proxy (Tells the proxy to create a UDP relay and bind on a new port)
|
||||
2. Client <-(port)- Proxy (Tells the origin client which port it opened and is accepting UDP frame packets on)
|
||||
|
||||
At this point the proxy is accepting UDP frames on the specified port.
|
||||
|
||||
3. Client --(udp frame) -> Proxy -> Destination (The origin client sends a UDP frame to the proxy on the UDP port, and the proxy then forwards it to the destination specified in the UDP frame.)
|
||||
4. Client <--(udp frame) <-- Proxy <-- Destination (The destination client responds to the udp packet sent in #3)
|
||||
|
||||
## Usage
|
||||
|
||||
The 'associate' command can only be used by creating a new SocksClient instance and listening for the 'established' event.
|
||||
|
||||
**Note:** UDP packets relayed through the proxy servers are encompassed in a special Socks UDP frame format. SocksClient.createUDPFrame() and SocksClient.parseUDPFrame() create and parse these special UDP packets.
|
||||
|
||||
```typescript
|
||||
const dgram = require('dgram');
|
||||
const SocksClient = require('socks').SocksClient;
|
||||
|
||||
// Create a local UDP socket for sending/receiving packets to/from the proxy.
|
||||
const udpSocket = dgram.createSocket('udp4');
|
||||
udpSocket.bind();
|
||||
|
||||
// Listen for incoming UDP packets from the proxy server.
|
||||
udpSocket.on('message', (message, rinfo) => {
|
||||
console.log(SocksClient.parseUDPFrame(message));
|
||||
/*
|
||||
{ frameNumber: 0,
|
||||
remoteHost: { host: '8.8.8.8', port: 53 }, // The remote host that replied with a UDP packet
|
||||
data: <Buffer 74 65 73 74 0a> // The data
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
const options = {
|
||||
proxy: {
|
||||
host: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
// This should be the ip and port of the expected client that will be sending UDP frames to the newly opened UDP port on the server.
|
||||
// Most SOCKS servers accept 0.0.0.0 as a wildcard address to accept UDP frames from any source.
|
||||
destination: {
|
||||
host: '0.0.0.0',
|
||||
port: 0
|
||||
},
|
||||
|
||||
command: 'associate'
|
||||
};
|
||||
|
||||
const client = new SocksClient(options);
|
||||
|
||||
// This event is fired when the SOCKS server has started listening on a new UDP port for UDP relaying.
|
||||
client.on('established', info => {
|
||||
console.log(info);
|
||||
/*
|
||||
{
|
||||
socket: <Socket ...>,
|
||||
remoteHost: { // This is the remote port on the SOCKS proxy server to send UDP frame packets to.
|
||||
host: '104.131.124.203',
|
||||
port: 58232
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Send a udp frame to 8.8.8.8 on port 53 through the proxy.
|
||||
const packet = SocksClient.createUDPFrame({
|
||||
remoteHost: { host: '8.8.8.8', port: 53 },
|
||||
data: Buffer.from('hello') // A DNS lookup in the real world.
|
||||
});
|
||||
|
||||
// Send packet.
|
||||
udpSocket.send(packet, info.remoteHost.port, info.remoteHost.host);
|
||||
});
|
||||
|
||||
// SOCKS proxy failed to bind.
|
||||
client.on('error', () => {
|
||||
// Handle errors
|
||||
});
|
||||
```
|
83
node_modules/socks/docs/examples/javascript/bindExample.md
generated
vendored
Normal file
83
node_modules/socks/docs/examples/javascript/bindExample.md
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
# socks examples
|
||||
|
||||
## Example for SOCKS 'bind' command
|
||||
|
||||
The bind command tells the SOCKS proxy server to bind and listen on a new TCP port for an incoming connection. It communicates the newly opened port back to the origin client. Once a incoming connection is accepted by the SOCKS proxy server it then communicates the remote host that connected to the SOCKS proxy back through the same initial connection via the origin client.
|
||||
|
||||
This can be used for things such as FTP clients which require incoming TCP connections, etc.
|
||||
|
||||
**Connection Steps**
|
||||
|
||||
1. Client -(bind)-> Proxy (Tells the proxy to bind to a new port)
|
||||
2. Client <-(port)- Proxy (Tells the origin client which port it opened)
|
||||
3. Client2 --> Proxy (Other client connects to the proxy on this port)
|
||||
4. Client <--(client2's host info) (Proxy tells the origin client who connected to it)
|
||||
5. Original connection to the proxy is now a full TCP stream between client (you) and client2.
|
||||
6. Client <--> Proxy <--> Client2
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
The 'bind' command can only be used by creating a new SocksClient instance and listening for 'bound' and 'established' events.
|
||||
|
||||
|
||||
```typescript
|
||||
const SocksClient = require('socks').SocksClient;
|
||||
|
||||
const options = {
|
||||
proxy: {
|
||||
host: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
// This should be the ip and port of the expected client that will connect to the SOCKS proxy server on the newly bound port.
|
||||
// Most SOCKS servers accept 0.0.0.0 as a wildcard address to accept any client.
|
||||
destination: {
|
||||
host: '0.0.0.0',
|
||||
port: 0
|
||||
},
|
||||
|
||||
command: 'bind'
|
||||
};
|
||||
|
||||
const client = new SocksClient(options);
|
||||
|
||||
// This event is fired when the SOCKS server has started listening on a new port for incoming connections.
|
||||
client.on('bound', (info) => {
|
||||
console.log(info);
|
||||
/*
|
||||
{
|
||||
socket: <Socket ...>,
|
||||
remoteHost: { // This is the remote ip and port of the SOCKS proxy that is now accepting incoming connections.
|
||||
host: '104.131.124.203',
|
||||
port: 49928
|
||||
}
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
// This event is fired when the SOCKS server has accepted an incoming connection on the newly bound port.
|
||||
client.on('established', (info) => {
|
||||
console.log(info);
|
||||
/*
|
||||
{
|
||||
socket: <Socket ...>,
|
||||
remoteHost: { // This is the remote ip and port that connected to the SOCKS proxy on the newly bound port.
|
||||
host: '1.2.3.4',
|
||||
port: 58232
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// At this point info.socket is a regular net.Socket TCP connection between client and client2 (1.2.3.4) (the client which connected to the proxy on the newly bound port.)
|
||||
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
});
|
||||
|
||||
// SOCKS proxy failed to bind.
|
||||
client.on('error', () => {
|
||||
// Handle errors
|
||||
});
|
||||
```
|
258
node_modules/socks/docs/examples/javascript/connectExample.md
generated
vendored
Normal file
258
node_modules/socks/docs/examples/javascript/connectExample.md
generated
vendored
Normal file
@@ -0,0 +1,258 @@
|
||||
# socks examples
|
||||
|
||||
## Example for SOCKS 'connect' command
|
||||
|
||||
The connect command is the most common use-case for a SOCKS proxy. This establishes a direct connection to a destination host through a proxy server. The destination host only has knowledge of the proxy server connecting to it and does not know about the origin client (you).
|
||||
|
||||
**Origin Client (you) <-> Proxy Server <-> Destination Server**
|
||||
|
||||
In this example, we are connecting to a web server on port 80, and sending a very basic HTTP request to receive a response. It's worth noting that there are many socks-http-agents that can be used with the node http module (and libraries such as request.js) to make this easier. This HTTP request is used as a simple example.
|
||||
|
||||
The 'connect' command can be used via the SocksClient.createConnection() factory function as well as by creating a SocksClient instance and using event handlers.
|
||||
|
||||
### Using createConnection with async/await
|
||||
|
||||
Since SocksClient.createConnection returns a Promise, we can easily use async/await for flow control.
|
||||
|
||||
```typescript
|
||||
const SocksClient = require('socks').SocksClient;
|
||||
|
||||
const options = {
|
||||
proxy: {
|
||||
host: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
destination: {
|
||||
host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5.
|
||||
port: 80
|
||||
},
|
||||
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
async function start() {
|
||||
try {
|
||||
const info = await SocksClient.createConnection(options);
|
||||
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
|
||||
info.socket.write('GET /json HTTP/1.1\nHost: ip-api.com\n\n');
|
||||
info.socket.on('data', (data) => {
|
||||
console.log(data.toString()); // ip-api.com sees that the last proxy (104.131.124.203) is connected to it and not the origin client (you).
|
||||
/*
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Sun, 24 Dec 2017 03:47:51 GMT
|
||||
Content-Length: 300
|
||||
|
||||
{
|
||||
"as":"AS14061 Digital Ocean, Inc.",
|
||||
"city":"Clifton",
|
||||
"country":"United States",
|
||||
"countryCode":"US",
|
||||
"isp":"Digital Ocean",
|
||||
"lat":40.8326,
|
||||
"lon":-74.1307,
|
||||
"org":"Digital Ocean",
|
||||
"query":"104.131.124.203",
|
||||
"region":"NJ",
|
||||
"regionName":"New Jersey",
|
||||
"status":"success",
|
||||
"timezone":"America/New_York",
|
||||
"zip":"07014"
|
||||
}
|
||||
*/
|
||||
} catch (err) {
|
||||
// Handle errors
|
||||
}
|
||||
}
|
||||
|
||||
start();
|
||||
```
|
||||
|
||||
### Using createConnection with Promises
|
||||
|
||||
```typescript
|
||||
const SocksClient = require('socks').SocksClient;
|
||||
|
||||
const options = {
|
||||
proxy: {
|
||||
ipaddress: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
destination: {
|
||||
host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5.
|
||||
port: 80
|
||||
},
|
||||
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
SocksClient.createConnection(options)
|
||||
.then(info => {
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
|
||||
info.socket.write('GET /json HTTP/1.1\nHost: ip-api.com\n\n');
|
||||
info.socket.on('data', (data) => {
|
||||
console.log(data.toString()); // ip-api.com sees that the last proxy (104.131.124.203) is connected to it and not the origin client (you).
|
||||
/*
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Sun, 24 Dec 2017 03:47:51 GMT
|
||||
Content-Length: 300
|
||||
|
||||
{
|
||||
"as":"AS14061 Digital Ocean, Inc.",
|
||||
"city":"Clifton",
|
||||
"country":"United States",
|
||||
"countryCode":"US",
|
||||
"isp":"Digital Ocean",
|
||||
"lat":40.8326,
|
||||
"lon":-74.1307,
|
||||
"org":"Digital Ocean",
|
||||
"query":"104.131.124.203",
|
||||
"region":"NJ",
|
||||
"regionName":"New Jersey",
|
||||
"status":"success",
|
||||
"timezone":"America/New_York",
|
||||
"zip":"07014"
|
||||
}
|
||||
*/
|
||||
})
|
||||
.catch(err => {
|
||||
// handle errors
|
||||
});
|
||||
```
|
||||
|
||||
### Using createConnection with callbacks
|
||||
|
||||
SocksClient.createConnection() optionally accepts a callback function as a second parameter.
|
||||
|
||||
**Note:** If a callback function is provided, a Promise is still returned from the function, but the promise will always resolve regardless of if there was en error. (tldr: Do not mix callbacks and Promises).
|
||||
|
||||
```typescript
|
||||
const SocksClient = require('socks').SocksClient;
|
||||
|
||||
const options = {
|
||||
proxy: {
|
||||
ipaddress: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
destination: {
|
||||
host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5.
|
||||
port: 80
|
||||
},
|
||||
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
SocksClient.createConnection(options, (err, info) => {
|
||||
if (err) {
|
||||
// handle errors
|
||||
} else {
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
|
||||
info.socket.write('GET /json HTTP/1.1\nHost: ip-api.com\n\n');
|
||||
info.socket.on('data', (data) => {
|
||||
console.log(data.toString()); // ip-api.com sees that the last proxy (104.131.124.203) is connected to it and not the origin client (you).
|
||||
/*
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Sun, 24 Dec 2017 03:47:51 GMT
|
||||
Content-Length: 300
|
||||
|
||||
{
|
||||
"as":"AS14061 Digital Ocean, Inc.",
|
||||
"city":"Clifton",
|
||||
"country":"United States",
|
||||
"countryCode":"US",
|
||||
"isp":"Digital Ocean",
|
||||
"lat":40.8326,
|
||||
"lon":-74.1307,
|
||||
"org":"Digital Ocean",
|
||||
"query":"104.131.124.203",
|
||||
"region":"NJ",
|
||||
"regionName":"New Jersey",
|
||||
"status":"success",
|
||||
"timezone":"America/New_York",
|
||||
"zip":"07014"
|
||||
}
|
||||
*/
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Using event handlers
|
||||
|
||||
SocksClient also supports instance creation of a SocksClient. This allows for event based flow control.
|
||||
|
||||
```typescript
|
||||
const SocksClient = require('socks').SocksClient;
|
||||
|
||||
const options = {
|
||||
proxy: {
|
||||
ipaddress: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
destination: {
|
||||
host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5.
|
||||
port: 80
|
||||
},
|
||||
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
const client = new SocksClient(options);
|
||||
|
||||
client.on('established', (info) => {
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
|
||||
info.socket.write('GET /json HTTP/1.1\nHost: ip-api.com\n\n');
|
||||
info.socket.on('data', (data) => {
|
||||
console.log(data.toString()); // ip-api.com sees that the last proxy (104.131.124.203) is connected to it and not the origin client (you).
|
||||
/*
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Sun, 24 Dec 2017 03:47:51 GMT
|
||||
Content-Length: 300
|
||||
|
||||
{
|
||||
"as":"AS14061 Digital Ocean, Inc.",
|
||||
"city":"Clifton",
|
||||
"country":"United States",
|
||||
"countryCode":"US",
|
||||
"isp":"Digital Ocean",
|
||||
"lat":40.8326,
|
||||
"lon":-74.1307,
|
||||
"org":"Digital Ocean",
|
||||
"query":"104.131.124.203",
|
||||
"region":"NJ",
|
||||
"regionName":"New Jersey",
|
||||
"status":"success",
|
||||
"timezone":"America/New_York",
|
||||
"zip":"07014"
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
// Failed to establish proxy connection to destination.
|
||||
client.on('error', () => {
|
||||
// Handle errors
|
||||
});
|
||||
```
|
93
node_modules/socks/docs/examples/typescript/associateExample.md
generated
vendored
Normal file
93
node_modules/socks/docs/examples/typescript/associateExample.md
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
# socks examples
|
||||
|
||||
## Example for SOCKS 'associate' command
|
||||
|
||||
The associate command tells the SOCKS proxy server to establish a UDP relay. The server binds to a new UDP port and communicates the newly opened port back to the origin client. From here, any SOCKS UDP frame packets sent to this special UDP port on the Proxy server will be forwarded to the desired destination, and any responses will be forwarded back to the origin client (you).
|
||||
|
||||
This can be used for things such as DNS queries, and other UDP communicates.
|
||||
|
||||
**Connection Steps**
|
||||
|
||||
1. Client -(associate)-> Proxy (Tells the proxy to create a UDP relay and bind on a new port)
|
||||
2. Client <-(port)- Proxy (Tells the origin client which port it opened and is accepting UDP frame packets on)
|
||||
|
||||
At this point the proxy is accepting UDP frames on the specified port.
|
||||
|
||||
3. Client --(udp frame) -> Proxy -> Destination (The origin client sends a UDP frame to the proxy on the UDP port, and the proxy then forwards it to the destination specified in the UDP frame.)
|
||||
4. Client <--(udp frame) <-- Proxy <-- Destination (The destination client responds to the udp packet sent in #3)
|
||||
|
||||
## Usage
|
||||
|
||||
The 'associate' command can only be used by creating a new SocksClient instance and listening for the 'established' event.
|
||||
|
||||
**Note:** UDP packets relayed through the proxy servers are packaged in a special Socks UDP frame format. SocksClient.createUDPFrame() and SocksClient.parseUDPFrame() create and parse these special UDP packets.
|
||||
|
||||
```typescript
|
||||
import * as dgram from 'dgram';
|
||||
import { SocksClient, SocksClientOptions } from 'socks';
|
||||
|
||||
// Create a local UDP socket for sending/receiving packets to/from the proxy.
|
||||
const udpSocket = dgram.createSocket('udp4');
|
||||
udpSocket.bind();
|
||||
|
||||
// Listen for incoming UDP packets from the proxy server.
|
||||
udpSocket.on('message', (message, rinfo) => {
|
||||
console.log(SocksClient.parseUDPFrame(message));
|
||||
/*
|
||||
{ frameNumber: 0,
|
||||
remoteHost: { host: '8.8.8.8', port: 53 }, // The remote host that replied with a UDP packet
|
||||
data: <Buffer 74 65 73 74 0a> // The data
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
const options: SocksClientOptions = {
|
||||
proxy: {
|
||||
host: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
// This should be the ip and port of the expected client that will be sending UDP frames to the newly opened UDP port on the server.
|
||||
// Most SOCKS servers accept 0.0.0.0 as a wildcard address to accept UDP frames from any source.
|
||||
destination: {
|
||||
host: '0.0.0.0',
|
||||
port: 0
|
||||
},
|
||||
|
||||
command: 'associate'
|
||||
};
|
||||
|
||||
const client = new SocksClient(options);
|
||||
|
||||
// This event is fired when the SOCKS server has started listening on a new UDP port for UDP relaying.
|
||||
client.on('established', info => {
|
||||
console.log(info);
|
||||
/*
|
||||
{
|
||||
socket: <Socket ...>,
|
||||
remoteHost: { // This is the remote port on the SOCKS proxy server to send UDP frame packets to.
|
||||
host: '104.131.124.203',
|
||||
port: 58232
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Send a udp frame to 8.8.8.8 on port 53 through the proxy.
|
||||
const packet = SocksClient.createUDPFrame({
|
||||
remoteHost: { host: '8.8.8.8', port: 53 },
|
||||
data: Buffer.from('hello') // A DNS lookup in the real world.
|
||||
});
|
||||
|
||||
// Send packet.
|
||||
udpSocket.send(packet, info.remoteHost.port, info.remoteHost.host);
|
||||
});
|
||||
|
||||
// SOCKS proxy failed to bind.
|
||||
client.on('error', () => {
|
||||
// Handle errors
|
||||
});
|
||||
|
||||
// Start connection
|
||||
client.connect();
|
||||
```
|
86
node_modules/socks/docs/examples/typescript/bindExample.md
generated
vendored
Normal file
86
node_modules/socks/docs/examples/typescript/bindExample.md
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
# socks examples
|
||||
|
||||
## Example for SOCKS 'bind' command
|
||||
|
||||
The bind command tells the SOCKS proxy server to bind and listen on a new TCP port for an incoming connection. It communicates the newly opened port back to the origin client. Once a incoming connection is accepted by the SOCKS proxy server it then communicates the remote host that connected to the SOCKS proxy back through the same initial connection via the origin client.
|
||||
|
||||
This can be used for things such as FTP clients which require incoming TCP connections, etc.
|
||||
|
||||
**Connection Steps**
|
||||
|
||||
1. Client -(bind)-> Proxy (Tells the proxy to bind to a new port)
|
||||
2. Client <-(port)- Proxy (Tells the origin client which port it opened)
|
||||
3. Client2 --> Proxy (Other client connects to the proxy on this port)
|
||||
4. Client <--(client2's host info) (Proxy tells the origin client who connected to it)
|
||||
5. Original connection to the proxy is now a full TCP stream between client (you) and client2.
|
||||
6. Client <--> Proxy <--> Client2
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
The 'bind' command can only be used by creating a new SocksClient instance and listening for 'bound' and 'established' events.
|
||||
|
||||
|
||||
```typescript
|
||||
import { SocksClient, SocksClientOptions } from 'socks';
|
||||
|
||||
const options: SocksClientOptions = {
|
||||
proxy: {
|
||||
host: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
// This should be the ip and port of the expected client that will connect to the SOCKS proxy server on the newly bound port.
|
||||
// Most SOCKS servers accept 0.0.0.0 as a wildcard address to accept any client.
|
||||
destination: {
|
||||
host: '0.0.0.0',
|
||||
port: 0
|
||||
},
|
||||
|
||||
command: 'bind'
|
||||
};
|
||||
|
||||
const client = new SocksClient(options);
|
||||
|
||||
// This event is fired when the SOCKS server has started listening on a new port for incoming connections.
|
||||
client.on('bound', (info) => {
|
||||
console.log(info);
|
||||
/*
|
||||
{
|
||||
socket: <Socket ...>,
|
||||
remoteHost: { // This is the remote ip and port of the SOCKS proxy that is now accepting incoming connections.
|
||||
host: '104.131.124.203',
|
||||
port: 49928
|
||||
}
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
// This event is fired when the SOCKS server has accepted an incoming connection on the newly bound port.
|
||||
client.on('established', (info) => {
|
||||
console.log(info);
|
||||
/*
|
||||
{
|
||||
socket: <Socket ...>,
|
||||
remoteHost: { // This is the remote ip and port that connected to the SOCKS proxy on the newly bound port.
|
||||
host: '1.2.3.4',
|
||||
port: 58232
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// At this point info.socket is a regular net.Socket TCP connection between client and client2 (1.2.3.4) (the client which connected to the proxy on the newly bound port.)
|
||||
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
});
|
||||
|
||||
// SOCKS proxy failed to bind.
|
||||
client.on('error', () => {
|
||||
// Handle errors
|
||||
});
|
||||
|
||||
// Start connection
|
||||
client.connect();
|
||||
```
|
265
node_modules/socks/docs/examples/typescript/connectExample.md
generated
vendored
Normal file
265
node_modules/socks/docs/examples/typescript/connectExample.md
generated
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
# socks examples
|
||||
|
||||
## Example for SOCKS 'connect' command
|
||||
|
||||
The connect command is the most common use-case for a SOCKS proxy. This establishes a direct connection to a destination host through a proxy server. The destination host only has knowledge of the proxy server connecting to it and does not know about the origin client (you).
|
||||
|
||||
**Origin Client (you) <-> Proxy Server <-> Destination Server**
|
||||
|
||||
In this example, we are connecting to a web server on port 80, and sending a very basic HTTP request to receive a response. It's worth noting that there are many socks-http-agents that can be used with the node http module (and libraries such as request.js) to make this easier. This HTTP request is used as a simple example.
|
||||
|
||||
The 'connect' command can be used via the SocksClient.createConnection() factory function as well as by creating a SocksClient instance and using event handlers.
|
||||
|
||||
### Using createConnection with async/await
|
||||
|
||||
Since SocksClient.createConnection returns a Promise, we can easily use async/await for flow control.
|
||||
|
||||
```typescript
|
||||
import { SocksClient, SocksClientOptions } from 'socks';
|
||||
|
||||
const options: SocksClientOptions = {
|
||||
proxy: {
|
||||
host: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
destination: {
|
||||
host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5.
|
||||
port: 80
|
||||
},
|
||||
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
async function start() {
|
||||
try {
|
||||
const info = await SocksClient.createConnection(options);
|
||||
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
|
||||
info.socket.write('GET /json HTTP/1.1\nHost: ip-api.com\n\n');
|
||||
info.socket.on('data', (data) => {
|
||||
console.log(data.toString()); // ip-api.com sees that the last proxy (104.131.124.203) is connected to it and not the origin client (you).
|
||||
/*
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Sun, 24 Dec 2017 03:47:51 GMT
|
||||
Content-Length: 300
|
||||
|
||||
{
|
||||
"as":"AS14061 Digital Ocean, Inc.",
|
||||
"city":"Clifton",
|
||||
"country":"United States",
|
||||
"countryCode":"US",
|
||||
"isp":"Digital Ocean",
|
||||
"lat":40.8326,
|
||||
"lon":-74.1307,
|
||||
"org":"Digital Ocean",
|
||||
"query":"104.131.124.203",
|
||||
"region":"NJ",
|
||||
"regionName":"New Jersey",
|
||||
"status":"success",
|
||||
"timezone":"America/New_York",
|
||||
"zip":"07014"
|
||||
}
|
||||
*/
|
||||
});
|
||||
} catch (err) {
|
||||
// Handle errors
|
||||
}
|
||||
}
|
||||
|
||||
start();
|
||||
```
|
||||
|
||||
### Using createConnection with Promises
|
||||
|
||||
```typescript
|
||||
import { SocksClient, SocksClientOptions } from 'socks';
|
||||
|
||||
const options: SocksClientOptions = {
|
||||
proxy: {
|
||||
ipaddress: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
destination: {
|
||||
host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5.
|
||||
port: 80
|
||||
},
|
||||
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
SocksClient.createConnection(options)
|
||||
.then(info => {
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
|
||||
info.socket.write('GET /json HTTP/1.1\nHost: ip-api.com\n\n');
|
||||
info.socket.on('data', (data) => {
|
||||
console.log(data.toString()); // ip-api.com sees that the last proxy (104.131.124.203) is connected to it and not the origin client (you).
|
||||
/*
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Sun, 24 Dec 2017 03:47:51 GMT
|
||||
Content-Length: 300
|
||||
|
||||
{
|
||||
"as":"AS14061 Digital Ocean, Inc.",
|
||||
"city":"Clifton",
|
||||
"country":"United States",
|
||||
"countryCode":"US",
|
||||
"isp":"Digital Ocean",
|
||||
"lat":40.8326,
|
||||
"lon":-74.1307,
|
||||
"org":"Digital Ocean",
|
||||
"query":"104.131.124.203",
|
||||
"region":"NJ",
|
||||
"regionName":"New Jersey",
|
||||
"status":"success",
|
||||
"timezone":"America/New_York",
|
||||
"zip":"07014"
|
||||
}
|
||||
*/
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
// handle errors
|
||||
});
|
||||
```
|
||||
|
||||
### Using createConnection with callbacks
|
||||
|
||||
SocksClient.createConnection() optionally accepts a callback function as a second parameter.
|
||||
|
||||
**Note:** If a callback function is provided, a Promise is still returned from the function, but the promise will always resolve regardless of if there was en error. (tldr: Do not mix callbacks and Promises).
|
||||
|
||||
```typescript
|
||||
import { SocksClient, SocksClientOptions } from 'socks';
|
||||
|
||||
const options: SocksClientOptions = {
|
||||
proxy: {
|
||||
ipaddress: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
destination: {
|
||||
host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5.
|
||||
port: 80
|
||||
},
|
||||
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
SocksClient.createConnection(options, (err, info) => {
|
||||
if (err) {
|
||||
// handle errors
|
||||
} else {
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
|
||||
info.socket.write('GET /json HTTP/1.1\nHost: ip-api.com\n\n');
|
||||
info.socket.on('data', (data) => {
|
||||
console.log(data.toString()); // ip-api.com sees that the last proxy (104.131.124.203) is connected to it and not the origin client (you).
|
||||
/*
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Sun, 24 Dec 2017 03:47:51 GMT
|
||||
Content-Length: 300
|
||||
|
||||
{
|
||||
"as":"AS14061 Digital Ocean, Inc.",
|
||||
"city":"Clifton",
|
||||
"country":"United States",
|
||||
"countryCode":"US",
|
||||
"isp":"Digital Ocean",
|
||||
"lat":40.8326,
|
||||
"lon":-74.1307,
|
||||
"org":"Digital Ocean",
|
||||
"query":"104.131.124.203",
|
||||
"region":"NJ",
|
||||
"regionName":"New Jersey",
|
||||
"status":"success",
|
||||
"timezone":"America/New_York",
|
||||
"zip":"07014"
|
||||
}
|
||||
*/
|
||||
});
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Using event handlers
|
||||
|
||||
SocksClient also supports instance creation of a SocksClient. This allows for event based flow control.
|
||||
|
||||
```typescript
|
||||
import { SocksClient, SocksClientOptions } from 'socks';
|
||||
|
||||
const options: SocksClientOptions = {
|
||||
proxy: {
|
||||
ipaddress: '104.131.124.203',
|
||||
port: 1081,
|
||||
type: 5
|
||||
},
|
||||
|
||||
destination: {
|
||||
host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5.
|
||||
port: 80
|
||||
},
|
||||
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
const client = new SocksClient(options);
|
||||
|
||||
client.on('established', (info) => {
|
||||
console.log(info.socket);
|
||||
// <Socket ...> (this is a raw net.Socket that is established to the destination host through the given proxy servers)
|
||||
|
||||
info.socket.write('GET /json HTTP/1.1\nHost: ip-api.com\n\n');
|
||||
info.socket.on('data', (data) => {
|
||||
console.log(data.toString()); // ip-api.com sees that the last proxy (104.131.124.203) is connected to it and not the origin client (you).
|
||||
/*
|
||||
HTTP/1.1 200 OK
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Date: Sun, 24 Dec 2017 03:47:51 GMT
|
||||
Content-Length: 300
|
||||
|
||||
{
|
||||
"as":"AS14061 Digital Ocean, Inc.",
|
||||
"city":"Clifton",
|
||||
"country":"United States",
|
||||
"countryCode":"US",
|
||||
"isp":"Digital Ocean",
|
||||
"lat":40.8326,
|
||||
"lon":-74.1307,
|
||||
"org":"Digital Ocean",
|
||||
"query":"104.131.124.203",
|
||||
"region":"NJ",
|
||||
"regionName":"New Jersey",
|
||||
"status":"success",
|
||||
"timezone":"America/New_York",
|
||||
"zip":"07014"
|
||||
}
|
||||
*/
|
||||
});
|
||||
});
|
||||
|
||||
// Failed to establish proxy connection to destination.
|
||||
client.on('error', () => {
|
||||
// Handle errors
|
||||
});
|
||||
|
||||
// Start connection
|
||||
client.connect();
|
||||
```
|
5
node_modules/socks/docs/index.md
generated
vendored
Normal file
5
node_modules/socks/docs/index.md
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# Documentation
|
||||
|
||||
- [API Reference](https://github.com/JoshGlazebrook/socks#api-reference)
|
||||
|
||||
- [Code Examples](./examples/index.md)
|
86
node_modules/socks/docs/migratingFromV1.md
generated
vendored
Normal file
86
node_modules/socks/docs/migratingFromV1.md
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
# socks
|
||||
|
||||
## Migrating from v1
|
||||
|
||||
For the most part, migrating from v1 takes minimal effort as v2 still supports factory creation of proxy connections with callback support.
|
||||
|
||||
### Notable breaking changes
|
||||
|
||||
- In an options object, the proxy 'command' is now required and does not default to 'connect'.
|
||||
- **In an options object, 'target' is now known as 'destination'.**
|
||||
- Sockets are no longer paused after a SOCKS connection is made, so socket.resume() is no longer required. (Please be sure to attach data handlers immediately to the Socket to avoid losing data).
|
||||
- In v2, only the 'connect' command is supported via the factory SocksClient.createConnection function. (BIND and ASSOCIATE must be used with a SocksClient instance via event handlers).
|
||||
- In v2, the factory SocksClient.createConnection function callback is called with a single object rather than separate socket and info object.
|
||||
- A SOCKS http/https agent is no longer bundled into the library.
|
||||
|
||||
For informational purposes, here is the original getting started example from v1 converted to work with v2.
|
||||
|
||||
### Before (v1)
|
||||
|
||||
```javascript
|
||||
var Socks = require('socks');
|
||||
|
||||
var options = {
|
||||
proxy: {
|
||||
ipaddress: "202.101.228.108",
|
||||
port: 1080,
|
||||
type: 5
|
||||
},
|
||||
target: {
|
||||
host: "google.com",
|
||||
port: 80
|
||||
},
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
Socks.createConnection(options, function(err, socket, info) {
|
||||
if (err)
|
||||
console.log(err);
|
||||
else {
|
||||
socket.write("GET / HTTP/1.1\nHost: google.com\n\n");
|
||||
socket.on('data', function(data) {
|
||||
console.log(data.length);
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
// PLEASE NOTE: sockets need to be resumed before any data will come in or out as they are paused right before this callback is fired.
|
||||
socket.resume();
|
||||
|
||||
// 569
|
||||
// <Buffer 48 54 54 50 2f 31 2e 31 20 33 30 31 20 4d 6f 76 65 64 20 50 65...
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### After (v2)
|
||||
```javascript
|
||||
const SocksClient = require('socks').SocksClient;
|
||||
|
||||
let options = {
|
||||
proxy: {
|
||||
ipaddress: "202.101.228.108",
|
||||
port: 1080,
|
||||
type: 5
|
||||
},
|
||||
destination: {
|
||||
host: "google.com",
|
||||
port: 80
|
||||
},
|
||||
command: 'connect'
|
||||
};
|
||||
|
||||
SocksClient.createConnection(options, function(err, result) {
|
||||
if (err)
|
||||
console.log(err);
|
||||
else {
|
||||
result.socket.write("GET / HTTP/1.1\nHost: google.com\n\n");
|
||||
result.socket.on('data', function(data) {
|
||||
console.log(data.length);
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
// 569
|
||||
// <Buffer 48 54 54 50 2f 31 2e 31 20 33 30 31 20 4d 6f 76 65 64 20 50 65...
|
||||
}
|
||||
});
|
||||
```
|
58
node_modules/socks/package.json
generated
vendored
Normal file
58
node_modules/socks/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "socks",
|
||||
"private": false,
|
||||
"version": "2.7.1",
|
||||
"description": "Fully featured SOCKS proxy client supporting SOCKSv4, SOCKSv4a, and SOCKSv5. Includes Bind and Associate functionality.",
|
||||
"main": "build/index.js",
|
||||
"typings": "typings/index.d.ts",
|
||||
"homepage": "https://github.com/JoshGlazebrook/socks/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/JoshGlazebrook/socks.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/JoshGlazebrook/socks/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"socks",
|
||||
"proxy",
|
||||
"tor",
|
||||
"socks 4",
|
||||
"socks 5",
|
||||
"socks4",
|
||||
"socks5"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 10.13.0",
|
||||
"npm": ">= 3.0.0"
|
||||
},
|
||||
"author": "Josh Glazebrook",
|
||||
"contributors": [
|
||||
"castorw"
|
||||
],
|
||||
"license": "MIT",
|
||||
"readmeFilename": "README.md",
|
||||
"devDependencies": {
|
||||
"@types/ip": "1.1.0",
|
||||
"@types/mocha": "^9.1.1",
|
||||
"@types/node": "^18.0.6",
|
||||
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
||||
"@typescript-eslint/parser": "^5.30.6",
|
||||
"eslint": "^8.20.0",
|
||||
"mocha": "^10.0.0",
|
||||
"prettier": "^2.7.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.7.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"ip": "^2.0.0",
|
||||
"smart-buffer": "^4.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "npm install -g typescript && npm run build",
|
||||
"test": "NODE_ENV=test mocha --recursive --require ts-node/register test/**/*.ts",
|
||||
"prettier": "prettier --write ./src/**/*.ts --config .prettierrc.yaml",
|
||||
"lint": "eslint 'src/**/*.ts'",
|
||||
"build": "rm -rf build typings && prettier --write ./src/**/*.ts --config .prettierrc.yaml && tsc -p ."
|
||||
}
|
||||
}
|
162
node_modules/socks/typings/client/socksclient.d.ts
generated
vendored
Normal file
162
node_modules/socks/typings/client/socksclient.d.ts
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
import { SocksClientOptions, SocksClientChainOptions, SocksRemoteHost, SocksProxy, SocksClientBoundEvent, SocksClientEstablishedEvent, SocksUDPFrameDetails } from '../common/constants';
|
||||
import { SocksClientError } from '../common/util';
|
||||
import { Duplex } from 'stream';
|
||||
declare interface SocksClient {
|
||||
on(event: 'error', listener: (err: SocksClientError) => void): this;
|
||||
on(event: 'bound', listener: (info: SocksClientBoundEvent) => void): this;
|
||||
on(event: 'established', listener: (info: SocksClientEstablishedEvent) => void): this;
|
||||
once(event: string, listener: (...args: unknown[]) => void): this;
|
||||
once(event: 'error', listener: (err: SocksClientError) => void): this;
|
||||
once(event: 'bound', listener: (info: SocksClientBoundEvent) => void): this;
|
||||
once(event: 'established', listener: (info: SocksClientEstablishedEvent) => void): this;
|
||||
emit(event: string | symbol, ...args: unknown[]): boolean;
|
||||
emit(event: 'error', err: SocksClientError): boolean;
|
||||
emit(event: 'bound', info: SocksClientBoundEvent): boolean;
|
||||
emit(event: 'established', info: SocksClientEstablishedEvent): boolean;
|
||||
}
|
||||
declare class SocksClient extends EventEmitter implements SocksClient {
|
||||
private options;
|
||||
private socket;
|
||||
private state;
|
||||
private receiveBuffer;
|
||||
private nextRequiredPacketBufferSize;
|
||||
private socks5ChosenAuthType;
|
||||
private onDataReceived;
|
||||
private onClose;
|
||||
private onError;
|
||||
private onConnect;
|
||||
constructor(options: SocksClientOptions);
|
||||
/**
|
||||
* Creates a new SOCKS connection.
|
||||
*
|
||||
* Note: Supports callbacks and promises. Only supports the connect command.
|
||||
* @param options { SocksClientOptions } Options.
|
||||
* @param callback { Function } An optional callback function.
|
||||
* @returns { Promise }
|
||||
*/
|
||||
static createConnection(options: SocksClientOptions, callback?: (error: Error | null, info?: SocksClientEstablishedEvent) => void): Promise<SocksClientEstablishedEvent>;
|
||||
/**
|
||||
* Creates a new SOCKS connection chain to a destination host through 2 or more SOCKS proxies.
|
||||
*
|
||||
* Note: Supports callbacks and promises. Only supports the connect method.
|
||||
* Note: Implemented via createConnection() factory function.
|
||||
* @param options { SocksClientChainOptions } Options
|
||||
* @param callback { Function } An optional callback function.
|
||||
* @returns { Promise }
|
||||
*/
|
||||
static createConnectionChain(options: SocksClientChainOptions, callback?: (error: Error | null, socket?: SocksClientEstablishedEvent) => void): Promise<SocksClientEstablishedEvent>;
|
||||
/**
|
||||
* Creates a SOCKS UDP Frame.
|
||||
* @param options
|
||||
*/
|
||||
static createUDPFrame(options: SocksUDPFrameDetails): Buffer;
|
||||
/**
|
||||
* Parses a SOCKS UDP frame.
|
||||
* @param data
|
||||
*/
|
||||
static parseUDPFrame(data: Buffer): SocksUDPFrameDetails;
|
||||
/**
|
||||
* Internal state setter. If the SocksClient is in an error state, it cannot be changed to a non error state.
|
||||
*/
|
||||
private setState;
|
||||
/**
|
||||
* Starts the connection establishment to the proxy and destination.
|
||||
* @param existingSocket Connected socket to use instead of creating a new one (internal use).
|
||||
*/
|
||||
connect(existingSocket?: Duplex): void;
|
||||
private getSocketOptions;
|
||||
/**
|
||||
* Handles internal Socks timeout callback.
|
||||
* Note: If the Socks client is not BoundWaitingForConnection or Established, the connection will be closed.
|
||||
*/
|
||||
private onEstablishedTimeout;
|
||||
/**
|
||||
* Handles Socket connect event.
|
||||
*/
|
||||
private onConnectHandler;
|
||||
/**
|
||||
* Handles Socket data event.
|
||||
* @param data
|
||||
*/
|
||||
private onDataReceivedHandler;
|
||||
/**
|
||||
* Handles processing of the data we have received.
|
||||
*/
|
||||
private processData;
|
||||
/**
|
||||
* Handles Socket close event.
|
||||
* @param had_error
|
||||
*/
|
||||
private onCloseHandler;
|
||||
/**
|
||||
* Handles Socket error event.
|
||||
* @param err
|
||||
*/
|
||||
private onErrorHandler;
|
||||
/**
|
||||
* Removes internal event listeners on the underlying Socket.
|
||||
*/
|
||||
private removeInternalSocketHandlers;
|
||||
/**
|
||||
* Closes and destroys the underlying Socket. Emits an error event.
|
||||
* @param err { String } An error string to include in error event.
|
||||
*/
|
||||
private closeSocket;
|
||||
/**
|
||||
* Sends initial Socks v4 handshake request.
|
||||
*/
|
||||
private sendSocks4InitialHandshake;
|
||||
/**
|
||||
* Handles Socks v4 handshake response.
|
||||
* @param data
|
||||
*/
|
||||
private handleSocks4FinalHandshakeResponse;
|
||||
/**
|
||||
* Handles Socks v4 incoming connection request (BIND)
|
||||
* @param data
|
||||
*/
|
||||
private handleSocks4IncomingConnectionResponse;
|
||||
/**
|
||||
* Sends initial Socks v5 handshake request.
|
||||
*/
|
||||
private sendSocks5InitialHandshake;
|
||||
/**
|
||||
* Handles initial Socks v5 handshake response.
|
||||
* @param data
|
||||
*/
|
||||
private handleInitialSocks5HandshakeResponse;
|
||||
/**
|
||||
* Sends Socks v5 user & password auth handshake.
|
||||
*
|
||||
* Note: No auth and user/pass are currently supported.
|
||||
*/
|
||||
private sendSocks5UserPassAuthentication;
|
||||
private sendSocks5CustomAuthentication;
|
||||
private handleSocks5CustomAuthHandshakeResponse;
|
||||
private handleSocks5AuthenticationNoAuthHandshakeResponse;
|
||||
private handleSocks5AuthenticationUserPassHandshakeResponse;
|
||||
/**
|
||||
* Handles Socks v5 auth handshake response.
|
||||
* @param data
|
||||
*/
|
||||
private handleInitialSocks5AuthenticationHandshakeResponse;
|
||||
/**
|
||||
* Sends Socks v5 final handshake request.
|
||||
*/
|
||||
private sendSocks5CommandRequest;
|
||||
/**
|
||||
* Handles Socks v5 final handshake response.
|
||||
* @param data
|
||||
*/
|
||||
private handleSocks5FinalHandshakeResponse;
|
||||
/**
|
||||
* Handles Socks v5 incoming connection request (BIND).
|
||||
*/
|
||||
private handleSocks5IncomingConnectionResponse;
|
||||
get socksClientOptions(): SocksClientOptions;
|
||||
}
|
||||
export { SocksClient, SocksClientOptions, SocksClientChainOptions, SocksClientError, SocksRemoteHost, SocksProxy, SocksUDPFrameDetails, };
|
152
node_modules/socks/typings/common/constants.d.ts
generated
vendored
Normal file
152
node_modules/socks/typings/common/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { Duplex } from 'stream';
|
||||
import { Socket, SocketConnectOpts } from 'net';
|
||||
import { RequireOnlyOne } from './util';
|
||||
declare const DEFAULT_TIMEOUT = 30000;
|
||||
declare type SocksProxyType = 4 | 5;
|
||||
declare const ERRORS: {
|
||||
InvalidSocksCommand: string;
|
||||
InvalidSocksCommandForOperation: string;
|
||||
InvalidSocksCommandChain: string;
|
||||
InvalidSocksClientOptionsDestination: string;
|
||||
InvalidSocksClientOptionsExistingSocket: string;
|
||||
InvalidSocksClientOptionsProxy: string;
|
||||
InvalidSocksClientOptionsTimeout: string;
|
||||
InvalidSocksClientOptionsProxiesLength: string;
|
||||
InvalidSocksClientOptionsCustomAuthRange: string;
|
||||
InvalidSocksClientOptionsCustomAuthOptions: string;
|
||||
NegotiationError: string;
|
||||
SocketClosed: string;
|
||||
ProxyConnectionTimedOut: string;
|
||||
InternalError: string;
|
||||
InvalidSocks4HandshakeResponse: string;
|
||||
Socks4ProxyRejectedConnection: string;
|
||||
InvalidSocks4IncomingConnectionResponse: string;
|
||||
Socks4ProxyRejectedIncomingBoundConnection: string;
|
||||
InvalidSocks5InitialHandshakeResponse: string;
|
||||
InvalidSocks5IntiailHandshakeSocksVersion: string;
|
||||
InvalidSocks5InitialHandshakeNoAcceptedAuthType: string;
|
||||
InvalidSocks5InitialHandshakeUnknownAuthType: string;
|
||||
Socks5AuthenticationFailed: string;
|
||||
InvalidSocks5FinalHandshake: string;
|
||||
InvalidSocks5FinalHandshakeRejected: string;
|
||||
InvalidSocks5IncomingConnectionResponse: string;
|
||||
Socks5ProxyRejectedIncomingBoundConnection: string;
|
||||
};
|
||||
declare const SOCKS_INCOMING_PACKET_SIZES: {
|
||||
Socks5InitialHandshakeResponse: number;
|
||||
Socks5UserPassAuthenticationResponse: number;
|
||||
Socks5ResponseHeader: number;
|
||||
Socks5ResponseIPv4: number;
|
||||
Socks5ResponseIPv6: number;
|
||||
Socks5ResponseHostname: (hostNameLength: number) => number;
|
||||
Socks4Response: number;
|
||||
};
|
||||
declare type SocksCommandOption = 'connect' | 'bind' | 'associate';
|
||||
declare enum SocksCommand {
|
||||
connect = 1,
|
||||
bind = 2,
|
||||
associate = 3
|
||||
}
|
||||
declare enum Socks4Response {
|
||||
Granted = 90,
|
||||
Failed = 91,
|
||||
Rejected = 92,
|
||||
RejectedIdent = 93
|
||||
}
|
||||
declare enum Socks5Auth {
|
||||
NoAuth = 0,
|
||||
GSSApi = 1,
|
||||
UserPass = 2
|
||||
}
|
||||
declare const SOCKS5_CUSTOM_AUTH_START = 128;
|
||||
declare const SOCKS5_CUSTOM_AUTH_END = 254;
|
||||
declare const SOCKS5_NO_ACCEPTABLE_AUTH = 255;
|
||||
declare enum Socks5Response {
|
||||
Granted = 0,
|
||||
Failure = 1,
|
||||
NotAllowed = 2,
|
||||
NetworkUnreachable = 3,
|
||||
HostUnreachable = 4,
|
||||
ConnectionRefused = 5,
|
||||
TTLExpired = 6,
|
||||
CommandNotSupported = 7,
|
||||
AddressNotSupported = 8
|
||||
}
|
||||
declare enum Socks5HostType {
|
||||
IPv4 = 1,
|
||||
Hostname = 3,
|
||||
IPv6 = 4
|
||||
}
|
||||
declare enum SocksClientState {
|
||||
Created = 0,
|
||||
Connecting = 1,
|
||||
Connected = 2,
|
||||
SentInitialHandshake = 3,
|
||||
ReceivedInitialHandshakeResponse = 4,
|
||||
SentAuthentication = 5,
|
||||
ReceivedAuthenticationResponse = 6,
|
||||
SentFinalHandshake = 7,
|
||||
ReceivedFinalResponse = 8,
|
||||
BoundWaitingForConnection = 9,
|
||||
Established = 10,
|
||||
Disconnected = 11,
|
||||
Error = 99
|
||||
}
|
||||
/**
|
||||
* Represents a SocksProxy
|
||||
*/
|
||||
declare type SocksProxy = RequireOnlyOne<{
|
||||
ipaddress?: string;
|
||||
host?: string;
|
||||
port: number;
|
||||
type: SocksProxyType;
|
||||
userId?: string;
|
||||
password?: string;
|
||||
custom_auth_method?: number;
|
||||
custom_auth_request_handler?: () => Promise<Buffer>;
|
||||
custom_auth_response_size?: number;
|
||||
custom_auth_response_handler?: (data: Buffer) => Promise<boolean>;
|
||||
}, 'host' | 'ipaddress'>;
|
||||
/**
|
||||
* Represents a remote host
|
||||
*/
|
||||
interface SocksRemoteHost {
|
||||
host: string;
|
||||
port: number;
|
||||
}
|
||||
/**
|
||||
* SocksClient connection options.
|
||||
*/
|
||||
interface SocksClientOptions {
|
||||
command: SocksCommandOption;
|
||||
destination: SocksRemoteHost;
|
||||
proxy: SocksProxy;
|
||||
timeout?: number;
|
||||
existing_socket?: Duplex;
|
||||
set_tcp_nodelay?: boolean;
|
||||
socket_options?: SocketConnectOpts;
|
||||
}
|
||||
/**
|
||||
* SocksClient chain connection options.
|
||||
*/
|
||||
interface SocksClientChainOptions {
|
||||
command: 'connect';
|
||||
destination: SocksRemoteHost;
|
||||
proxies: SocksProxy[];
|
||||
timeout?: number;
|
||||
randomizeChain?: false;
|
||||
}
|
||||
interface SocksClientEstablishedEvent {
|
||||
socket: Socket;
|
||||
remoteHost?: SocksRemoteHost;
|
||||
}
|
||||
declare type SocksClientBoundEvent = SocksClientEstablishedEvent;
|
||||
interface SocksUDPFrameDetails {
|
||||
frameNumber?: number;
|
||||
remoteHost: SocksRemoteHost;
|
||||
data: Buffer;
|
||||
}
|
||||
export { DEFAULT_TIMEOUT, ERRORS, SocksProxyType, SocksCommand, Socks4Response, Socks5Auth, Socks5HostType, Socks5Response, SocksClientState, SocksProxy, SocksRemoteHost, SocksCommandOption, SocksClientOptions, SocksClientChainOptions, SocksClientEstablishedEvent, SocksClientBoundEvent, SocksUDPFrameDetails, SOCKS_INCOMING_PACKET_SIZES, SOCKS5_CUSTOM_AUTH_START, SOCKS5_CUSTOM_AUTH_END, SOCKS5_NO_ACCEPTABLE_AUTH, };
|
13
node_modules/socks/typings/common/helpers.d.ts
generated
vendored
Normal file
13
node_modules/socks/typings/common/helpers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { SocksClientOptions, SocksClientChainOptions } from '../client/socksclient';
|
||||
/**
|
||||
* Validates the provided SocksClientOptions
|
||||
* @param options { SocksClientOptions }
|
||||
* @param acceptedCommands { string[] } A list of accepted SocksProxy commands.
|
||||
*/
|
||||
declare function validateSocksClientOptions(options: SocksClientOptions, acceptedCommands?: string[]): void;
|
||||
/**
|
||||
* Validates the SocksClientChainOptions
|
||||
* @param options { SocksClientChainOptions }
|
||||
*/
|
||||
declare function validateSocksClientChainOptions(options: SocksClientChainOptions): void;
|
||||
export { validateSocksClientOptions, validateSocksClientChainOptions };
|
12
node_modules/socks/typings/common/receivebuffer.d.ts
generated
vendored
Normal file
12
node_modules/socks/typings/common/receivebuffer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/// <reference types="node" />
|
||||
declare class ReceiveBuffer {
|
||||
private buffer;
|
||||
private offset;
|
||||
private originalSize;
|
||||
constructor(size?: number);
|
||||
get length(): number;
|
||||
append(data: Buffer): number;
|
||||
peek(length: number): Buffer;
|
||||
get(length: number): Buffer;
|
||||
}
|
||||
export { ReceiveBuffer };
|
17
node_modules/socks/typings/common/util.d.ts
generated
vendored
Normal file
17
node_modules/socks/typings/common/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { SocksClientOptions, SocksClientChainOptions } from './constants';
|
||||
/**
|
||||
* Error wrapper for SocksClient
|
||||
*/
|
||||
declare class SocksClientError extends Error {
|
||||
options: SocksClientOptions | SocksClientChainOptions;
|
||||
constructor(message: string, options: SocksClientOptions | SocksClientChainOptions);
|
||||
}
|
||||
/**
|
||||
* Shuffles a given array.
|
||||
* @param array The array to shuffle.
|
||||
*/
|
||||
declare function shuffleArray(array: unknown[]): void;
|
||||
declare type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
||||
[K in Keys]?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
|
||||
}[Keys];
|
||||
export { RequireOnlyOne, SocksClientError, shuffleArray };
|
1
node_modules/socks/typings/index.d.ts
generated
vendored
Normal file
1
node_modules/socks/typings/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './client/socksclient';
|
Reference in New Issue
Block a user