1
0
Fork 0
forked from svrjs/svrjs

Update to SVR.JS 3.4.27

This commit is contained in:
Dorian Niemiec 2023-09-02 19:25:19 +02:00
parent 2b91a22dac
commit d2fa84a969
4 changed files with 375 additions and 434 deletions

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>SVR.JS 3.4.26</title>
<title>SVR.JS 3.4.27</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="UTF-8" />
<style>
@ -12,7 +12,7 @@
</style>
</head>
<body>
<h1>Welcome to SVR.JS 3.4.26</h1>
<h1>Welcome to SVR.JS 3.4.27</h1>
<br/>
<img src="/logo.png" style="width: 256px;" />
<br/>
@ -119,8 +119,8 @@
</div>
<p>Changes:</p>
<ul>
<li>Changed default SVR.JS configuration.</li>
<li>Disabled server-side script exposure by default.</li>
<li>Dropped support for undocumented unused non-standard SVR.JS-specific headers.</li>
<li>Fixed bug with <i>wwwredirect</i>.</li>
</ul>
<p>Bugs:</p>
<ul>

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>SVR.JS 3.4.26 Licenses</title>
<title>SVR.JS 3.4.27 Licenses</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="UTF-8" />
<style>
@ -12,8 +12,8 @@
</style>
</head>
<body>
<h1>SVR.JS 3.4.26 Licenses</h1>
<h2>SVR.JS 3.4.26</h2>
<h1>SVR.JS 3.4.27 Licenses</h1>
<h2>SVR.JS 3.4.27</h2>
<div style="display: inline-block; text-align: left; border-width: 2px; border-style: solid; border-color: gray; padding: 8px;">
MIT License<br/>
<br/>
@ -37,7 +37,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br/>
SOFTWARE.<br/>
</div>
<h2>Packages used by SVR.JS 3.4.26 and utilities</h2>
<h2>Packages used by SVR.JS 3.4.27 and utilities</h2>
<div style="width: 100%; background-color: #ccc; border: 1px solid green; text-align: left; margin: 10px 0;">
<div style="float: right;">License: MIT</div>
<div style="font-size: 20px;">

69
svr.js
View file

@ -71,7 +71,7 @@ function deleteFolderRecursive(path) {
}
var os = require("os");
var version = "3.4.26";
var version = "3.4.27";
var singlethreaded = false;
if (process.versions) process.versions.svrjs = version; //Inject SVR.JS into process.versions
@ -1844,9 +1844,6 @@ if (!cluster.isPrimary) {
if (server2.requestTimeout !== undefined && server2.requestTimeout === 0) server2.requestTimeout = 300000;
function redirhandler(req, res) {
if (req.headers["force-insecure"] == "true" || req.headers["x-force-insecure"] == "true" || req.headers["x-svr-js-force-insecure"] == "true") {
reqhandler(req, res, false);
} else {
var reqIdInt = Math.round(Math.random() * 16777216);
var reqId = "0".repeat(6 - reqIdInt.toString(16).length) + reqIdInt.toString(16);
var serverconsole = {
@ -2071,25 +2068,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 (ex) {
//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;
@ -2246,8 +2225,6 @@ if (!cluster.isPrimary) {
serverconsole.errmessage(generateErrorStack(ex));
callServerError(500, undefined, generateErrorStack(ex));
}
}
}
function reqerrhandler(err, socket, fromMain) {
@ -2874,7 +2851,7 @@ if (!cluster.isPrimary) {
hostname = hostname.join(":");
}
if (wwwredirect && hostname == domain && hostname.indexOf("www.") != 0) {
var lloc = (request.socket.encrypted ? "https" : "http") + "://" + hostname + (hostport ? ":" + hostport : "");
var lloc = (request.socket.encrypted ? "https" : "http") + "://www." + hostname + (hostport ? ":" + hostport : "");
try {
var rheaders = getCustomHeaders();
rheaders["Location"] = lloc + (request.url.replace(/\/+/g, "/"));
@ -2914,25 +2891,7 @@ if (!cluster.isPrimary) {
var reqip = "";
var oldport = "";
var oldip = "";
if (request.headers["x-svr-js-client"] != undefined && enableIPSpoofing) {
var kl = request.headers["x-svr-js-client"].split(":");
reqport = kl.pop();
reqip = kl.join(":");
try {
oldport = request.socket.remotePort;
oldip = request.socket.remoteAddress;
request.socket.realRemotePort = reqport;
request.socket.realRemoteAddress = reqip;
request.socket.originalRemotePort = oldport;
request.socket.originalRemoteAddress = oldip;
response.socket.realRemotePort = reqport;
response.socket.realRemoteAddress = reqip;
response.socket.originalRemotePort = oldport;
response.socket.originalRemoteAddress = oldip;
} catch (ex) {
//Address setting failed
}
} else if (request.headers["x-forwarded-for"] != undefined && enableIPSpoofing) {
if (request.headers["x-forwarded-for"] != undefined && enableIPSpoofing) {
reqport = null;
reqip = request.headers["x-forwarded-for"].split(",")[0].replace(/ /g, "");
if (reqip.indexOf(":") == -1) reqip = "::ffff:" + reqip;
@ -3302,25 +3261,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 (ex) {
//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;

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>SVR.JS 3.4.26 Tests</title>
<title>SVR.JS 3.4.27 Tests</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="UTF-8" />
<style>
@ -12,7 +12,7 @@
</style>
</head>
<body>
<h1>SVR.JS 3.4.26 Tests</h1>
<h1>SVR.JS 3.4.27 Tests</h1>
<h2>Directory</h2>
<iframe src="/testdir" width="50%" height="300px"></iframe>
<h2>Directory (with query)</h2>