Comparing version 2.3.6 to 2.3.7
@@ -52,3 +52,3 @@ | ||
} | ||
function connected(ws) { | ||
function connected(ws, req) { | ||
ws.localMessage = function (buffer) { | ||
@@ -60,3 +60,9 @@ ws.send(buffer) | ||
} | ||
const remoteProtocol = localProtocol(ws, ws._socket.remoteAddress) | ||
var ip | ||
if (req.headers['x-forwarded-for']) { | ||
ip = req.headers['x-forwarded-for'].split(',')[0].trim(); | ||
} else { | ||
ip = ws._socket.remoteAddress | ||
} | ||
const remoteProtocol = localProtocol(ws, ip) | ||
ws.on("close", function () { remoteProtocol.close() }) | ||
@@ -109,3 +115,3 @@ ws.on("error", function () { remoteProtocol.close() }) | ||
localsocket.localMessage = localsocket.write.bind(localsocket) | ||
localsocket.localClose = localsocket.destroy.bind(localsocket) | ||
localsocket.localClose = localsocket.destroy.bind(localsocket) | ||
const remoteProtocol = localProtocol(localsocket, localsocket.remoteAddress) | ||
@@ -112,0 +118,0 @@ localsocket.setTimeout(30000); |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
const protocols = {} | ||
@@ -3,0 +3,0 @@ protocols.vmess = require('./protocols/vmess') |
{ | ||
"name": "js2ray", | ||
"version": "2.3.6", | ||
"version": "2.3.7", | ||
"description": "The v2ray vmess protocol, based on nodejs javascript which you can use on hosts and servers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
@@ -2,0 +3,0 @@ const crypto = require('crypto'); |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
const EventEmitter = require('events'); | ||
@@ -2,0 +4,0 @@ |
"use strict"; | ||
const kdf = require("./kdf") | ||
@@ -42,3 +43,3 @@ const CRC32 = require('./crypto/crc32'); | ||
function OpenVMessAEADHeader(key, data) { | ||
var authid = data.subarray(0, 16) | ||
const authid = data.subarray(0, 16) | ||
var payloadHeaderLengthAEADEncrypted = data.subarray(16, 18) | ||
@@ -45,0 +46,0 @@ var payloadHeaderLengthAEADEncryptedTag = data.subarray(18, 34) |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
@@ -2,0 +3,0 @@ |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
@@ -70,4 +71,4 @@ const jsSha = require("./crypto/sha3"); | ||
function encrypt(plaintext, app) { | ||
const security = app._security; | ||
if (app._dataEncIV) { | ||
const security = app._security; | ||
let tag = null; | ||
@@ -99,33 +100,34 @@ const nonce = Buffer.concat([ntb(app._cipherNonce), app._dataEncIV.subarray(2, 12)]); | ||
function decrypt(ciphertext, app) { | ||
const tag = ciphertext.subarray(-16); | ||
ciphertext = ciphertext.subarray(0, -16) | ||
const security = app._security; | ||
const nonce = Buffer.concat([ntb(app._decipherNonce), app._dataDecIV.subarray(2, 12)]); | ||
if (security === consts.SECURITY_TYPE_AES_128_GCM) { | ||
try { | ||
const decipher = crypto.createDecipheriv('aes-128-gcm', app._dataDecKey, nonce); | ||
decipher.setAuthTag(tag); | ||
const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]); | ||
app._decipherNonce += 1; | ||
if (app._decipherNonce > 65535) | ||
app._decipherNonce = 0 | ||
return plaintext; | ||
} catch (err) { | ||
return null; | ||
if (app._dataDecIV) { | ||
const tag = ciphertext.subarray(-16); | ||
ciphertext = ciphertext.subarray(0, -16) | ||
const security = app._security; | ||
const nonce = Buffer.concat([ntb(app._decipherNonce), app._dataDecIV.subarray(2, 12)]); | ||
if (security === consts.SECURITY_TYPE_AES_128_GCM) { | ||
try { | ||
const decipher = crypto.createDecipheriv('aes-128-gcm', app._dataDecKey, nonce); | ||
decipher.setAuthTag(tag); | ||
const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]); | ||
app._decipherNonce += 1; | ||
if (app._decipherNonce > 65535) | ||
app._decipherNonce = 0 | ||
return plaintext; | ||
} catch (err) { | ||
return null; | ||
} | ||
} | ||
} | ||
else if (security === consts.SECURITY_TYPE_CHACHA20_POLY1305) { | ||
try { | ||
const decipher = crypto.createDecipheriv('chacha20-poly1305', app._dataDecKeyForChaCha20, nonce, { | ||
authTagLength: 16 | ||
}); | ||
decipher.setAuthTag(tag) | ||
const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]); | ||
app._decipherNonce += 1; | ||
if (app._decipherNonce > 65535) | ||
app._decipherNonce = 0 | ||
return plaintext; | ||
} catch (err) { | ||
return null; | ||
else if (security === consts.SECURITY_TYPE_CHACHA20_POLY1305) { | ||
try { | ||
const decipher = crypto.createDecipheriv('chacha20-poly1305', app._dataDecKeyForChaCha20, nonce, { | ||
authTagLength: 16 | ||
}); | ||
decipher.setAuthTag(tag) | ||
const plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]); | ||
app._decipherNonce += 1; | ||
if (app._decipherNonce > 65535) | ||
app._decipherNonce = 0 | ||
return plaintext; | ||
} catch (err) { | ||
return null; | ||
} | ||
} | ||
@@ -132,0 +134,0 @@ } |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
module.exports.KDFSaltConstAuthIDEncryptionKey = "AES Auth ID Encryption" | ||
@@ -2,0 +3,0 @@ module.exports.KDFSaltConstAEADRespHeaderLenKey = "AEAD Resp Header Len Key" |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
@@ -2,0 +3,0 @@ const validator = require("./validator") |
@@ -1,3 +0,2 @@ | ||
"use strict"; | ||
const { hmac } = require('./crypto/hmac/hmac.js') | ||
@@ -4,0 +3,0 @@ const { sha256 } = require('./crypto/hmac/sha256.js') |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
function InsertUnique(cf, data) { | ||
@@ -21,3 +21,3 @@ if (cf.has(data)) { | ||
var now = Math.round(new Date() / 1000) | ||
if (now - filter.lastSwap >= filter.interval) { | ||
if (now - filter.lastSwap >= filter.interval) { | ||
if (filter.poolSwap) { | ||
@@ -24,0 +24,0 @@ filter.poolA.clear() |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
const common = require("./common") | ||
@@ -46,2 +46,4 @@ const validator = require("./validator") | ||
if (app._isConnecting) { | ||
if (!buffer || !app._staging) | ||
return | ||
app._staging = Buffer.concat([app._staging, buffer]); | ||
@@ -48,0 +50,0 @@ return; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
const storage = require("../../core/storage") | ||
@@ -3,0 +3,0 @@ const that = { |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
const crypto = require("crypto"), | ||
@@ -2,0 +3,0 @@ common = require("./common"), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136987
3523