From 5da28b0f8771834ae208d61431d632875e9f8e7d Mon Sep 17 00:00:00 2001 From: Ruben Rodriguez Date: Thu, 8 Sep 2022 20:18:54 -0400 Subject: Updated extensions: * Upgraded Privacy Redirect to 1.1.49 and configured to use the 10 most reliable invidious instances * Removed ViewTube * Added torproxy@icecat.gnu based on 'Proxy toggle' extension * Added jShelter 0.11.1 * Upgraded LibreJS to 7.21.0 * Upgraded HTTPS Everywhere to 2021.7.13 * Upgraded SubmitMe to 1.9 --- .../background-scripts/ip_utils.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'data/extensions/https-everywhere@eff.org/background-scripts/ip_utils.js') diff --git a/data/extensions/https-everywhere@eff.org/background-scripts/ip_utils.js b/data/extensions/https-everywhere@eff.org/background-scripts/ip_utils.js index be7c1c8..90e0b1a 100644 --- a/data/extensions/https-everywhere@eff.org/background-scripts/ip_utils.js +++ b/data/extensions/https-everywhere@eff.org/background-scripts/ip_utils.js @@ -2,11 +2,17 @@ (function (exports) { +/** + * Parse and convert literal IP address into numerical IP address. + * @param {string} ip + * @returns {number} + */ const parseIp = ip => { if (!/^[0-9.]+$/.test(ip)) { return -1; } + /** @type {string[]} */ const octets = ip.split('.'); if (octets.length !== 4) { @@ -26,14 +32,21 @@ const parseIp = ip => { return -1; } - ipN = (ipN << 8) | octet; + ipN = (ipN << 8) | octetN; } return ipN >>> 0; }; +/** + * Check if the numeric IP address is within a certain range. + * @param {number} ip + * @param {number[]} range + * @returns {boolean} + */ const isIpInRange = (ip, [rangeIp, mask]) => (ip & mask) >>> 0 === rangeIp; +// A list of local IP address ranges const localRanges = [ [/* 0.0.0.0 */ 0x00000000, /* 255.255.255.255 */ 0xffffffff], [/* 127.0.0.0 */ 0x7f000000, /* 255.0.0.0 */ 0xff000000], @@ -42,6 +55,11 @@ const localRanges = [ [/* 192.168.0.0 */ 0xc0a80000, /* 255.255.0.0 */ 0xffff0000], ]; +/** + * Check if the numeric IP address is inside the local IP address ranges. + * @param {number} ip + * @returns {boolean} + */ const isLocalIp = ip => localRanges.some(range => isIpInRange(ip, range)); Object.assign(exports, { -- cgit v1.2.3