ip2proxy-nodejs
Advanced tools
+1
-1
| { | ||
| "name": "ip2proxy-nodejs", | ||
| "version": "4.3.1", | ||
| "version": "4.3.2", | ||
| "description": "IP2Proxy proxy detection component", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
+53
-16
@@ -7,3 +7,3 @@ const net = require("net"); | ||
| // For BIN queries | ||
| const VERSION = "4.3.1"; | ||
| const VERSION = "4.3.2"; | ||
| const MAX_INDEX = 65536; | ||
@@ -29,2 +29,4 @@ const COUNTRY_POSITION = [0, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]; | ||
| const LAST_32_BITS = BigInt("4294967295"); | ||
| const FROM_IPV4_MAPPED_IPV6 = BigInt("281470681743360"); | ||
| const TO_IPV4_MAPPED_IPV6 = BigInt("281474976710655"); | ||
| const MODES = { | ||
@@ -132,2 +134,3 @@ COUNTRY_SHORT: 1, | ||
| #fd; | ||
| #fh; | ||
@@ -402,4 +405,4 @@ constructor() {} | ||
| if (this.#binFile && this.#binFile != "") { | ||
| let fh = await fsp.open(this.#binFile, "r"); | ||
| this.#fd = fh.fd; | ||
| this.#fh = await fsp.open(this.#binFile, "r"); | ||
| this.#fd = this.#fh.fd; | ||
@@ -556,3 +559,3 @@ let len = 64; // 64-byte header | ||
| // Reset everything (do not use in async case due to race conditions) | ||
| // Reset everything | ||
| close() { | ||
@@ -576,3 +579,3 @@ try { | ||
| this.#myDB.fileSize = 0; | ||
| fs.closeSync(this.#fd); | ||
| fs.closeSync(this.#fd); // normal file handle | ||
| return 0; | ||
@@ -584,2 +587,28 @@ } catch (err) { | ||
| // Reset everything | ||
| async closeAsync() { | ||
| try { | ||
| this.#myDB.baseAddress = 0; | ||
| this.#myDB.dbCount = 0; | ||
| this.#myDB.dbColumn = 0; | ||
| this.#myDB.dbType = 0; | ||
| this.#myDB.dbDay = 0; | ||
| this.#myDB.dbMonth = 0; | ||
| this.#myDB.dbYear = 0; | ||
| this.#myDB.baseAddressIPV6 = 0; | ||
| this.#myDB.dbCountIPV6 = 0; | ||
| this.#myDB.indexed = 0; | ||
| this.#myDB.indexedIPV6 = 0; | ||
| this.#myDB.indexBaseAddress = 0; | ||
| this.#myDB.indexBaseAddressIPV6 = 0; | ||
| this.#myDB.productCode = 0; | ||
| this.#myDB.productType = 0; | ||
| this.#myDB.fileSize = 0; | ||
| await this.#fh.close(); // FileHandler object opened by fs.Promises | ||
| return 0; | ||
| } catch (err) { | ||
| return -1; | ||
| } | ||
| } | ||
| // Search BIN for the data | ||
@@ -625,3 +654,4 @@ proxyQueryData(myIP, ipType, data, mode) { | ||
| (ipNumber >= FROM_6TO4 && ipNumber <= TO_6TO4) || | ||
| (ipNumber >= FROM_TEREDO && ipNumber <= TO_TEREDO) | ||
| (ipNumber >= FROM_TEREDO && ipNumber <= TO_TEREDO) || | ||
| (ipNumber >= FROM_IPV4_MAPPED_IPV6 && ipNumber <= TO_IPV4_MAPPED_IPV6) | ||
| ) { | ||
@@ -636,4 +666,6 @@ ipType = 4; | ||
| ipNumber = Number((ipNumber >> BigInt(80)) & LAST_32_BITS); | ||
| } else if (ipNumber >= FROM_TEREDO && ipNumber <= TO_TEREDO) { | ||
| ipNumber = Number(~ipNumber & LAST_32_BITS); | ||
| } else { | ||
| ipNumber = Number(~ipNumber & LAST_32_BITS); | ||
| ipNumber = Number(ipNumber - FROM_IPV4_MAPPED_IPV6); | ||
| } | ||
@@ -646,2 +678,6 @@ if (this.#myDB.indexed == 1) { | ||
| } else { | ||
| if (this.#myDB.dbCountIPV6 == 0) { | ||
| loadMesg(data, MSG_IPV6_UNSUPPORTED); | ||
| return; | ||
| } | ||
| firstCol = 16; // IPv6 is 16 bytes | ||
@@ -848,3 +884,4 @@ if (this.#myDB.indexedIPV6 == 1) { | ||
| (ipNumber >= FROM_6TO4 && ipNumber <= TO_6TO4) || | ||
| (ipNumber >= FROM_TEREDO && ipNumber <= TO_TEREDO) | ||
| (ipNumber >= FROM_TEREDO && ipNumber <= TO_TEREDO) || | ||
| (ipNumber >= FROM_IPV4_MAPPED_IPV6 && ipNumber <= TO_IPV4_MAPPED_IPV6) | ||
| ) { | ||
@@ -859,4 +896,6 @@ ipType = 4; | ||
| ipNumber = Number((ipNumber >> BigInt(80)) & LAST_32_BITS); | ||
| } else if (ipNumber >= FROM_TEREDO && ipNumber <= TO_TEREDO) { | ||
| ipNumber = Number(~ipNumber & LAST_32_BITS); | ||
| } else { | ||
| ipNumber = Number(~ipNumber & LAST_32_BITS); | ||
| ipNumber = Number(ipNumber - FROM_IPV4_MAPPED_IPV6); | ||
| } | ||
@@ -869,2 +908,6 @@ if (this.#myDB.indexed == 1) { | ||
| } else { | ||
| if (this.#myDB.dbCountIPV6 == 0) { | ||
| loadMesg(data, MSG_IPV6_UNSUPPORTED); | ||
| return; | ||
| } | ||
| firstCol = 16; // IPv6 is 16 bytes | ||
@@ -1075,5 +1118,2 @@ if (this.#myDB.indexedIPV6 == 1) { | ||
| return data; | ||
| } else if (ipType == 6 && this.#myDB.dbCountIPV6 == 0) { | ||
| loadMesg(data, MSG_IPV6_UNSUPPORTED); | ||
| return data; | ||
| } else { | ||
@@ -1127,5 +1167,2 @@ this.proxyQueryData(myIP, ipType, data, mode); | ||
| return data; | ||
| } else if (ipType == 6 && this.#myDB.dbCountIPV6 == 0) { | ||
| loadMesg(data, MSG_IPV6_UNSUPPORTED); | ||
| return data; | ||
| } else { | ||
@@ -1501,2 +1538,2 @@ await this.proxyQueryDataAsync(myIP, ipType, data, mode); | ||
| IP2ProxyWebService: IP2ProxyWebService, | ||
| }; | ||
| }; |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
72497
1.74%1884
2%