Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js2ray

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js2ray - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

event.js

46

index.js

@@ -5,5 +5,4 @@

const http = require('http');
const validator = require('./validator');
const _server = require('./server');
const event = require('./event');
const protocol = require('./vmess');
const event = require('./event');

@@ -17,10 +16,10 @@

}
validator.init(data.users)
protocol.init(data.users)
if (data.network == "ws") {
const wss = new WebSocketServer({ port: data.port, host: data.address });
wss.on('connection', function connection(ws) {
_server.connect(ws, ws._socket.remoteAddress)
protocol.connect(ws, ws._socket.remoteAddress)
ws.write = ws.send
ws.on("close", _server.close)
ws.on('message', _server.message);
ws.on("close", protocol.close)
ws.on('message', protocol.message);
});

@@ -31,6 +30,6 @@ log("ws server is running on port", data.port)

var server = net.createServer(function (localsocket) {
_server.connect(localsocket, localsocket.remoteAddress)
protocol.connect(localsocket, localsocket.remoteAddress)
localsocket.on("error", function () { })
localsocket.on("close", _server.close)
localsocket.on('data', _server.message);
localsocket.on("close", protocol.close)
localsocket.on('data', protocol.message);
});

@@ -41,7 +40,8 @@ server.listen(data.port, data.address);

} else if (data.network == "http") {
const HTTP_HEADER = "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nConnection: keep-alive\r\n\r\n";
if (!data.header)
data.header = "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nConnection: keep-alive\r\n\r\n"
var server = net.createServer(function (localsocket) {
_server.connect(localsocket, localsocket.remoteAddress)
protocol.connect(localsocket, localsocket.remoteAddress)
localsocket.on("error", function () { })
// localsocket.on("close", _server.close)
// localsocket.on("close", protocol.close)
localsocket.on('data', function (buffer) {

@@ -51,5 +51,5 @@ console.log(buffer + "")

if (indhttp != -1 && (buffer.subarray(0, 3) == "GET" || buffer.subarray(0, 4) == "POST")) {
this.write(HTTP_HEADER)
this.write(data.header)
if (buffer.length != indhttp + 4) {
return _server.message.call(this, buffer.subarray(indhttp + 4))
return protocol.message.call(this, buffer.subarray(indhttp + 4))
} else {

@@ -59,3 +59,3 @@ return

} else {
_server.message.call(this, buffer)
protocol.message.call(this, buffer)
}

@@ -68,16 +68,18 @@ });

} else if (data.network == "httpAlt") {
const HTTP_HEADER = "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nConnection: keep-alive\r\n\r\n";
if (!data.header)
data.header = "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nConnection: keep-alive\r\n\r\n"
var server = http.createServer()
server.on('connection', function (localsocket) {
_server.connect(localsocket, localsocket.remoteAddress)
protocol.connect(localsocket, localsocket.remoteAddress)
localsocket.on("error", function () { })
// localsocket.on("close", protocol.close)
localsocket.on('data', function (buffer) {
if (buffer.includes("keep-alive")) {
buffer.write(replace(buffer, "keep-alive", "close") + "", 0)
}
}
var indhttp = buffer.indexOf('\r\n\r\n')
if (indhttp != -1 && (buffer.subarray(0, 3) == "GET" || buffer.subarray(0, 4) == "POST")) {
this.write(HTTP_HEADER)
this.write(data.header)
if (buffer.length != indhttp + 4) {
return _server.message.call(this, buffer.subarray(indhttp + 4))
return protocol.message.call(this, buffer.subarray(indhttp + 4))
} else {

@@ -87,3 +89,3 @@ return

} else {
_server.message.call(this, buffer)
protocol.message.call(this, buffer)
}

@@ -90,0 +92,0 @@ });

{
"name": "js2ray",
"version": "1.0.1",
"version": "1.0.2",
"description": "The v2ray vmess protocol, based on nodejs javascript which you can use on hosts and servers",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,3 +7,3 @@

const kdf = require("./kdf")
const event = require("./event")
const event = require("../event")
const consts = require("./consts")

@@ -263,3 +263,3 @@ const crypto = require("crypto")

let _chunk = chunk;
if ([consts.SECURITY_TYPE_AES_128_GCM, consts.SECURITY_TYPE_CHACHA20_POLY1305].includes(this._security)) {
if ([consts.SECURITY_TYPE_AES_128_GCM, consts.SECURITY_TYPE_CHACHA20_POLY1305].includes(this._security)) {
_chunk = Buffer.concat(this.encrypt(_chunk));

@@ -468,5 +468,6 @@ }

module.exports = {
message: DecodeRequestHeader,
message: DecodeRequestHeader,
connect,
close
close,
init: validator.init
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc