1
0
Fork 0
mirror of https://github.com/shimataro/ssh-key-action.git synced 2025-06-19 22:52:10 +10:00

* first action! (#1)

This commit is contained in:
shimataro 2019-09-18 20:39:54 +09:00 committed by GitHub
parent 8deacc95b1
commit ace1e6a69a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3750 changed files with 1155519 additions and 0 deletions

718
node_modules/socks/build/client/socksclient.js generated vendored Normal file
View file

@ -0,0 +1,718 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(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._options.proxy.port, this._options.proxy.host || this._options.proxy.ipaddress);
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();
});
});
}
/**
* 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.map

1
node_modules/socks/build/client/socksclient.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

105
node_modules/socks/build/common/constants.js generated vendored Normal file
View file

@ -0,0 +1,105 @@
"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.map

1
node_modules/socks/build/common/constants.js.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"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"}

100
node_modules/socks/build/common/helpers.js generated vendored Normal file
View file

@ -0,0 +1,100 @@
"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.map

1
node_modules/socks/build/common/helpers.js.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/common/helpers.ts"],"names":[],"mappings":"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"}

42
node_modules/socks/build/common/receivebuffer.js generated vendored Normal file
View file

@ -0,0 +1,42 @@
"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.map

1
node_modules/socks/build/common/receivebuffer.js.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"receivebuffer.js","sourceRoot":"","sources":["../../src/common/receivebuffer.ts"],"names":[],"mappings":";;AAAA;IAKE,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"}

24
node_modules/socks/build/common/util.js generated vendored Normal file
View file

@ -0,0 +1,24 @@
"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.map

1
node_modules/socks/build/common/util.js.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/common/util.ts"],"names":[],"mappings":";;AAEA;;GAEG;AACH,sBAAuB,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,sBAAsB,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"}

7
node_modules/socks/build/index.js generated vendored Normal file
View file

@ -0,0 +1,7 @@
"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.map

1
node_modules/socks/build/index.js.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,0CAAqC"}