From 1637e87550b3d021238752eb404ecc1336d5edfb Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sat, 2 Sep 2023 18:33:09 +0200 Subject: [PATCH] Dropped support for unused SVR.JS-specific X-SVR-JS-Client header (use X-Forwarded-For header instead) --- svr.js | 60 +++------------------------------------------------------- 1 file changed, 3 insertions(+), 57 deletions(-) diff --git a/svr.js b/svr.js index 7972f01..4f2102d 100644 --- a/svr.js +++ b/svr.js @@ -2419,25 +2419,7 @@ if (!cluster.isPrimary) { var reqip = ""; var oldport = ""; var oldip = ""; - if (req.headers["x-svr-js-client"] != undefined && enableIPSpoofing) { - var kl = req.headers["x-svr-js-client"].split(":"); - reqport = kl.pop(); - reqip = kl.join(":"); - try { - oldport = req.socket.remotePort; - oldip = req.socket.remoteAddress; - req.socket.realRemotePort = reqport; - req.socket.realRemoteAddress = reqip; - req.socket.originalRemotePort = oldport; - req.socket.originalRemoteAddress = oldip; - res.socket.realRemotePort = reqport; - res.socket.realRemoteAddress = reqip; - res.socket.originalRemotePort = oldport; - res.socket.originalRemoteAddress = oldip; - } catch (err) { - //Nevermind... - } - } else if (req.headers["x-forwarded-for"] != undefined && enableIPSpoofing) { + if (req.headers["x-forwarded-for"] != undefined && enableIPSpoofing) { reqport = null; reqip = req.headers["x-forwarded-for"].split(",")[0].replace(/ /g, ""); if (reqip.indexOf(":") == -1) reqip = "::ffff:" + reqip; @@ -3351,25 +3333,7 @@ if (!cluster.isPrimary) { var reqip = ""; var oldport = ""; var oldip = ""; - if (req.headers["x-svr-js-client"] != undefined && enableIPSpoofing) { - var kl = req.headers["x-svr-js-client"].split(":"); - reqport = kl.pop(); - reqip = kl.join(":"); - try { - oldport = req.socket.remotePort; - oldip = req.socket.remoteAddress; - req.socket.realRemotePort = reqport; - req.socket.realRemoteAddress = reqip; - req.socket.originalRemotePort = oldport; - req.socket.originalRemoteAddress = oldip; - res.socket.realRemotePort = reqport; - res.socket.realRemoteAddress = reqip; - res.socket.originalRemotePort = oldport; - res.socket.originalRemoteAddress = oldip; - } catch (err) { - //Address setting failed - } - } else if (req.headers["x-forwarded-for"] != undefined && enableIPSpoofing) { + if (req.headers["x-forwarded-for"] != undefined && enableIPSpoofing) { reqport = null; reqip = req.headers["x-forwarded-for"].split(",")[0].replace(/ /g, ""); if (reqip.indexOf(":") == -1) reqip = "::ffff:" + reqip; @@ -3848,25 +3812,7 @@ if (!cluster.isPrimary) { var reqip = ""; var oldport = ""; var oldip = ""; - if (req.headers["x-svr-js-client"] != undefined && enableIPSpoofing) { - var kl = req.headers["x-svr-js-client"].split(":"); - reqport = kl.pop(); - reqip = kl.join(":"); - try { - oldport = req.socket.remotePort; - oldip = req.socket.remoteAddress; - req.socket.realRemotePort = reqport; - req.socket.realRemoteAddress = reqip; - req.socket.originalRemotePort = oldport; - req.socket.originalRemoteAddress = oldip; - res.socket.realRemotePort = reqport; - res.socket.realRemoteAddress = reqip; - res.socket.originalRemotePort = oldport; - res.socket.originalRemoteAddress = oldip; - } catch (err) { - //Nevermind... - } - } else if (req.headers["x-forwarded-for"] != undefined && enableIPSpoofing) { + if (req.headers["x-forwarded-for"] != undefined && enableIPSpoofing) { reqport = null; reqip = req.headers["x-forwarded-for"].split(",")[0].replace(/ /g, ""); if (reqip.indexOf(":") == -1) reqip = "::ffff:" + reqip;