ÿØÿà JFIF    ÿÛ „ ( %!1!%*+...983,7(-.- PK R ]WCbuild/index.jsnu["use strict"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./client/socksclient")); //# sourceMappingURL=index.js.mapPK R ]͟Avvbuild/index.js.mapnu[{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,0CAAqC"}PK R ]h:BPBPbuild/client/socksclient.js.mapnu[{"version":3,"file":"socksclient.js","sourceRoot":"","sources":["../../src/client/socksclient.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mCAAsC;AACtC,2BAA2B;AAC3B,yBAAyB;AACzB,+CAA2C;AAC3C,mDAiB6B;AAC7B,+CAG2B;AAC3B,2DAAwD;AACxD,yCAAgE;AA0BhE,MAAM,WAAY,SAAQ,qBAAY;IAepC,YAAY,OAA2B;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,qBACR,OAAO,CACX,CAAC;QAEF,8BAA8B;QAC9B,oCAA0B,CAAC,OAAO,CAAC,CAAC;QAEpC,gBAAgB;QAChB,IAAI,CAAC,KAAK,GAAG,4BAAgB,CAAC,OAAO,CAAC;IACxC,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,gBAAgB,CACrB,OAA2B,EAC3B,QAAmB;QAEnB,8BAA8B;QAC9B,oCAA0B,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;QAEjD,OAAO,IAAI,OAAO,CAA8B,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAClE,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;YACxC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;YACxC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,IAAiC,EAAE,EAAE;gBAC/D,MAAM,CAAC,kBAAkB,E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BAAW,CAAC,UAAU,CAC3B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,iCAAiC;iBAC/E,CAAC;gBAEF,UAAU,GAAG;oBACX,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;oBACjC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE;iBAC1B,CAAC;gBACF,OAAO;aACR;iBAAM,IAAI,WAAW,KAAK,0BAAc,CAAC,IAAI,EAAE;gBAC9C,8BAA8B;gBAC9B,MAAM,UAAU,GAAG,uCAA2B,CAAC,kBAAkB,CAAC;gBAClE,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,UAAU,EAAE;oBAC3C,IAAI,CAAC,6BAA6B,GAAG,UAAU,CAAC;oBAChD,OAAO;iBACR;gBAED,IAAI,GAAG,0BAAW,CAAC,UAAU,CAC3B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAC7C,CAAC;gBAEF,UAAU,GAAG;oBACX,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;oBACtC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE;iBAC1B,CAAC;aACH;YAED,IAAI,CAAC,KAAK,GAAG,4BAAgB,CAAC,WAAW,CAAC;YAC1C,IAAI,CAAC,4BAA4B,EAAE,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;SAChE;IACH,CAAC;IAED,IAAI,kBAAkB;QACpB,yBACK,IAAI,CAAC,QAAQ,EAChB;IACJ,CAAC;CACF;AAGC,kCAAW"}PK R ]ᩀ{{build/client/socksclient.jsnu["use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const events_1 = require("events"); const net = require("net"); const ip = require("ip"); const smart_buffer_1 = require("smart-buffer"); const constants_1 = require("../common/constants"); const helpers_1 = require("../common/helpers"); const receivebuffer_1 = require("../common/receivebuffer"); const util_1 = require("../common/util"); class SocksClient extends events_1.EventEmitter { constructor(options) { super(); this._options = Object.assign({}, options); // Validate SocksClientOptions helpers_1.validateSocksClientOptions(options); // Default state this.state = constants_1.SocksClientState.Created; } /** * 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, callback) { // Validate SocksClientOptions helpers_1.validateSocksClientOptions(options, ['connect']); return new Promise((resolve, reject) => { const client = new SocksClient(options); client.connect(options.existing_socket); client.once('established', (info) => { client.removeAllListeners(); if (typeof callback === 'function') { callback(null, info); resolve(); // Resolves pending promise (prevents memory leaks). } else { resolve(info); } }); // Error occurred, failed to establish connection. client.once('error', (err) => { client.removeAllListeners(); if (typeof callback === 'function') { callback(err); resolve(); // Resolves pending promise (prevents memory leaks). } else { reject(err); } }); }); } /** * 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, callback) { // Validate SocksClientChainOptions helpers_1.validateSocksClientChainOptions(options); // Shuffle proxies if (options.randomizeChain) { util_1.shuffleArray(options.proxies); } return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { let sock; try { for (let i = 0; i < options.proxies.length; i++) { const nextProxy = options.proxies[i]; // If we've reached the last proxy in the chain, the destination is the actual destination, otherwise it's the next proxy. const nextDestination = i === options.proxies.length - 1 ? options.destination : { host: options.proxies[i + 1].ipaddress, port: options.proxies[i + 1].port }; // Creates the next connection in the chain. const result = yield SocksClient.createConnection({ command: 'connect', proxy: nextProxy, destination: nextDestination // Initial connection ignores this as sock is undefined. Subsequent connections re-use the first proxy socket to form a chain. }); // If sock is undefined, assign it here. if (!sock) { sock = result.socket; } } if (typeof callback === 'function') { callback(null, { socket: sock }); resolve(); // Resolves pending promise (prevents memory leaks). } else { resolve({ socket: sock }); } } catch (err) { if (typeof callback === 'function') { callback(err); resolve(); // Resolves pending promise (prevents memory leaks). } else { reject(err); } } })); } /** * Creates a SOCKS UDP Frame. * @param options */ static createUDPFrame(options) { const buff = new smart_buffer_1.SmartBuffer(); buff.writeUInt16BE(0); buff.writeUInt8(options.frameNumber || 0); // IPv4/IPv6/Hostname if (net.isIPv4(options.remoteHost.host)) { buff.writeUInt8(constants_1.Socks5HostType.IPv4); buff.writeUInt32BE(ip.toLong(options.remoteHost.host)); } else if (net.isIPv6(options.remoteHost.host)) { buff.writeUInt8(constants_1.Socks5HostType.IPv6); buff.writeBuffer(ip.toBuffer(options.remoteHost.host)); } else { buff.writeUInt8(constants_1.Socks5HostType.Hostname); buff.writeUInt8(Buffer.byteLength(options.remoteHost.host)); buff.writeString(options.remoteHost.host); } // Port buff.writeUInt16BE(options.remoteHost.port); // Data buff.writeBuffer(options.data); return buff.toBuffer(); } /** * Parses a SOCKS UDP frame. * @param data */ static parseUDPFrame(data) { const buff = smart_buffer_1.SmartBuffer.fromBuffer(data); buff.readOffset = 2; const frameNumber = buff.readUInt8(); const hostType = buff.readUInt8(); let remoteHost; if (hostType === constants_1.Socks5HostType.IPv4) { remoteHost = ip.fromLong(buff.readUInt32BE()); } else if (hostType === constants_1.Socks5HostType.IPv6) { remoteHost = ip.toString(buff.readBuffer(16)); } else { remoteHost = buff.readString(buff.readUInt8()); } const remotePort = buff.readUInt16BE(); return { frameNumber, remoteHost: { host: remoteHost, port: remotePort }, data: buff.readBuffer() }; } /** * Gets the SocksClient internal state. */ get state() { return this._state; } /** * Internal state setter. If the SocksClient is in an error state, it cannot be changed to a non error state. */ set state(newState) { if (this._state !== constants_1.SocksClientState.Error) { this._state = newState; } } /** * Starts the connection establishment to the proxy and destination. * @param existing_socket Connected socket to use instead of creating a new one (internal use). */ connect(existing_socket) { this._onDataReceived = (data) => this.onDataReceived(data); this._onClose = () => this.onClose(); this._onError = (err) => this.onError(err); this._onConnect = () => this.onConnect(); // Start timeout timer (defaults to 30 seconds) const timer = setTimeout(() => this.onEstablishedTimeout(), this._options.timeout || constants_1.DEFAULT_TIMEOUT); // check whether unref is available as it differs from browser to NodeJS (#33) if (timer.unref && typeof timer.unref === 'function') { timer.unref(); } // If an existing socket is provided, use it to negotiate SOCKS handshake. Otherwise create a new Socket. if (existing_socket) { this._socket = existing_socket; } else { this._socket = new net.Socket(); } // Attach Socket error handlers. this._socket.once('close', this._onClose); this._socket.once('error', this._onError); this._socket.once('connect', this._onConnect); this._socket.on('data', this._onDataReceived); this.state = constants_1.SocksClientState.Connecting; this._receiveBuffer = new receivebuffer_1.ReceiveBuffer(); if (existing_socket) { this._socket.emit('connect'); } else { this._socket.connect(this.getSocketOptions()); if (this._options.set_tcp_nodelay !== undefined && this._options.set_tcp_nodelay !== null) { this._socket.setNoDelay(!!this._options.set_tcp_nodelay); } } // Listen for established event so we can re-emit any excess data received during handshakes. this.prependOnceListener('established', info => { setImmediate(() => { if (this._receiveBuffer.length > 0) { const excessData = this._receiveBuffer.get(this._receiveBuffer.length); info.socket.emit('data', excessData); } info.socket.resume(); }); }); } // Socket options (defaults host/port to options.proxy.host/options.proxy.port) getSocketOptions() { return Object.assign(Object.assign({}, this._options.socket_options), { host: this._options.proxy.host || this._options.proxy.ipaddress, port: this._options.proxy.port }); } /** * Handles internal Socks timeout callback. * Note: If the Socks client is not BoundWaitingForConnection or Established, the connection will be closed. */ onEstablishedTimeout() { if (this.state !== constants_1.SocksClientState.Established && this.state !== constants_1.SocksClientState.BoundWaitingForConnection) { this._closeSocket(constants_1.ERRORS.ProxyConnectionTimedOut); } } /** * Handles Socket connect event. */ onConnect() { this.state = constants_1.SocksClientState.Connected; // Send initial handshake. if (this._options.proxy.type === 4) { this.sendSocks4InitialHandshake(); } else { this.sendSocks5InitialHandshake(); } this.state = constants_1.SocksClientState.SentInitialHandshake; } /** * Handles Socket data event. * @param data */ onDataReceived(data) { /* All received data is appended to a ReceiveBuffer. This makes sure that all the data we need is received before we attempt to process it. */ this._receiveBuffer.append(data); // Process data that we have. this.processData(); } /** * Handles processing of the data we have received. */ processData() { // If we have enough data to process the next step in the SOCKS handshake, proceed. if (this._receiveBuffer.length >= this._nextRequiredPacketBufferSize) { // Sent initial handshake, waiting for response. if (this.state === constants_1.SocksClientState.SentInitialHandshake) { if (this._options.proxy.type === 4) { // Socks v4 only has one handshake response. this.handleSocks4FinalHandshakeResponse(); } else { // Socks v5 has two handshakes, handle initial one here. this.handleInitialSocks5HandshakeResponse(); } // Sent auth request for Socks v5, waiting for response. } else if (this.state === constants_1.SocksClientState.SentAuthentication) { this.handleInitialSocks5AuthenticationHandshakeResponse(); // Sent final Socks v5 handshake, waiting for final response. } else if (this.state === constants_1.SocksClientState.SentFinalHandshake) { this.handleSocks5FinalHandshakeResponse(); // Socks BIND established. Waiting for remote connection via proxy. } else if (this.state === constants_1.SocksClientState.BoundWaitingForConnection) { if (this._options.proxy.type === 4) { this.handleSocks4IncomingConnectionResponse(); } else { this.handleSocks5IncomingConnectionResponse(); } } else if (this.state === constants_1.SocksClientState.Established) { // do nothing (prevents closing of the socket) } else { this._closeSocket(constants_1.ERRORS.InternalError); } } } /** * Handles Socket close event. * @param had_error */ onClose() { this._closeSocket(constants_1.ERRORS.SocketClosed); } /** * Handles Socket error event. * @param err */ onError(err) { this._closeSocket(err.message); } /** * Removes internal event listeners on the underlying Socket. */ removeInternalSocketHandlers() { // Pauses data flow of the socket (this is internally resumed after 'established' is emitted) this._socket.pause(); this._socket.removeListener('data', this._onDataReceived); this._socket.removeListener('close', this._onClose); this._socket.removeListener('error', this._onError); this._socket.removeListener('connect', this.onConnect); } /** * Closes and destroys the underlying Socket. Emits an error event. * @param err { String } An error string to include in error event. */ _closeSocket(err) { // Make sure only one 'error' event is fired for the lifetime of this SocksClient instance. if (this.state !== constants_1.SocksClientState.Error) { // Set internal state to Error. this.state = constants_1.SocksClientState.Error; // Destroy Socket this._socket.destroy(); // Remove internal listeners this.removeInternalSocketHandlers(); // Fire 'error' event. this.emit('error', new util_1.SocksClientError(err, this._options)); } } /** * Sends initial Socks v4 handshake request. */ sendSocks4InitialHandshake() { const userId = this._options.proxy.userId || ''; const buff = new smart_buffer_1.SmartBuffer(); buff.writeUInt8(0x04); buff.writeUInt8(constants_1.SocksCommand[this._options.command]); buff.writeUInt16BE(this._options.destination.port); // Socks 4 (IPv4) if (net.isIPv4(this._options.destination.host)) { buff.writeBuffer(ip.toBuffer(this._options.destination.host)); buff.writeStringNT(userId); // Socks 4a (hostname) } else { buff.writeUInt8(0x00); buff.writeUInt8(0x00); buff.writeUInt8(0x00); buff.writeUInt8(0x01); buff.writeStringNT(userId); buff.writeStringNT(this._options.destination.host); } this._nextRequiredPacketBufferSize = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks4Response; this._socket.write(buff.toBuffer()); } /** * Handles Socks v4 handshake response. * @param data */ handleSocks4FinalHandshakeResponse() { const data = this._receiveBuffer.get(8); if (data[1] !== constants_1.Socks4Response.Granted) { this._closeSocket(`${constants_1.ERRORS.Socks4ProxyRejectedConnection} - (${constants_1.Socks4Response[data[1]]})`); } else { // Bind response if (constants_1.SocksCommand[this._options.command] === constants_1.SocksCommand.bind) { const buff = smart_buffer_1.SmartBuffer.fromBuffer(data); buff.readOffset = 2; const remoteHost = { port: buff.readUInt16BE(), host: ip.fromLong(buff.readUInt32BE()) }; // If host is 0.0.0.0, set to proxy host. if (remoteHost.host === '0.0.0.0') { remoteHost.host = this._options.proxy.ipaddress; } this.state = constants_1.SocksClientState.BoundWaitingForConnection; this.emit('bound', { socket: this._socket, remoteHost }); // Connect response } else { this.state = constants_1.SocksClientState.Established; this.removeInternalSocketHandlers(); this.emit('established', { socket: this._socket }); } } } /** * Handles Socks v4 incoming connection request (BIND) * @param data */ handleSocks4IncomingConnectionResponse() { const data = this._receiveBuffer.get(8); if (data[1] !== constants_1.Socks4Response.Granted) { this._closeSocket(`${constants_1.ERRORS.Socks4ProxyRejectedIncomingBoundConnection} - (${constants_1.Socks4Response[data[1]]})`); } else { const buff = smart_buffer_1.SmartBuffer.fromBuffer(data); buff.readOffset = 2; const remoteHost = { port: buff.readUInt16BE(), host: ip.fromLong(buff.readUInt32BE()) }; this.state = constants_1.SocksClientState.Established; this.removeInternalSocketHandlers(); this.emit('established', { socket: this._socket, remoteHost }); } } /** * Sends initial Socks v5 handshake request. */ sendSocks5InitialHandshake() { const buff = new smart_buffer_1.SmartBuffer(); buff.writeUInt8(0x05); // We should only tell the proxy we support user/pass auth if auth info is actually provided. // Note: As of Tor v0.3.5.7+, if user/pass auth is an option from the client, by default it will always take priority. if (this._options.proxy.userId || this._options.proxy.password) { buff.writeUInt8(2); buff.writeUInt8(constants_1.Socks5Auth.NoAuth); buff.writeUInt8(constants_1.Socks5Auth.UserPass); } else { buff.writeUInt8(1); buff.writeUInt8(constants_1.Socks5Auth.NoAuth); } this._nextRequiredPacketBufferSize = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5InitialHandshakeResponse; this._socket.write(buff.toBuffer()); this.state = constants_1.SocksClientState.SentInitialHandshake; } /** * Handles initial Socks v5 handshake response. * @param data */ handleInitialSocks5HandshakeResponse() { const data = this._receiveBuffer.get(2); if (data[0] !== 0x05) { this._closeSocket(constants_1.ERRORS.InvalidSocks5IntiailHandshakeSocksVersion); } else if (data[1] === 0xff) { this._closeSocket(constants_1.ERRORS.InvalidSocks5InitialHandshakeNoAcceptedAuthType); } else { // If selected Socks v5 auth method is no auth, send final handshake request. if (data[1] === constants_1.Socks5Auth.NoAuth) { this.sendSocks5CommandRequest(); // If selected Socks v5 auth method is user/password, send auth handshake. } else if (data[1] === constants_1.Socks5Auth.UserPass) { this.sendSocks5UserPassAuthentication(); } else { this._closeSocket(constants_1.ERRORS.InvalidSocks5InitialHandshakeUnknownAuthType); } } } /** * Sends Socks v5 user & password auth handshake. * * Note: No auth and user/pass are currently supported. */ sendSocks5UserPassAuthentication() { const userId = this._options.proxy.userId || ''; const password = this._options.proxy.password || ''; const buff = new smart_buffer_1.SmartBuffer(); buff.writeUInt8(0x01); buff.writeUInt8(Buffer.byteLength(userId)); buff.writeString(userId); buff.writeUInt8(Buffer.byteLength(password)); buff.writeString(password); this._nextRequiredPacketBufferSize = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5UserPassAuthenticationResponse; this._socket.write(buff.toBuffer()); this.state = constants_1.SocksClientState.SentAuthentication; } /** * Handles Socks v5 auth handshake response. * @param data */ handleInitialSocks5AuthenticationHandshakeResponse() { this.state = constants_1.SocksClientState.ReceivedAuthenticationResponse; const data = this._receiveBuffer.get(2); if (data[1] !== 0x00) { this._closeSocket(constants_1.ERRORS.Socks5AuthenticationFailed); } else { this.sendSocks5CommandRequest(); } } /** * Sends Socks v5 final handshake request. */ sendSocks5CommandRequest() { const buff = new smart_buffer_1.SmartBuffer(); buff.writeUInt8(0x05); buff.writeUInt8(constants_1.SocksCommand[this._options.command]); buff.writeUInt8(0x00); // ipv4, ipv6, domain? if (net.isIPv4(this._options.destination.host)) { buff.writeUInt8(constants_1.Socks5HostType.IPv4); buff.writeBuffer(ip.toBuffer(this._options.destination.host)); } else if (net.isIPv6(this._options.destination.host)) { buff.writeUInt8(constants_1.Socks5HostType.IPv6); buff.writeBuffer(ip.toBuffer(this._options.destination.host)); } else { buff.writeUInt8(constants_1.Socks5HostType.Hostname); buff.writeUInt8(this._options.destination.host.length); buff.writeString(this._options.destination.host); } buff.writeUInt16BE(this._options.destination.port); this._nextRequiredPacketBufferSize = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader; this._socket.write(buff.toBuffer()); this.state = constants_1.SocksClientState.SentFinalHandshake; } /** * Handles Socks v5 final handshake response. * @param data */ handleSocks5FinalHandshakeResponse() { // Peek at available data (we need at least 5 bytes to get the hostname length) const header = this._receiveBuffer.peek(5); if (header[0] !== 0x05 || header[1] !== constants_1.Socks5Response.Granted) { this._closeSocket(`${constants_1.ERRORS.InvalidSocks5FinalHandshakeRejected} - ${constants_1.Socks5Response[header[1]]}`); } else { // Read address type const addressType = header[3]; let remoteHost; let buff; // IPv4 if (addressType === constants_1.Socks5HostType.IPv4) { // Check if data is available. const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4; if (this._receiveBuffer.length < dataNeeded) { this._nextRequiredPacketBufferSize = dataNeeded; return; } buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(4)); remoteHost = { host: ip.fromLong(buff.readUInt32BE()), port: buff.readUInt16BE() }; // If given host is 0.0.0.0, assume remote proxy ip instead. if (remoteHost.host === '0.0.0.0') { remoteHost.host = this._options.proxy.ipaddress; } // Hostname } else if (addressType === constants_1.Socks5HostType.Hostname) { const hostLength = header[4]; const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(hostLength); // header + host length + host + port // Check if data is available. if (this._receiveBuffer.length < dataNeeded) { this._nextRequiredPacketBufferSize = dataNeeded; return; } buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(5) // Slice at 5 to skip host length ); remoteHost = { host: buff.readString(hostLength), port: buff.readUInt16BE() }; // IPv6 } else if (addressType === constants_1.Socks5HostType.IPv6) { // Check if data is available. const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6; if (this._receiveBuffer.length < dataNeeded) { this._nextRequiredPacketBufferSize = dataNeeded; return; } buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(4)); remoteHost = { host: ip.toString(buff.readBuffer(16)), port: buff.readUInt16BE() }; } // We have everything we need this.state = constants_1.SocksClientState.ReceivedFinalResponse; // If using CONNECT, the client is now in the established state. if (constants_1.SocksCommand[this._options.command] === constants_1.SocksCommand.connect) { this.state = constants_1.SocksClientState.Established; this.removeInternalSocketHandlers(); this.emit('established', { socket: this._socket }); } else if (constants_1.SocksCommand[this._options.command] === constants_1.SocksCommand.bind) { /* If using BIND, the Socks client is now in BoundWaitingForConnection state. This means that the remote proxy server is waiting for a remote connection to the bound port. */ this.state = constants_1.SocksClientState.BoundWaitingForConnection; this._nextRequiredPacketBufferSize = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader; this.emit('bound', { socket: this._socket, remoteHost }); /* If using Associate, the Socks client is now Established. And the proxy server is now accepting UDP packets at the given bound port. This initial Socks TCP connection must remain open for the UDP relay to continue to work. */ } else if (constants_1.SocksCommand[this._options.command] === constants_1.SocksCommand.associate) { this.state = constants_1.SocksClientState.Established; this.removeInternalSocketHandlers(); this.emit('established', { socket: this._socket, remoteHost }); } } } /** * Handles Socks v5 incoming connection request (BIND). */ handleSocks5IncomingConnectionResponse() { // Peek at available data (we need at least 5 bytes to get the hostname length) const header = this._receiveBuffer.peek(5); if (header[0] !== 0x05 || header[1] !== constants_1.Socks5Response.Granted) { this._closeSocket(`${constants_1.ERRORS.Socks5ProxyRejectedIncomingBoundConnection} - ${constants_1.Socks5Response[header[1]]}`); } else { // Read address type const addressType = header[3]; let remoteHost; let buff; // IPv4 if (addressType === constants_1.Socks5HostType.IPv4) { // Check if data is available. const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4; if (this._receiveBuffer.length < dataNeeded) { this._nextRequiredPacketBufferSize = dataNeeded; return; } buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(4)); remoteHost = { host: ip.fromLong(buff.readUInt32BE()), port: buff.readUInt16BE() }; // If given host is 0.0.0.0, assume remote proxy ip instead. if (remoteHost.host === '0.0.0.0') { remoteHost.host = this._options.proxy.ipaddress; } // Hostname } else if (addressType === constants_1.Socks5HostType.Hostname) { const hostLength = header[4]; const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(hostLength); // header + host length + port // Check if data is available. if (this._receiveBuffer.length < dataNeeded) { this._nextRequiredPacketBufferSize = dataNeeded; return; } buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(5) // Slice at 5 to skip host length ); remoteHost = { host: buff.readString(hostLength), port: buff.readUInt16BE() }; // IPv6 } else if (addressType === constants_1.Socks5HostType.IPv6) { // Check if data is available. const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6; if (this._receiveBuffer.length < dataNeeded) { this._nextRequiredPacketBufferSize = dataNeeded; return; } buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(4)); remoteHost = { host: ip.toString(buff.readBuffer(16)), port: buff.readUInt16BE() }; } this.state = constants_1.SocksClientState.Established; this.removeInternalSocketHandlers(); this.emit('established', { socket: this._socket, remoteHost }); } } get socksClientOptions() { return Object.assign({}, this._options); } } exports.SocksClient = SocksClient; //# sourceMappingURL=socksclient.js.mapPK R ] 6build/common/receivebuffer.jsnu["use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 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.mapPK R ]פ3build/common/constants.js.mapnu[{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":";;AAIA,MAAM,eAAe,GAAG,KAAK,CAAC;AA6L5B,0CAAe;AAzLjB,kBAAkB;AAClB,MAAM,MAAM,GAAG;IACb,mBAAmB,EAAE,wFAAwF;IAC7G,+BAA+B,EAAE,oGAAoG;IACrI,wBAAwB,EAAE,8FAA8F;IACxH,oCAAoC,EAAE,2CAA2C;IACjF,uCAAuC,EAAE,uFAAuF;IAChI,8BAA8B,EAAE,4CAA4C;IAC5E,gCAAgC,EAAE,8EAA8E;IAChH,sCAAsC,EAAE,2DAA2D;IACnG,gBAAgB,EAAE,mBAAmB;IACrC,YAAY,EAAE,eAAe;IAC7B,uBAAuB,EAAE,4BAA4B;IACrD,aAAa,EAAE,qDAAqD;IACpE,8BAA8B,EAAE,4CAA4C;IAC5E,6BAA6B,EAAE,kCAAkC;IACjE,uCAAuC,EAAE,6CAA6C;IACtF,0CAA0C,EAAE,iDAAiD;IAC7F,qCAAqC,EAAE,oDAAoD;IAC3F,yCAAyC,EAAE,mEAAmE;IAC9G,+CAA+C,EAAE,6EAA6E;IAC9H,4CAA4C,EAAE,yEAAyE;IACvH,0BAA0B,EAAE,8BAA8B;IAC1D,2BAA2B,EAAE,kDAAkD;IAC/E,mCAAmC,EAAE,kCAAkC;IACvE,uCAAuC,EAAE,sDAAsD;IAC/F,0CAA0C,E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c,KAAd,cAAc,QAIlB;AAiHC,wCAAc;AA/GhB,IAAK,gBAcJ;AAdD,WAAK,gBAAgB;IACnB,6DAAW,CAAA;IACX,mEAAc,CAAA;IACd,iEAAa,CAAA;IACb,uFAAwB,CAAA;IACxB,+GAAoC,CAAA;IACpC,mFAAsB,CAAA;IACtB,2GAAkC,CAAA;IAClC,mFAAsB,CAAA;IACtB,yFAAyB,CAAA;IACzB,iGAA6B,CAAA;IAC7B,sEAAgB,CAAA;IAChB,wEAAiB,CAAA;IACjB,0DAAU,CAAA;AACZ,CAAC,EAdI,gBAAgB,KAAhB,gBAAgB,QAcpB;AAmGC,4CAAgB"}PK R ]1GDD!build/common/receivebuffer.js.mapnu[{"version":3,"file":"receivebuffer.js","sourceRoot":"","sources":["../../src/common/receivebuffer.ts"],"names":[],"mappings":";;AAAA,MAAM,aAAa;IAKjB,YAAY,OAAe,IAAI;QAC7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YAC1B,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;SACH;QAED,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACrD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC;YACzB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CAC/B,IAAI,CAAC,GAAG,CACN,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,EACxC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAClC,CACF,CAAC;YACF,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACxB;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,CAAC,MAAc;QACjB,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE;YACzB,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;SACH;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,GAAG,CAAC,MAAc;QAChB,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE;YACzB,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;SACH;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;QACnE,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC;QAEvB,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAEQ,sCAAa"}PK R ]Kc build/common/helpers.js.mapnu[{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/common/helpers.ts"],"names":[],"mappings":";;AAKA,iCAA0C;AAC1C,2CAA+D;AAC/D,iCAAiC;AAEjC;;;;GAIG;AACH,SAAS,0BAA0B,CACjC,OAA2B,EAC3B,gBAAgB,GAAG,CAAC,SAAS,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C1C,OAAO,CACL,KAAK;QACL,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ,CAAC;QACvE,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,KAAK,CAAC,IAAI,IAAI,CAAC;QACf,KAAK,CAAC,IAAI,IAAI,KAAK;QACnB,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CACvC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC,CAAC;AAChD,CAAC"}PK R ]ö76~~build/common/util.jsnu["use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * 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--) { let j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; } } exports.shuffleArray = shuffleArray; //# sourceMappingURL=util.js.mapPK R ]DTbuild/common/util.js.mapnu[{"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;AAuBwB,4CAAgB;AArBzC;;;GAGG;AACH,SAAS,YAAY,CAAC,KAAY;IAChC,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACzC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5C,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;AAY0C,oCAAY"}PK R ]_*^^build/common/constants.jsnu["use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 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.', 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; 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.mapPK R ]hhbuild/common/helpers.jsnu["use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 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); } // 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); } }); // Check timeout if (options.timeout && !isValidTimeoutValue(options.timeout)) { throw new util_1.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsTimeout, options); } } exports.validateSocksClientChainOptions = validateSocksClientChainOptions; /** * 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.mapPK R ]Q&{E E docs/migratingFromV1.mdnu[# 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 // 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: , 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: , 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); // (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(); ```PK R ]f ,docs/examples/typescript/associateExample.mdnu[# 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: // 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: , 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(); ``` PK R ]h=::*docs/examples/typescript/connectExample.mdnu[# 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); // (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); // (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); // (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); // (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(); ```PK R ]l 'docs/examples/javascript/bindExample.mdnu[# 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: , 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: , 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); // (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 }); ```PK R ] ,docs/examples/javascript/associateExample.mdnu[# 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: // 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: , 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 }); ``` PK R ]:*docs/examples/javascript/connectExample.mdnu[# 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); // (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); // (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); // (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); // (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 }); ```PK R ]6 TT.prettierrc.yamlnu[parser: typescript printWidth: 80 tabWidth: 2 singleQuote: true trailingComma: none PK R ]7xR::LICENSEnu[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. PK R ]sVV README.mdnu[# socks [![Build Status](https://travis-ci.org/JoshGlazebrook/socks.svg?branch=master)](https://travis-ci.org/JoshGlazebrook/socks) [![Coverage Status](https://coveralls.io/repos/github/JoshGlazebrook/socks/badge.svg?branch=master)](https://coveralls.io/github/JoshGlazebrook/socks?branch=v2) Fully featured SOCKS proxy client supporting SOCKSv4, SOCKSv4a, and SOCKSv5. Includes Bind and Associate functionality. ### Features * Supports SOCKS v4, v4a, and v5 protocols. * Supports the CONNECT, BIND, and ASSOCIATE commands. * Supports callbacks, promises, and events for proxy connection creation async flow control. * Supports proxy chaining (CONNECT only). * Supports user/pass authentication. * Built in UDP frame creation & parse functions. * Created with TypeScript, type definitions are provided. ### Requirements * Node.js v6.0+ (Please use [v1](https://github.com/JoshGlazebrook/socks/tree/82d83923ad960693d8b774cafe17443ded7ed584) for older versions of Node.js) ### Looking for v1? * Docs for v1 are available [here](https://github.com/JoshGlazebrook/socks/tree/82d83923ad960693d8b774cafe17443ded7ed584) ## Installation `yarn add socks` or `npm install --save socks` ## Usage ```typescript // TypeScript import { SocksClient, SocksClientOptions, SocksClientChainOptions } from 'socks'; // ES6 JavaScript import { SocksClient } from 'socks'; // Legacy JavaScript const SocksClient = require('socks').SocksClient; ``` ## Quick Start Example Connect to github.com (192.30.253.113) on port 80, using a SOCKS proxy. ```javascript const options = { proxy: { host: '159.203.75.200', // ipv4 or ipv6 or hostname port: 1080, type: 5 // Proxy version (4 or 5) }, command: 'connect', // SOCKS command (createConnection factory function only supports the connect command) destination: { host: '192.30.253.113', // github.com (hostname lookups are supported with SOCKS v4a and 5) port: 80 } }; // Async/Await try { const info = await SocksClient.createConnection(options); console.log(info.socket); // (this is a raw net.Socket that is established to the destination host through the given proxy server) } catch (err) { // Handle errors } // Promises SocksClient.createConnection(options) .then(info => { console.log(info.socket); // (this is a raw net.Socket that is established to the destination host through the given proxy server) }) .catch(err => { // Handle errors }); // Callbacks SocksClient.createConnection(options, (err, info) => { if (!err) { console.log(info.socket); // (this is a raw net.Socket that is established to the destination host through the given proxy server) } else { // Handle errors } }); ``` ## Chaining Proxies **Note:** Chaining is only supported when using the SOCKS connect command, and chaining can only be done through the special factory chaining function. This example makes a proxy chain through two SOCKS proxies to ip-api.com. Once the connection to the destination is established it sends an HTTP request to get a JSON response that returns ip info for the requesting ip. ```javascript const options = { destination: { host: 'ip-api.com', // host names are supported with SOCKS v4a and SOCKS v5. port: 80 }, command: 'connect', // Only the connect command is supported when chaining proxies. proxies: [ // The chain order is the order in the proxies array, meaning the last proxy will establish a connection to the destination. { host: '159.203.75.235', // ipv4, ipv6, or hostname port: 1081, type: 5 }, { host: '104.131.124.203', // ipv4, ipv6, or hostname port: 1081, type: 5 } ] } // Async/Await try { const info = await SocksClient.createConnectionChain(options); console.log(info.socket); // (this is a raw net.Socket that is established to the destination host through the given proxy servers) console.log(info.socket.remoteAddress) // The remote address of the returned socket is the first proxy in the chain. // 159.203.75.235 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 in the chain (104.131.124.203) is connected to it. /* 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 } // Promises SocksClient.createConnectionChain(options) .then(info => { console.log(info.socket); // (this is a raw net.Socket that is established to the destination host through the given proxy server) console.log(info.socket.remoteAddress) // The remote address of the returned socket is the first proxy in the chain. // 159.203.75.235 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 in the chain (104.131.124.203) is connected to it. /* 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 }); // Callbacks SocksClient.createConnectionChain(options, (err, info) => { if (!err) { console.log(info.socket); // (this is a raw net.Socket that is established to the destination host through the given proxy server) console.log(info.socket.remoteAddress) // The remote address of the returned socket is the first proxy in the chain. // 159.203.75.235 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 in the chain (104.131.124.203) is connected to it. /* 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" } */ }); } else { // Handle errors } }); ``` ## Bind Example (TCP Relay) When the bind command is sent to a SOCKS v4/v5 proxy server, the proxy server starts listening on a new TCP port and the proxy relays then remote host information back to the client. When another remote client connects to the proxy server on this port the SOCKS proxy sends a notification that an incoming connection has been accepted to the initial client and a full duplex stream is now established to the initial client and the client that connected to that special port. ```javascript const options = { proxy: { host: '159.203.75.235', // ipv4, ipv6, or hostname port: 1081, type: 5 }, command: 'bind', // When using BIND, the destination should be the remote client that is expected to connect to the SOCKS proxy. Using 0.0.0.0 makes the Proxy accept any incoming connection on that port. destination: { host: '0.0.0.0', port: 0 } }; // Creates a new SocksClient instance. const client = new SocksClient(options); // When the SOCKS proxy has bound a new port and started listening, this event is fired. client.on('bound', info => { console.log(info.remoteHost); /* { host: "159.203.75.235", port: 57362 } */ }); // When a client connects to the newly bound port on the SOCKS proxy, this event is fired. client.on('established', info => { // info.remoteHost is the remote address of the client that connected to the SOCKS proxy. console.log(info.remoteHost); /* host: 67.171.34.23, port: 49823 */ console.log(info.socket); // (This is a raw net.Socket that is a connection between the initial client and the remote client that connected to the proxy) // Handle received data... info.socket.on('data', data => { console.log('recv', data); }); }); // An error occurred trying to establish this SOCKS connection. client.on('error', err => { console.error(err); }); // Start connection to proxy client.connect(); ``` ## Associate Example (UDP Relay) When the associate command is sent to a SOCKS v5 proxy server, it sets up a UDP relay that allows the client to send UDP packets to a remote host through the proxy server, and also receive UDP packet responses back through the proxy server. ```javascript const options = { proxy: { host: '159.203.75.235', // ipv4, ipv6, or hostname port: 1081, type: 5 }, command: 'associate', // When using associate, the destination should be the remote client that is expected to send UDP packets to the proxy server to be forwarded. This should be your local ip, or optionally the wildcard address (0.0.0.0) UDP Client <-> Proxy <-> UDP Client destination: { host: '0.0.0.0', port: 0 } }; // Create a local UDP socket for sending packets to 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: '165.227.108.231', port: 4444 }, // The remote host that replied with a UDP packet data: // The data } */ }); let client = new SocksClient(associateOptions); // When the UDP relay is established, this event is fired and includes the UDP relay port to send data to on the proxy server. client.on('established', info => { console.log(info.remoteHost); /* { host: '159.203.75.235', port: 44711 } */ // Send 'hello' to 165.227.108.231:4444 const packet = SocksClient.createUDPFrame({ remoteHost: { host: '165.227.108.231', port: 4444 }, data: Buffer.from(line) }); udpSocket.send(packet, info.remoteHost.port, info.remoteHost.host); }); // Start connection client.connect(); ``` **Note:** The associate TCP connection to the proxy must remain open for the UDP relay to work. ## Additional Examples [Documentation](docs/index.md) ## Migrating from v1 Looking for a guide to migrate from v1? Look [here](docs/migratingFromV1.md) ## Api Reference: **Note:** socks includes full TypeScript definitions. These can even be used without using TypeScript as most IDEs (such as VS Code) will use these type definition files for auto completion intellisense even in JavaScript files. * Class: SocksClient * [new SocksClient(options[, callback])](#new-socksclientoptions) * [Class Method: SocksClient.createConnection(options[, callback])](#class-method-socksclientcreateconnectionoptions-callback) * [Class Method: SocksClient.createConnectionChain(options[, callback])](#class-method-socksclientcreateconnectionchainoptions-callback) * [Class Method: SocksClient.createUDPFrame(options)](#class-method-socksclientcreateudpframedetails) * [Class Method: SocksClient.parseUDPFrame(data)](#class-method-socksclientparseudpframedata) * [Event: 'error'](#event-error) * [Event: 'bound'](#event-bound) * [Event: 'established'](#event-established) * [client.connect()](#clientconnect) * [client.socksClientOptions](#clientconnect) ### SocksClient SocksClient establishes SOCKS proxy connections to remote destination hosts. These proxy connections are fully transparent to the server and once established act as full duplex streams. SOCKS v4, v4a, and v5 are supported, as well as the connect, bind, and associate commands. SocksClient supports creating connections using callbacks, promises, and async/await flow control using two static factory functions createConnection and createConnectionChain. It also internally extends EventEmitter which results in allowing event handling based async flow control. **SOCKS Compatibility Table** | Socks Version | TCP | UDP | IPv4 | IPv6 | Hostname | | --- | :---: | :---: | :---: | :---: | :---: | | SOCKS v4 | ✅ | ❌ | ✅ | ❌ | ❌ | | SOCKS v4a | ✅ | ❌ | ✅ | ❌ | ✅ | | SOCKS v5 | ✅ | ✅ | ✅ | ✅ | ✅ | ### new SocksClient(options) * ```options``` {SocksClientOptions} - An object describing the SOCKS proxy to use, the command to send and establish, and the destination host to connect to. ### SocksClientOptions ```typescript { proxy: { host: '159.203.75.200', // ipv4, ipv6, or hostname port: 1080, type: 5 // Proxy version (4 or 5). For v4a, just use 4. // Optional fields userId: 'some username', // Used for SOCKS4 userId auth, and SOCKS5 user/pass auth in conjunction with password. password: 'some password' // Used in conjunction with userId for user/pass auth for SOCKS5 proxies. }, command: 'connect', // connect, bind, associate destination: { host: '192.30.253.113', // ipv4, ipv6, hostname. Hostnames work with v4a and v5. port: 80 }, // Optional fields timeout: 30000, // How long to wait to establish a proxy connection. (defaults to 30 seconds) set_tcp_nodelay: true // If true, will turn on the underlying sockets TCP_NODELAY option. } ``` ### Class Method: SocksClient.createConnection(options[, callback]) * ```options``` { SocksClientOptions } - An object describing the SOCKS proxy to use, the command to send and establish, and the destination host to connect to. * ```callback``` { Function } - Optional callback function that is called when the proxy connection is established, or an error occurs. * ```returns``` { Promise } - A Promise is returned that is resolved when the proxy connection is established, or rejected when an error occurs. Creates a new proxy connection through the given proxy to the given destination host. This factory function supports callbacks and promises for async flow control. **Note:** If a callback function is provided, the promise will always resolve regardless of an error occurring. Please be sure to exclusively use either promises or callbacks when using this factory function. ```typescript const options = { proxy: { host: '159.203.75.200', // ipv4, ipv6, or hostname port: 1080, type: 5 // Proxy version (4 or 5) }, command: 'connect', // connect, bind, associate destination: { host: '192.30.253.113', // ipv4, ipv6, or hostname port: 80 } } // Await/Async (uses a Promise) try { const info = await SocksClient.createConnection(options); console.log(info); /* { socket: , // Raw net.Socket } */ / (this is a raw net.Socket that is established to the destination host through the given proxy server) } catch (err) { // Handle error... } // Promise SocksClient.createConnection(options) .then(info => { console.log(info); /* { socket: , // Raw net.Socket } */ }) .catch(err => { // Handle error... }); // Callback SocksClient.createConnection(options, (err, info) => { if (!err) { console.log(info); /* { socket: , // Raw net.Socket } */ } else { // Handle error... } }); ``` ### Class Method: SocksClient.createConnectionChain(options[, callback]) * ```options``` { SocksClientChainOptions } - An object describing a list of SOCKS proxies to use, the command to send and establish, and the destination host to connect to. * ```callback``` { Function } - Optional callback function that is called when the proxy connection chain is established, or an error occurs. * ```returns``` { Promise } - A Promise is returned that is resolved when the proxy connection chain is established, or rejected when an error occurs. Creates a new proxy connection chain through a list of at least two SOCKS proxies to the given destination host. This factory method supports callbacks and promises for async flow control. **Note:** If a callback function is provided, the promise will always resolve regardless of an error occurring. Please be sure to exclusively use either promises or callbacks when using this factory function. **Note:** At least two proxies must be provided for the chain to be established. ```typescript const options = { proxies: [ // The chain order is the order in the proxies array, meaning the last proxy will establish a connection to the destination. { host: '159.203.75.235', // ipv4, ipv6, or hostname port: 1081, type: 5 }, { host: '104.131.124.203', // ipv4, ipv6, or hostname port: 1081, type: 5 } ] command: 'connect', // Only connect is supported in chaining mode. destination: { host: '192.30.253.113', // ipv4, ipv6, hostname port: 80 } } ``` ### Class Method: SocksClient.createUDPFrame(details) * ```details``` { SocksUDPFrameDetails } - An object containing the remote host, frame number, and frame data to use when creating a SOCKS UDP frame packet. * ```returns``` { Buffer } - A Buffer containing all of the UDP frame data. Creates a SOCKS UDP frame relay packet that is sent and received via a SOCKS proxy when using the associate command for UDP packet forwarding. **SocksUDPFrameDetails** ```typescript { frameNumber: 0, // The frame number (used for breaking up larger packets) remoteHost: { // The remote host to have the proxy send data to, or the remote host that send this data. host: '1.2.3.4', port: 1234 }, data: // A Buffer instance of data to include in the packet (actual data sent to the remote host) } interface SocksUDPFrameDetails { // The frame number of the packet. frameNumber?: number; // The remote host. remoteHost: SocksRemoteHost; // The packet data. data: Buffer; } ``` ### Class Method: SocksClient.parseUDPFrame(data) * ```data``` { Buffer } - A Buffer instance containing SOCKS UDP frame data to parse. * ```returns``` { SocksUDPFrameDetails } - An object containing the remote host, frame number, and frame data of the SOCKS UDP frame. ```typescript const frame = SocksClient.parseUDPFrame(data); console.log(frame); /* { frameNumber: 0, remoteHost: { host: '1.2.3.4', port: 1234 }, data: } */ ``` Parses a Buffer instance and returns the parsed SocksUDPFrameDetails object. ## Event: 'error' * ```err``` { SocksClientError } - An Error object containing an error message and the original SocksClientOptions. This event is emitted if an error occurs when trying to establish the proxy connection. ## Event: 'bound' * ```info``` { SocksClientBoundEvent } An object containing a Socket and SocksRemoteHost info. This event is emitted when using the BIND command on a remote SOCKS proxy server. This event indicates the proxy server is now listening for incoming connections on a specified port. **SocksClientBoundEvent** ```typescript { socket: net.Socket, // The underlying raw Socket remoteHost: { host: '1.2.3.4', // The remote host that is listening (usually the proxy itself) port: 4444 // The remote port the proxy is listening on for incoming connections (when using BIND). } } ``` ## Event: 'established' * ```info``` { SocksClientEstablishedEvent } An object containing a Socket and SocksRemoteHost info. This event is emitted when the following conditions are met: 1. When using the CONNECT command, and a proxy connection has been established to the remote host. 2. When using the BIND command, and an incoming connection has been accepted by the proxy and a TCP relay has been established. 3. When using the ASSOCIATE command, and a UDP relay has been established. When using BIND, 'bound' is first emitted to indicate the SOCKS server is waiting for an incoming connection, and provides the remote port the SOCKS server is listening on. When using ASSOCIATE, 'established' is emitted with the remote UDP port the SOCKS server is accepting UDP frame packets on. **SocksClientEstablishedEvent** ```typescript { socket: net.Socket, // The underlying raw Socket remoteHost: { host: '1.2.3.4', // The remote host that is listening (usually the proxy itself) port: 52738 // The remote port the proxy is listening on for incoming connections (when using BIND). } } ``` ## client.connect() Starts connecting to the remote SOCKS proxy server to establish a proxy connection to the destination host. ## client.socksClientOptions * ```returns``` { SocksClientOptions } The options that were passed to the SocksClient. Gets the options that were passed to the SocksClient when it was created. **SocksClientError** ```typescript { // Subclassed from Error. message: 'An error has occurred', options: { // SocksClientOptions } } ``` # Further Reading: Please read the SOCKS 5 specifications for more information on how to use BIND and Associate. http://www.ietf.org/rfc/rfc1928.txt # License This work is licensed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License). PK R ]GĊ|&&typings/index.d.tsnu[export * from './client/socksclient'; PK R ]•ggtypings/client/socksclient.d.tsnu[/// 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: any[]) => 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: any[]): 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 _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?: Function): Promise; /** * 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?: Function): Promise; /** * Creates a SOCKS UDP Frame. * @param options */ static createUDPFrame(options: SocksUDPFrameDetails): Buffer; /** * Parses a SOCKS UDP frame. * @param data */ static parseUDPFrame(data: Buffer): SocksUDPFrameDetails; /** * Gets the SocksClient internal state. */ private get state(); /** * Internal state setter. If the SocksClient is in an error state, it cannot be changed to a non error state. */ private set state(value); /** * Starts the connection establishment to the proxy and destination. * @param existing_socket Connected socket to use instead of creating a new one (internal use). */ connect(existing_socket?: 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 onConnect; /** * Handles Socket data event. * @param data */ private onDataReceived; /** * Handles processing of the data we have received. */ private processData; /** * Handles Socket close event. * @param had_error */ private onClose; /** * Handles Socket error event. * @param err */ private onError; /** * 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; /** * 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, SocksRemoteHost, SocksProxy, SocksUDPFrameDetails }; PK R ]a.qqtypings/common/helpers.d.tsnu[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 }; PK R ]$==!typings/common/receiveBuffer.d.tsnu[/// 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 }; PK R ](typings/common/constants.d.tsnu[/// 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; 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 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; }, '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 }; PK R ]-typings/common/util.d.tsnu[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: any[]): void; declare type RequireOnlyOne = Pick> & { [K in Keys]?: Required> & Partial, undefined>>; }[Keys]; export { RequireOnlyOne, SocksClientError, shuffleArray }; PK R ] W%> .travis.ymlnu[language: node_js node_js: - 6 - 8 - 10 - 12 - stable before_install: - yarn global add typescript prettier tslint coveralls script: "yarn run build && yarn run coveralls"PK R ]%G   package.jsonnu[{ "_from": "socks@~2.3.2", "_id": "socks@2.3.3", "_inBundle": false, "_integrity": "sha512-o5t52PCNtVdiOvzMry7wU4aOqYWL0PeCXRWBEiJow4/i/wr+wpsJQ9awEu1EonLIqsfGd5qSgDdxEOvCdmBEpA==", "_location": "/socks", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, "raw": "socks@~2.3.2", "name": "socks", "escapedName": "socks", "rawSpec": "~2.3.2", "saveSpec": null, "fetchSpec": "~2.3.2" }, "_requiredBy": [ "/socks-proxy-agent" ], "_resolved": "https://registry.npmjs.org/socks/-/socks-2.3.3.tgz", "_shasum": "01129f0a5d534d2b897712ed8aceab7ee65d78e3", "_spec": "socks@~2.3.2", "_where": "/Users/claudiahdz/npm/cli/node_modules/socks-proxy-agent", "author": { "name": "Josh Glazebrook" }, "bugs": { "url": "https://github.com/JoshGlazebrook/socks/issues" }, "bundleDependencies": false, "contributors": [ { "name": "castorw" } ], "dependencies": { "ip": "1.1.5", "smart-buffer": "^4.1.0" }, "deprecated": false, "description": "Fully featured SOCKS proxy client supporting SOCKSv4, SOCKSv4a, and SOCKSv5. Includes Bind and Associate functionality.", "devDependencies": { "@types/chai": "4.2.4", "@types/ip": "1.1.0", "@types/mocha": "5.2.7", "@types/node": "12.12.6", "chai": "^4.1.2", "coveralls": "^3.0.0", "mocha": "6.2.2", "nyc": "14.1.1", "prettier": "^1.9.2", "socks5-server": "^0.1.1", "ts-node": "8.4.1", "tslint": "^5.8.0", "typescript": "3.7.2" }, "engines": { "node": ">= 6.0.0", "npm": ">= 3.0.0" }, "homepage": "https://github.com/JoshGlazebrook/socks/", "keywords": [ "socks", "proxy", "tor", "socks 4", "socks 5", "socks4", "socks5" ], "license": "MIT", "main": "build/index.js", "name": "socks", "nyc": { "extension": [ ".ts", ".tsx" ], "include": [ "src/*.ts", "src/**/*.ts" ], "exclude": [ "**.*.d.ts", "node_modules", "typings" ], "require": [ "ts-node/register" ], "reporter": [ "json", "html" ], "all": true }, "private": false, "repository": { "type": "git", "url": "git+https://github.com/JoshGlazebrook/socks.git" }, "scripts": { "build": "tslint --project tsconfig.json && prettier --write ./src/**/*.ts --config .prettierrc.yaml && tsc -p .", "coverage": "NODE_ENV=test nyc npm test", "coveralls": "NODE_ENV=test nyc npm test && nyc report --reporter=text-lcov | coveralls", "lint": "tslint --project tsconfig.json 'src/**/*.ts'", "prepublish": "npm install -g typescript && npm run build", "test": "NODE_ENV=test mocha --recursive --require ts-node/register test/**/*.ts" }, "typings": "typings", "version": "2.3.3" } PK R ]WCbuild/index.jsnu[PK R ]͟Avv8build/index.js.mapnu[PK R ]h:BPBPbuild/client/socksclient.js.mapnu[PK R ]ᩀ{{Rbuild/client/socksclient.jsnu[PK R ] 6Lbuild/common/receivebuffer.jsnu[PK R ]פ3build/common/constants.js.mapnu[PK R ]1GDD!build/common/receivebuffer.js.mapnu[PK R ]Kc build/common/helpers.js.mapnu[PK R ]ö76~~build/common/util.jsnu[PK R ]DTbuild/common/util.js.mapnu[PK R ]_*^^build/common/constants.jsnu[PK R ]hhQbuild/common/helpers.jsnu[PK R ]Q&{E E docs/migratingFromV1.mdnu[PK R ]SŔ (docs/index.mdnu[PK R ]PbbJ)docs/examples/index.mdnu[PK R ]  #  '*docs/examples/typescript/bindExample.mdnu[PK R ]f ,_6docs/examples/typescript/associateExample.mdnu[PK R ]h=::*Cdocs/examples/typescript/connectExample.mdnu[PK R ]l 'Xbdocs/examples/javascript/bindExample.mdnu[PK R ] ,mdocs/examples/javascript/associateExample.mdnu[PK R ]:*zdocs/examples/javascript/connectExample.mdnu[PK R ]6 TT.prettierrc.yamlnu[PK R ]7xR::&LICENSEnu[PK R ]sVV README.mdnu[PK R ]GĊ|&&typings/index.d.tsnu[PK R ]•ggtypings/client/socksclient.d.tsnu[PK R ]a.qq typings/common/helpers.d.tsnu[PK R ]$==!utypings/common/receiveBuffer.d.tsnu[PK R ](typings/common/constants.d.tsnu[PK R ]- typings/common/util.d.tsnu[PK R ] W%> #.travis.ymlnu[PK R ]%G   $package.jsonnu[PK 9 0