主程序

更新了端口查询功能,后端console稍微修改了一下
This commit is contained in:
Starlight_0208 2021-09-19 22:26:15 +08:00
parent 2d1f0fe64a
commit 4f587b2cf5

35
app.js
View File

@ -8,15 +8,40 @@ app.use(express.json());
app.get("/api/IP", (req, res) => {
UserConnection = req.connection.remoteAddress
userIP = UserConnection.replace("::ffff:","");
Uport = req.connection.remotePort;
console.log(userIP)
if(req.query.type == 'json'){
var str = {"IP":userIP, "Status":"OK"};
str_json = JSON.stringify(str);
res.send(str_json);
if(req.query.port == 1){
var str = {"IP":userIP, "port":Uport, "Status":"OK"};
str_json = JSON.stringify(str);
res.send(str_json);
}else{
var str = {"IP":userIP, "Status":"OK"};
str_json = JSON.stringify(str);
res.send(str_json);
}
}else{
res.send(userIP);
if(req.query.port == 1){
res.send(userIP + ":" + Uport);
}else{
res.send(userIP);
}
}
console.log("[Log]" + userIP + ":" + Uport + " Connecting to This Server.");
//pds
if(req.query.type == 'json'){
if(req.query.port == 1){
console.log("json: Y, Port: Y");
}else{
console.log("json: Y, Port: N");
}
}else{
if(req.query.port == 1){
console.log("json: N, Port: Y");
}else{
console.log("json: N, Port: N");
}
}
console.log("[Log]" + UserIP + "Connecting to This Server.");
//res.send("Hello World");
res.end();
})