From e2e374a0e0cd794f9c798d007a915a05ce3d4463 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sun, 3 Sep 2023 11:34:18 +0200 Subject: [PATCH] Fix handling of REMOTE_PORT --- index.js | 6 +++++- mod.info | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 11b886b..de2ff23 100644 --- a/index.js +++ b/index.js @@ -202,7 +202,11 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e nEnv["SCGI"] = "1"; nEnv["REQUEST_URI"] = (!origHref || origHref == href) ? req.url : (origHref + (uobject.search ? ("?" + uobject.search) : "")); nEnv["REMOTE_ADDR"] = (req.socket.realRemoteAddress ? req.socket.realRemoteAddress : ((req.headers["x-forwarded-for"] && configJSON.enableIPSpoofing) ? req.headers["x-forwarded-for"].split(",")[0].replace(/ /g, "") : req.socket.remoteAddress)).replace(/^::ffff:/i, ""); - nEnv["REMOTE_PORT"] = (req.socket.realRemotePort ? req.socket.realRemotePort : req.socket.remotePort); + if(req.socket.realRemoteAddress && req.socket.realRemotePort) { + nEnv["REMOTE_PORT"] = req.socket.realRemotePort; + } else if(!(req.socket.realRemoteAddress && !req.socket.realRemotePort)) { + nEnv["REMOTE_PORT"] = req.socket.remotePort; + } if (req.socket.encrypted) nEnv["HTTPS"] = "ON"; if (req.headers["content-type"]) nEnv["CONTENT_TYPE"] = req.headers["content-type"]; nEnv["CONTENT_LENGTH"] = "0"; diff --git a/mod.info b/mod.info index 4fb1716..1f31667 100755 --- a/mod.info +++ b/mod.info @@ -1,4 +1,4 @@ { "name": "DorianTech OrangeCircle SCGI client for SVR.JS", - "version": "1.0.5" + "version": "1.0.6" }