r2/proxy/client.js
lightings 3620fdae36 ...
2023-04-12 14:37:56 +08:00

34 lines
708 B
JavaScript

const net = require("net");
const port = 4999;
const host = "127.0.0.1";
var client = new net.Socket();
client.connect(port, host, function () {
console.log("Connected");
client.write("queryEntry");
});
client.on("data", function (data) {
data = JSON.parse(data);
console.log("Received: " + data);
client.destroy(); // kill client after server's response
const game = new net.Socket();
console.log(data.port, data.host);
game.connect(data.port, data.host, function () {
console.log("Connected");
game.write("entry");
});
});
client.on("error", function (error) {
console.log("Error: " + error);
});
client.on("close", function () {
console.log("Connection closed");
});