• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.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;
4const DEFAULT_TIMEOUT = 30000;
5exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
6// prettier-ignore
7const ERRORS = {
8    InvalidSocksCommand: 'An invalid SOCKS command was provided. Valid options are connect, bind, and associate.',
9    InvalidSocksCommandForOperation: 'An invalid SOCKS command was provided. Only a subset of commands are supported for this operation.',
10    InvalidSocksCommandChain: 'An invalid SOCKS command was provided. Chaining currently only supports the connect command.',
11    InvalidSocksClientOptionsDestination: 'An invalid destination host was provided.',
12    InvalidSocksClientOptionsExistingSocket: 'An invalid existing socket was provided. This should be an instance of stream.Duplex.',
13    InvalidSocksClientOptionsProxy: 'Invalid SOCKS proxy details were provided.',
14    InvalidSocksClientOptionsTimeout: 'An invalid timeout value was provided. Please enter a value above 0 (in ms).',
15    InvalidSocksClientOptionsProxiesLength: 'At least two socks proxies must be provided for chaining.',
16    InvalidSocksClientOptionsCustomAuthRange: 'Custom auth must be a value between 0x80 and 0xFE.',
17    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.',
18    NegotiationError: 'Negotiation error',
19    SocketClosed: 'Socket closed',
20    ProxyConnectionTimedOut: 'Proxy connection timed out',
21    InternalError: 'SocksClient internal error (this should not happen)',
22    InvalidSocks4HandshakeResponse: 'Received invalid Socks4 handshake response',
23    Socks4ProxyRejectedConnection: 'Socks4 Proxy rejected connection',
24    InvalidSocks4IncomingConnectionResponse: 'Socks4 invalid incoming connection response',
25    Socks4ProxyRejectedIncomingBoundConnection: 'Socks4 Proxy rejected incoming bound connection',
26    InvalidSocks5InitialHandshakeResponse: 'Received invalid Socks5 initial handshake response',
27    InvalidSocks5IntiailHandshakeSocksVersion: 'Received invalid Socks5 initial handshake (invalid socks version)',
28    InvalidSocks5InitialHandshakeNoAcceptedAuthType: 'Received invalid Socks5 initial handshake (no accepted authentication type)',
29    InvalidSocks5InitialHandshakeUnknownAuthType: 'Received invalid Socks5 initial handshake (unknown authentication type)',
30    Socks5AuthenticationFailed: 'Socks5 Authentication failed',
31    InvalidSocks5FinalHandshake: 'Received invalid Socks5 final handshake response',
32    InvalidSocks5FinalHandshakeRejected: 'Socks5 proxy rejected connection',
33    InvalidSocks5IncomingConnectionResponse: 'Received invalid Socks5 incoming connection response',
34    Socks5ProxyRejectedIncomingBoundConnection: 'Socks5 Proxy rejected incoming bound connection',
35};
36exports.ERRORS = ERRORS;
37const SOCKS_INCOMING_PACKET_SIZES = {
38    Socks5InitialHandshakeResponse: 2,
39    Socks5UserPassAuthenticationResponse: 2,
40    // Command response + incoming connection (bind)
41    Socks5ResponseHeader: 5, // We need at least 5 to read the hostname length, then we wait for the address+port information.
42    Socks5ResponseIPv4: 10, // 4 header + 4 ip + 2 port
43    Socks5ResponseIPv6: 22, // 4 header + 16 ip + 2 port
44    Socks5ResponseHostname: (hostNameLength) => hostNameLength + 7, // 4 header + 1 host length + host + 2 port
45    // Command response + incoming connection (bind)
46    Socks4Response: 8, // 2 header + 2 port + 4 ip
47};
48exports.SOCKS_INCOMING_PACKET_SIZES = SOCKS_INCOMING_PACKET_SIZES;
49var SocksCommand;
50(function (SocksCommand) {
51    SocksCommand[SocksCommand["connect"] = 1] = "connect";
52    SocksCommand[SocksCommand["bind"] = 2] = "bind";
53    SocksCommand[SocksCommand["associate"] = 3] = "associate";
54})(SocksCommand || (exports.SocksCommand = SocksCommand = {}));
55var Socks4Response;
56(function (Socks4Response) {
57    Socks4Response[Socks4Response["Granted"] = 90] = "Granted";
58    Socks4Response[Socks4Response["Failed"] = 91] = "Failed";
59    Socks4Response[Socks4Response["Rejected"] = 92] = "Rejected";
60    Socks4Response[Socks4Response["RejectedIdent"] = 93] = "RejectedIdent";
61})(Socks4Response || (exports.Socks4Response = Socks4Response = {}));
62var Socks5Auth;
63(function (Socks5Auth) {
64    Socks5Auth[Socks5Auth["NoAuth"] = 0] = "NoAuth";
65    Socks5Auth[Socks5Auth["GSSApi"] = 1] = "GSSApi";
66    Socks5Auth[Socks5Auth["UserPass"] = 2] = "UserPass";
67})(Socks5Auth || (exports.Socks5Auth = Socks5Auth = {}));
68const SOCKS5_CUSTOM_AUTH_START = 0x80;
69exports.SOCKS5_CUSTOM_AUTH_START = SOCKS5_CUSTOM_AUTH_START;
70const SOCKS5_CUSTOM_AUTH_END = 0xfe;
71exports.SOCKS5_CUSTOM_AUTH_END = SOCKS5_CUSTOM_AUTH_END;
72const SOCKS5_NO_ACCEPTABLE_AUTH = 0xff;
73exports.SOCKS5_NO_ACCEPTABLE_AUTH = SOCKS5_NO_ACCEPTABLE_AUTH;
74var Socks5Response;
75(function (Socks5Response) {
76    Socks5Response[Socks5Response["Granted"] = 0] = "Granted";
77    Socks5Response[Socks5Response["Failure"] = 1] = "Failure";
78    Socks5Response[Socks5Response["NotAllowed"] = 2] = "NotAllowed";
79    Socks5Response[Socks5Response["NetworkUnreachable"] = 3] = "NetworkUnreachable";
80    Socks5Response[Socks5Response["HostUnreachable"] = 4] = "HostUnreachable";
81    Socks5Response[Socks5Response["ConnectionRefused"] = 5] = "ConnectionRefused";
82    Socks5Response[Socks5Response["TTLExpired"] = 6] = "TTLExpired";
83    Socks5Response[Socks5Response["CommandNotSupported"] = 7] = "CommandNotSupported";
84    Socks5Response[Socks5Response["AddressNotSupported"] = 8] = "AddressNotSupported";
85})(Socks5Response || (exports.Socks5Response = Socks5Response = {}));
86var Socks5HostType;
87(function (Socks5HostType) {
88    Socks5HostType[Socks5HostType["IPv4"] = 1] = "IPv4";
89    Socks5HostType[Socks5HostType["Hostname"] = 3] = "Hostname";
90    Socks5HostType[Socks5HostType["IPv6"] = 4] = "IPv6";
91})(Socks5HostType || (exports.Socks5HostType = Socks5HostType = {}));
92var SocksClientState;
93(function (SocksClientState) {
94    SocksClientState[SocksClientState["Created"] = 0] = "Created";
95    SocksClientState[SocksClientState["Connecting"] = 1] = "Connecting";
96    SocksClientState[SocksClientState["Connected"] = 2] = "Connected";
97    SocksClientState[SocksClientState["SentInitialHandshake"] = 3] = "SentInitialHandshake";
98    SocksClientState[SocksClientState["ReceivedInitialHandshakeResponse"] = 4] = "ReceivedInitialHandshakeResponse";
99    SocksClientState[SocksClientState["SentAuthentication"] = 5] = "SentAuthentication";
100    SocksClientState[SocksClientState["ReceivedAuthenticationResponse"] = 6] = "ReceivedAuthenticationResponse";
101    SocksClientState[SocksClientState["SentFinalHandshake"] = 7] = "SentFinalHandshake";
102    SocksClientState[SocksClientState["ReceivedFinalResponse"] = 8] = "ReceivedFinalResponse";
103    SocksClientState[SocksClientState["BoundWaitingForConnection"] = 9] = "BoundWaitingForConnection";
104    SocksClientState[SocksClientState["Established"] = 10] = "Established";
105    SocksClientState[SocksClientState["Disconnected"] = 11] = "Disconnected";
106    SocksClientState[SocksClientState["Error"] = 99] = "Error";
107})(SocksClientState || (exports.SocksClientState = SocksClientState = {}));
108//# sourceMappingURL=constants.js.map