1
0
Fork 0
forked from svrjs/svrjs

Update to SVR.JS 3.4.35

This commit is contained in:
Dorian Niemiec 2023-09-11 23:43:53 +02:00
parent 67770b224b
commit d0a01ebe18
5 changed files with 40 additions and 21 deletions

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>SVR.JS 3.4.34</title> <title>SVR.JS 3.4.35</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<style> <style>
@ -12,7 +12,7 @@
</style> </style>
</head> </head>
<body> <body>
<h1>Welcome to SVR.JS 3.4.34</h1> <h1>Welcome to SVR.JS 3.4.35</h1>
<br/> <br/>
<img src="/logo.png" style="width: 256px;" /> <img src="/logo.png" style="width: 256px;" />
<br/> <br/>
@ -74,7 +74,7 @@
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"replacement": ""<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"replacement": ""<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]<br/>
&nbsp;&nbsp;&nbsp;&nbsp;},<br/>3.4.13 &nbsp;&nbsp;&nbsp;&nbsp;},<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{<br/> &nbsp;&nbsp;&nbsp;&nbsp;{<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"definingRegex": "/^\\/invoke500\\/.+/",<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"definingRegex": "/^\\/invoke500\\/.+/",<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"replacements": [<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"replacements": [<br/>
@ -119,12 +119,9 @@
</div> </div>
<p>Changes:</p> <p>Changes:</p>
<ul> <ul>
<li>Changed enableRemoteLogBrowsing property to be false by default.</li> <li>Added warning about worker count being limited to one when using Bun 1.0 and newer with shimmed (not native) clustering module.</li>
<li>Mitigated security vulnerability: Sensitive data is no longer leaked from temp directory inside SVR.JS installation directory.</li> <li>Disabled server-side JavaScript bug workaround for Bun 1.0 and newer (it's not needed anymore for these Bun versions).</li>
</ul> <li>Improved clustering shim for Bun.</li>
<p>Bugs:</p>
<ul>
<li>On first load server-side JavaScript will fail to load when SVR.JS is running on Bun.</li>
</ul> </ul>
<br/> <br/>
<a href="/tests.html">Tests</a><br/> <a href="/tests.html">Tests</a><br/>

View file

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

View file

@ -9,12 +9,12 @@
// ext - File extension of requested file // ext - File extension of requested file
// uobject - Request URL object // uobject - Request URL object
// search - Request URL queries // search - Request URL queries
// defaultPage - An index page location (deprecated, always returns 'index.json') // defaultPage - An index page location (deprecated, always returns 'index.html')
// users - A list of users (deprecated) // users - A list of users (deprecated)
// page404 - 404 Not Found page location // page404 - 404 Not Found page location
// head - A head of server response // head - A head of server response
// foot - A foot of server response // foot - A foot of server response
// fd - A response body used by responseEnd method // fd - Currently unused
// elseCallback - Method summoning SVR.JS internal callbacks // elseCallback - Method summoning SVR.JS internal callbacks
// callServerError - Method to end with server error // callServerError - Method to end with server error
// getCustomHeaders - Method to get headers defined in config.json file // getCustomHeaders - Method to get headers defined in config.json file

30
svr.js
View file

@ -71,7 +71,7 @@ function deleteFolderRecursive(path) {
} }
var os = require("os"); var os = require("os");
var version = "3.4.34"; var version = "3.4.35";
var singlethreaded = false; var singlethreaded = false;
if (process.versions) process.versions.svrjs = version; //Inject SVR.JS into process.versions if (process.versions) process.versions.svrjs = version; //Inject SVR.JS into process.versions
@ -142,6 +142,7 @@ if (!singlethreaded) {
cluster.isMaster = !process.env.NODE_UNIQUE_ID; cluster.isMaster = !process.env.NODE_UNIQUE_ID;
cluster.isPrimary = cluster.isMaster; cluster.isPrimary = cluster.isMaster;
cluster.isWorker = !cluster.isMaster; cluster.isWorker = !cluster.isMaster;
cluster.__shimmed__ = true;
if (cluster.isWorker) { if (cluster.isWorker) {
// Shim the cluster.worker object for worker processes // Shim the cluster.worker object for worker processes
@ -279,6 +280,10 @@ if (!singlethreaded) {
newWorker.send(message, fakeParam2, fakeParam3, fakeParam4, tries + 1); newWorker.send(message, fakeParam2, fakeParam3, fakeParam4, tries + 1);
} }
}; };
} else {
newWorker.on("exit", function () {
delete cluster.workers[newWorker.id];
});
} }
cluster.workers[newWorker.id] = newWorker; cluster.workers[newWorker.id] = newWorker;
@ -300,6 +305,7 @@ var bruteForceDb = {};
var SVRJSInitialized = false; var SVRJSInitialized = false;
var exiting = false; var exiting = false;
var crashed = false; var crashed = false;
var threadLimitWarned = false;
function SVRJSFork() { function SVRJSFork() {
//Log //Log
@ -307,12 +313,28 @@ function SVRJSFork() {
//Fork new worker //Fork new worker
var newWorker = {}; var newWorker = {};
try { try {
newWorker = cluster.fork(); if (!threadLimitWarned && cluster.__shimmed__ && process.isBun && process.versions.bun && process.versions.bun[0] != "0") {
threadLimitWarned = true;
serverconsole.locwarnmessage("SVR.JS limited the number of workers to one, because of startup problems in Bun 1.0 and newer with shimmed (not native) clustering module. Reliability may suffer.");
}
if (!(cluster.__shimmed__ && process.isBun && process.versions.bun && process.versions.bun[0] != "0" && Object.keys(cluster.workers) > 0)) {
newWorker = cluster.fork();
} else {
if (SVRJSInitialized) serverconsole.locwarnmessage("SVR.JS limited the number of workers to one, because of startup problems in Bun 1.0 and newer with shimmed (not native) clustering module. Reliability may suffer.");
}
} catch (err) { } catch (err) {
if(err.name == "NotImplementedError") { if(err.name == "NotImplementedError") {
// If cluster.fork throws a NotImplementedError, shim cluster module // If cluster.fork throws a NotImplementedError, shim cluster module
cluster.bunShim(); cluster.bunShim();
newWorker = cluster.fork(); if (!threadLimitWarned && cluster.__shimmed__ && process.isBun && process.versions.bun && process.versions.bun[0] != "0") {
threadLimitWarned = true;
serverconsole.locwarnmessage("SVR.JS limited the number of workers to one, because of startup problems in Bun 1.0 and newer with shimmed (not native) clustering module. Reliability may suffer.");
}
if (!(cluster.__shimmed__ && process.isBun && process.versions.bun && process.versions.bun[0] != "0" && Object.keys(cluster.workers) > 0)) {
newWorker = cluster.fork();
} else {
if (SVRJSInitialized) serverconsole.locwarnmessage("SVR.JS limited the number of workers to one, because of startup problems in Bun 1.0 and newer with shimmed (not native) clustering module. Reliability may suffer.");
}
} else { } else {
throw err; throw err;
} }
@ -1252,7 +1274,7 @@ if (!disableMods) {
modloaderFolderName = ".modloader_w" + Math.floor(Math.random() * 65536); modloaderFolderName = ".modloader_w" + Math.floor(Math.random() * 65536);
} }
var tempServerSideScriptName = "serverSideScript.js"; var tempServerSideScriptName = "serverSideScript.js";
if (!process.isBun && cluster.isPrimary === false) { if (!(process.isBun && process.versions.bun && process.versions.bun[0] == "0") && cluster.isPrimary === false) {
tempServerSideScriptName = ".serverSideScript_w" + Math.floor(Math.random() * 65536) + ".js"; tempServerSideScriptName = ".serverSideScript_w" + Math.floor(Math.random() * 65536) + ".js";
} }
for (var i = 0; i < modFiles.length; i++) { for (var i = 0; i < modFiles.length; i++) {

View file

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