From 4f587b2cf5c8e7dfd30f739c480f4a69cb38bda6 Mon Sep 17 00:00:00 2001 From: Starlight_0208 <2682994272@qq.com> Date: Sun, 19 Sep 2021 22:26:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新了端口查询功能,后端console稍微修改了一下 --- app.js | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 3ead861..15adbfd 100644 --- a/app.js +++ b/app.js @@ -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(); })