From 5e031fe997825498c42a3b7d531da420c8a7a346 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sat, 27 Apr 2024 13:55:21 +0200 Subject: [PATCH] Update to SVR.JS 3.14.14 --- index.html | 8 +++---- licenses/index.html | 8 +++---- svr.js | 53 ++++++++++++++++++++++++++++++++++----------- tests.html | 4 ++-- 4 files changed, 50 insertions(+), 23 deletions(-) diff --git a/index.html b/index.html index f11fe11..9acba9b 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,7 @@ - SVR.JS 3.14.13 + SVR.JS 3.14.14 -

Welcome to SVR.JS 3.14.13

+

Welcome to SVR.JS 3.14.14



@@ -84,8 +84,8 @@

Changes:

Tests
diff --git a/licenses/index.html b/licenses/index.html index bbd994e..bf662c3 100644 --- a/licenses/index.html +++ b/licenses/index.html @@ -1,7 +1,7 @@ - SVR.JS 3.14.13 Licenses + SVR.JS 3.14.14 Licenses -

SVR.JS 3.14.13 Licenses

-

SVR.JS 3.14.13

+

SVR.JS 3.14.14 Licenses

+

SVR.JS 3.14.14

MIT License

@@ -37,7 +37,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-

Packages used by SVR.JS 3.14.13

+

Packages used by SVR.JS 3.14.14

License: MIT
diff --git a/svr.js b/svr.js index 91b9347..8b17d7b 100644 --- a/svr.js +++ b/svr.js @@ -69,7 +69,7 @@ function deleteFolderRecursive(path) { } var os = require("os"); -var version = "3.14.13"; +var version = "3.14.14"; var singlethreaded = false; if (process.versions) process.versions.svrjs = version; // Inject SVR.JS into process.versions @@ -390,6 +390,12 @@ try { } catch (err) { // Don't use hexstrbase64 } +var inspector = undefined; +try { + inspector = require("inspector"); +} catch (err) { + // Don't use inspector +} var zlib = require("zlib"); var tar = undefined; try { @@ -934,6 +940,23 @@ function calculateNetworkIPv4FromCidr(ipWithCidr) { }).join("."); } +var inspectorURL = undefined; +try { + if (inspector) { + inspectorURL = inspector.url(); + } +} catch (err) { + // Failed to get inspector URL +} + +if (!process.stdout.isTTY && !inspectorURL) { + // When stdout is not a terminal and not attached to an Node.JS inspector, disable it to improve performance of SVR.JS + console.log = function () {}; + process.stdout.write = function () {}; + process.stdout._write = function () {}; + process.stdout._writev = function () {}; +} + // IP and network inteface-related var ifaces = {}; var ifaceEx = null; @@ -2163,19 +2186,23 @@ if (!cluster.isPrimary) { } } if (secure) { - sniCredentials.forEach(function (sniCredentialsSingle) { - server.addContext(sniCredentialsSingle.name, { - cert: sniCredentialsSingle.cert, - key: sniCredentialsSingle.key + try { + sniCredentials.forEach(function (sniCredentialsSingle) { + server.addContext(sniCredentialsSingle.name, { + cert: sniCredentialsSingle.cert, + key: sniCredentialsSingle.key + }); + try { + var snMatches = sniCredentialsSingle.name.match(/^([^:[]*|\[[^]]*\]?)((?::.*)?)$/); + if (!snMatches[1][0].match(/^\.+$/)) snMatches[1][0] = snMatches[1][0].replace(/\.+$/, ""); + server._contexts[server._contexts.length - 1][0] = new RegExp("^" + snMatches[1].replace(/([.^$+?\-\\[\]{}])/g, "\\$1").replace(/\*/g, "[^.:]*") + ((snMatches[1][0] == "[" || snMatches[1].match(/^(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/)) ? "" : "\.?") + snMatches[2].replace(/([.^$+?\-\\[\]{}])/g, "\\$1").replace(/\*/g, "[^.]*") + "$", "i"); + } catch (ex) { + // Can't replace regex, ignoring... + } }); - try { - var snMatches = sniCredentialsSingle.name.match(/^([^:[]*|\[[^]]*\]?)((?::.*)?)$/); - if (!snMatches[1][0].match(/^\.+$/)) snMatches[1][0] = snMatches[1][0].replace(/\.+$/, ""); - server._contexts[server._contexts.length - 1][0] = new RegExp("^" + snMatches[1].replace(/([.^$+?\-\\[\]{}])/g, "\\$1").replace(/\*/g, "[^.:]*") + ((snMatches[1][0] == "[" || snMatches[1].match(/^(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/)) ? "" : "\.?") + snMatches[2].replace(/([.^$+?\-\\[\]{}])/g, "\\$1").replace(/\*/g, "[^.]*") + "$", "i"); - } catch (ex) { - // Can't replace regex, ignoring... - } - }); + } catch (err) { + // SNI error + } } server.on("request", reqhandler); server.on("checkExpectation", reqhandler); diff --git a/tests.html b/tests.html index bb8f10c..5c4bccf 100644 --- a/tests.html +++ b/tests.html @@ -1,7 +1,7 @@ - SVR.JS 3.14.13 Tests + SVR.JS 3.14.14 Tests -

SVR.JS 3.14.13 Tests

+

SVR.JS 3.14.14 Tests

Directory (without trailing slash)

Directory (with query)