Comparing version 2.1.1 to 2.1.2
{ | ||
"name": "js2ray", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "The v2ray vmess protocol, based on nodejs javascript which you can use on hosts and servers", | ||
@@ -29,5 +29,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"cuckoo-filter": "^1.1.4", | ||
"ws": "^8.12.0" | ||
} | ||
} |
@@ -40,28 +40,3 @@ | ||
function unix() { | ||
return Math.round(new Date() / 1000) | ||
} | ||
function Match(AuthIDDecoderHolder, authID) { | ||
for (var v in AuthIDDecoderHolder.decoders) { | ||
var decode = Decode(AuthIDDecoderHolder.decoders[v].dec, authID) | ||
if (decode.z != CRC32(decode.d.subarray(0, 12))) { | ||
continue | ||
} | ||
if (decode.t < 0) { | ||
continue | ||
} | ||
if (Math.abs(Number(decode.t) - unix()) > 120) { | ||
continue | ||
} | ||
if (!antireplay.Check(AuthIDDecoderHolder.filter, authID)) { | ||
return false | ||
} | ||
return AuthIDDecoderHolder.decoders[v].ticket | ||
} | ||
return undefined | ||
} | ||
function OpenVMessAEADHeader(key, data) { | ||
@@ -160,3 +135,28 @@ var authid = data.subarray(0, 16) | ||
function unix() { | ||
return Math.round(new Date() / 1000) | ||
} | ||
function Match(AuthIDDecoderHolder, authID) { | ||
for (var v in AuthIDDecoderHolder.decoders) { | ||
var decode = Decode(AuthIDDecoderHolder.decoders[v].dec, authID) | ||
if (decode.z != CRC32(decode.d.subarray(0, 12))) { | ||
continue | ||
} | ||
if (decode.t < 0) { | ||
continue | ||
} | ||
if (Math.abs(Number(decode.t) - unix()) > 120) { | ||
continue | ||
} | ||
if (!antireplay.Check(AuthIDDecoderHolder.filter, authID)) { | ||
return false | ||
} | ||
return AuthIDDecoderHolder.decoders[v].ticket | ||
} | ||
return undefined | ||
} | ||
// ====================================================== FUNCTIONS | ||
@@ -163,0 +163,0 @@ |
const CuckooFilter = require('cuckoo-filter').CuckooFilter | ||
const replayFilterCapacity = 100000 | ||
function InsertUnique(cf, data) { | ||
if (cf.contains(data)) { | ||
if (cf.has(data)) { | ||
return false | ||
} | ||
return cf.add(data) | ||
cf.add(data) | ||
return true | ||
} | ||
function NewReplayFilter(interval) { | ||
return { | ||
poolA: [], | ||
poolB: [], | ||
poolA: new Set(), | ||
poolB: new Set(), | ||
poolSwap: false, | ||
lastSwap: 0, | ||
lastSwap: Math.round(new Date() / 1000), | ||
interval: interval | ||
} | ||
} | ||
// Check determines if there are duplicate records. | ||
function Check(filter, sum) { | ||
var now = Math.round(new Date() / 1000) | ||
if (filter.lastSwap == 0) { | ||
filter.lastSwap = now | ||
filter.poolA = new CuckooFilter(replayFilterCapacity, 2, 4) | ||
filter.poolB = new CuckooFilter(replayFilterCapacity, 2, 4) | ||
} | ||
if (now - filter.lastSwap >= filter.Interval) { | ||
if (now - filter.lastSwap >= 5) { | ||
console.log(100000) | ||
if (filter.poolSwap) { | ||
filter.poolA = new CuckooFilter(replayFilterCapacity, 2, 4) | ||
filter.poolA.clear() | ||
} else { | ||
filter.poolB = new CuckooFilter(replayFilterCapacity, 2, 4) | ||
filter.poolB.clear() | ||
} | ||
@@ -39,3 +31,2 @@ filter.poolSwap = !filter.poolSwap | ||
} | ||
return InsertUnique(filter.poolA, sum) && InsertUnique(filter.poolB, sum) | ||
@@ -42,0 +33,0 @@ } |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
1
123208
3168
8
- Removedcuckoo-filter@^1.1.4
- Removedbignumber.js@7.2.1(transitive)
- Removedborc@2.0.4(transitive)
- Removedcommander@2.20.3(transitive)
- Removedcuckoo-filter@1.1.4(transitive)
- Removeddelimit-stream@0.1.0(transitive)
- Removedfnv32@0.0.1(transitive)
- Removedieee754@1.2.1(transitive)
- Removedjson-text-sequence@0.1.1(transitive)