Skip to content

Commit

Permalink
deps: socks@2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Aug 9, 2022
1 parent ee957ed commit e65443d
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 116 deletions.
113 changes: 54 additions & 59 deletions node_modules/ip/lib/ip.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
var ip = exports;
var { Buffer } = require('buffer');
var os = require('os');
const ip = exports;
const { Buffer } = require('buffer');
const os = require('os');

ip.toBuffer = function (ip, buff, offset) {
offset = ~~offset;

var result;
let result;

if (this.isV4Format(ip)) {
result = buff || new Buffer(offset + 4);
result = buff || Buffer.alloc(offset + 4);
ip.split(/\./g).map((byte) => {
result[offset++] = parseInt(byte, 10) & 0xff;
});
} else if (this.isV6Format(ip)) {
var sections = ip.split(':', 8);
const sections = ip.split(':', 8);

var i;
let i;
for (i = 0; i < sections.length; i++) {
var isv4 = this.isV4Format(sections[i]);
var v4Buffer;
const isv4 = this.isV4Format(sections[i]);
let v4Buffer;

if (isv4) {
v4Buffer = this.toBuffer(sections[i]);
Expand All @@ -36,16 +36,16 @@ ip.toBuffer = function (ip, buff, offset) {
while (sections.length < 8) sections.push('0');
} else if (sections.length < 8) {
for (i = 0; i < sections.length && sections[i] !== ''; i++);
var argv = [i, 1];
const argv = [i, 1];
for (i = 9 - sections.length; i > 0; i--) {
argv.push('0');
}
sections.splice.apply(sections, argv);
sections.splice(...argv);
}

result = buff || new Buffer(offset + 16);
result = buff || Buffer.alloc(offset + 16);
for (i = 0; i < sections.length; i++) {
var word = parseInt(sections[i], 16);
const word = parseInt(sections[i], 16);
result[offset++] = (word >> 8) & 0xff;
result[offset++] = word & 0xff;
}
Expand All @@ -62,17 +62,16 @@ ip.toString = function (buff, offset, length) {
offset = ~~offset;
length = length || (buff.length - offset);

var result = [];
var i;
let result = [];
if (length === 4) {
// IPv4
for (i = 0; i < length; i++) {
for (let i = 0; i < length; i++) {
result.push(buff[offset + i]);
}
result = result.join('.');
} else if (length === 16) {
// IPv6
for (i = 0; i < length; i += 2) {
for (let i = 0; i < length; i += 2) {
result.push(buff.readUInt16BE(offset + i).toString(16));
}
result = result.join(':');
Expand All @@ -83,8 +82,8 @@ ip.toString = function (buff, offset, length) {
return result;
};

var ipv4Regex = /^(\d{1,3}\.){3,3}\d{1,3}$/;
var ipv6Regex = /^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;
const ipv4Regex = /^(\d{1,3}\.){3,3}\d{1,3}$/;
const ipv6Regex = /^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i;

ip.isV4Format = function (ip) {
return ipv4Regex.test(ip);
Expand All @@ -111,14 +110,14 @@ ip.fromPrefixLen = function (prefixlen, family) {
family = _normalizeFamily(family);
}

var len = 4;
let len = 4;
if (family === 'ipv6') {
len = 16;
}
var buff = new Buffer(len);
const buff = Buffer.alloc(len);

for (var i = 0, n = buff.length; i < n; ++i) {
var bits = 8;
for (let i = 0, n = buff.length; i < n; ++i) {
let bits = 8;
if (prefixlen < 8) {
bits = prefixlen;
}
Expand All @@ -134,10 +133,10 @@ ip.mask = function (addr, mask) {
addr = ip.toBuffer(addr);
mask = ip.toBuffer(mask);

var result = new Buffer(Math.max(addr.length, mask.length));
const result = Buffer.alloc(Math.max(addr.length, mask.length));

// Same protocol - do bitwise and
var i;
let i;
if (addr.length === mask.length) {
for (i = 0; i < addr.length; i++) {
result[i] = addr[i] & mask[i];
Expand Down Expand Up @@ -170,38 +169,38 @@ ip.mask = function (addr, mask) {
};

ip.cidr = function (cidrString) {
var cidrParts = cidrString.split('/');
const cidrParts = cidrString.split('/');

var addr = cidrParts[0];
const addr = cidrParts[0];
if (cidrParts.length !== 2) {
throw new Error(`invalid CIDR subnet: ${addr}`);
}

var mask = ip.fromPrefixLen(parseInt(cidrParts[1], 10));
const mask = ip.fromPrefixLen(parseInt(cidrParts[1], 10));

return ip.mask(addr, mask);
};

ip.subnet = function (addr, mask) {
var networkAddress = ip.toLong(ip.mask(addr, mask));
const networkAddress = ip.toLong(ip.mask(addr, mask));

// Calculate the mask's length.
var maskBuffer = ip.toBuffer(mask);
var maskLength = 0;
const maskBuffer = ip.toBuffer(mask);
let maskLength = 0;

for (var i = 0; i < maskBuffer.length; i++) {
for (let i = 0; i < maskBuffer.length; i++) {
if (maskBuffer[i] === 0xff) {
maskLength += 8;
} else {
var octet = maskBuffer[i] & 0xff;
let octet = maskBuffer[i] & 0xff;
while (octet) {
octet = (octet << 1) & 0xff;
maskLength++;
}
}
}

var numberOfAddresses = Math.pow(2, 32 - maskLength);
const numberOfAddresses = 2 ** (32 - maskLength);

return {
networkAddress: ip.fromLong(networkAddress),
Expand All @@ -224,86 +223,82 @@ ip.subnet = function (addr, mask) {
};

ip.cidrSubnet = function (cidrString) {
var cidrParts = cidrString.split('/');
const cidrParts = cidrString.split('/');

var addr = cidrParts[0];
const addr = cidrParts[0];
if (cidrParts.length !== 2) {
throw new Error(`invalid CIDR subnet: ${addr}`);
}

var mask = ip.fromPrefixLen(parseInt(cidrParts[1], 10));
const mask = ip.fromPrefixLen(parseInt(cidrParts[1], 10));

return ip.subnet(addr, mask);
};

ip.not = function (addr) {
var buff = ip.toBuffer(addr);
for (var i = 0; i < buff.length; i++) {
const buff = ip.toBuffer(addr);
for (let i = 0; i < buff.length; i++) {
buff[i] = 0xff ^ buff[i];
}
return ip.toString(buff);
};

ip.or = function (a, b) {
var i;

a = ip.toBuffer(a);
b = ip.toBuffer(b);

// same protocol
if (a.length === b.length) {
for (i = 0; i < a.length; ++i) {
for (let i = 0; i < a.length; ++i) {
a[i] |= b[i];
}
return ip.toString(a);

// mixed protocols
}
var buff = a;
var other = b;
let buff = a;
let other = b;
if (b.length > a.length) {
buff = b;
other = a;
}

var offset = buff.length - other.length;
for (i = offset; i < buff.length; ++i) {
const offset = buff.length - other.length;
for (let i = offset; i < buff.length; ++i) {
buff[i] |= other[i - offset];
}

return ip.toString(buff);
};

ip.isEqual = function (a, b) {
var i;

a = ip.toBuffer(a);
b = ip.toBuffer(b);

// Same protocol
if (a.length === b.length) {
for (i = 0; i < a.length; i++) {
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) return false;
}
return true;
}

// Swap
if (b.length === 4) {
var t = b;
const t = b;
b = a;
a = t;
}

// a - IPv4, b - IPv6
for (i = 0; i < 10; i++) {
for (let i = 0; i < 10; i++) {
if (b[i] !== 0) return false;
}

var word = b.readUInt16BE(10);
const word = b.readUInt16BE(10);
if (word !== 0 && word !== 0xffff) return false;

for (i = 0; i < 4; i++) {
for (let i = 0; i < 4; i++) {
if (a[i] !== b[i + 12]) return false;
}

Expand Down Expand Up @@ -365,7 +360,7 @@ ip.loopback = function (family) {
// * undefined: First address with `ipv4` or loopback address `127.0.0.1`.
//
ip.address = function (name, family) {
var interfaces = os.networkInterfaces();
const interfaces = os.networkInterfaces();

//
// Default to `ipv4`
Expand All @@ -377,8 +372,8 @@ ip.address = function (name, family) {
// return the address.
//
if (name && name !== 'private' && name !== 'public') {
var res = interfaces[name].filter((details) => {
var itemFamily = _normalizeFamily(details.family);
const res = interfaces[name].filter((details) => {
const itemFamily = _normalizeFamily(details.family);
return itemFamily === family;
});
if (res.length === 0) {
Expand All @@ -387,12 +382,12 @@ ip.address = function (name, family) {
return res[0].address;
}

var all = Object.keys(interfaces).map((nic) => {
const all = Object.keys(interfaces).map((nic) => {
//
// Note: name will only be `public` or `private`
// when this is called.
//
var addresses = interfaces[nic].filter((details) => {
const addresses = interfaces[nic].filter((details) => {
details.family = _normalizeFamily(details.family);
if (details.family !== family || ip.isLoopback(details.address)) {
return false;
Expand All @@ -411,7 +406,7 @@ ip.address = function (name, family) {
};

ip.toLong = function (ip) {
var ipl = 0;
let ipl = 0;
ip.split('.').forEach((octet) => {
ipl <<= 8;
ipl += parseInt(octet);
Expand Down
2 changes: 1 addition & 1 deletion node_modules/ip/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ip",
"version": "1.1.8",
"version": "2.0.0",
"author": "Fedor Indutny <fedor@indutny.com>",
"homepage": "https://github.com/indutny/node-ip",
"repository": {
Expand Down
6 changes: 5 additions & 1 deletion node_modules/socks/build/client/socksclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class SocksClient extends events_1.EventEmitter {
catch (err) {
if (typeof callback === 'function') {
callback(err);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return resolve(err); // Resolves pending promise (prevents memory leaks).
}
else {
Expand All @@ -68,6 +69,7 @@ class SocksClient extends events_1.EventEmitter {
client.removeAllListeners();
if (typeof callback === 'function') {
callback(err);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
resolve(err); // Resolves pending promise (prevents memory leaks).
}
else {
Expand All @@ -86,6 +88,7 @@ class SocksClient extends events_1.EventEmitter {
* @returns { Promise }
*/
static createConnectionChain(options, callback) {
// eslint-disable-next-line no-async-promise-executor
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
// Validate SocksClientChainOptions
try {
Expand All @@ -94,6 +97,7 @@ class SocksClient extends events_1.EventEmitter {
catch (err) {
if (typeof callback === 'function') {
callback(err);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return resolve(err); // Resolves pending promise (prevents memory leaks).
}
else {
Expand All @@ -106,7 +110,6 @@ class SocksClient extends events_1.EventEmitter {
(0, util_1.shuffleArray)(options.proxies);
}
try {
// tslint:disable-next-line:no-increment-decrement
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.
Expand Down Expand Up @@ -140,6 +143,7 @@ class SocksClient extends events_1.EventEmitter {
catch (err) {
if (typeof callback === 'function') {
callback(err);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
resolve(err); // Resolves pending promise (prevents memory leaks).
}
else {
Expand Down
2 changes: 1 addition & 1 deletion node_modules/socks/build/client/socksclient.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion node_modules/socks/build/common/receivebuffer.js.map
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":3,"file":"receivebuffer.js","sourceRoot":"","sources":["../../src/common/receivebuffer.ts"],"names":[],"mappings":";;;AAAA,MAAM,aAAa;IAKjB,YAAY,OAAe,IAAI;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,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,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YACnD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;YACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,CAC9B,IAAI,CAAC,GAAG,CACN,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,EACtC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CACjC,CACF,CAAC;YACF,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACvB;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACpC,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,CAAC,MAAc;QACjB,IAAI,MAAM,GA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CAAC;CACF;AAEO,sCAAa"}
1 change: 0 additions & 1 deletion node_modules/socks/build/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ exports.SocksClientError = SocksClientError;
* @param array The array to shuffle.
*/
function shuffleArray(array) {
// tslint:disable-next-line:no-increment-decrement
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
Expand Down
2 changes: 1 addition & 1 deletion node_modules/socks/build/common/util.js.map
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/common/util.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAM,gBAAiB,SAAQ,KAAK;IAClC,YACE,OAAe,EACR,OAAqD;QAE5D,KAAK,CAAC,OAAO,CAAC,CAAC;QAFR,YAAO,GAAP,OAAO,CAA8C;IAG9D,CAAC;CACF;AAwBuB,4CAAgB;AAtBxC;;;GAGG;AACH,SAAS,YAAY,CAAC,KAAY;IAChC,kDAAkD;IAClD,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACzC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7C;AACH,CAAC;AAYyC,oCAAY"}
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/common/util.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAM,gBAAiB,SAAQ,KAAK;IAClC,YACE,OAAe,EACR,OAAqD;QAE5D,KAAK,CAAC,OAAO,CAAC,CAAC;QAFR,YAAO,GAAP,OAAO,CAA8C;IAG9D,CAAC;CACF;AAuBuB,4CAAgB;AArBxC;;;GAGG;AACH,SAAS,YAAY,CAAC,KAAgB;IACpC,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACzC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7C;AACH,CAAC;AAYyC,oCAAY"}
6 changes: 5 additions & 1 deletion node_modules/socks/build/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand Down
Loading

0 comments on commit e65443d

Please sign in to comment.