From 7decde6b58cd7ef43dcb6f6bb1c12d6618f2e1c5 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sun, 25 Aug 2024 13:10:28 +0200 Subject: [PATCH] Lint out the codebase --- src/index.js | 8 ++++++-- src/middleware/defaultHandlerChecks.js | 11 +++++++++-- .../nonStandardCodesAndHttpAuthentication.js | 10 +++++++--- .../staticFileServingAndDirectoryListings.js | 3 ++- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/index.js b/src/index.js index 59b8924..1557ce7 100644 --- a/src/index.js +++ b/src/index.js @@ -53,7 +53,9 @@ for ( console.log("-h -? /h /? --help -- Displays help"); console.log("--clean -- Cleans up files created by " + name); console.log( - "--reset -- Resets " + name + " to default settings (WARNING: DANGEROUS)", + "--reset -- Resets " + + name + + " to default settings (WARNING: DANGEROUS)", ); console.log("--secure -- Runs HTTPS server"); console.log("--disable-mods -- Disables mods (safe mode)"); @@ -98,7 +100,9 @@ for ( console.log("-h -? /h /? --help -- Displays help"); console.log("--clean -- Cleans up files created by " + name); console.log( - "--reset -- Resets " + name + " to default settings (WARNING: DANGEROUS)", + "--reset -- Resets " + + name + + " to default settings (WARNING: DANGEROUS)", ); console.log("--secure -- Runs HTTPS server"); console.log("--disable-mods -- Disables mods (safe mode)"); diff --git a/src/middleware/defaultHandlerChecks.js b/src/middleware/defaultHandlerChecks.js index ad54cbe..1fec49f 100644 --- a/src/middleware/defaultHandlerChecks.js +++ b/src/middleware/defaultHandlerChecks.js @@ -8,7 +8,12 @@ module.exports = (req, res, logFacilities, config, next) => { eheaders["Content-Type"] = "text/html; charset=utf-8"; res.writeHead(501, http.STATUS_CODES[501], eheaders); res.write( - 'Proxy not implemented

Proxy not implemented

SVR.JS doesn\'t support proxy without proxy mod. If you\'re administator of this server, then install this mod in order to use ' + name.replace(/&/g, "&").replace(//g, ">") + ' as a proxy.

' + + 'Proxy not implemented

Proxy not implemented

SVR.JS doesn\'t support proxy without proxy mod. If you\'re administator of this server, then install this mod in order to use ' + + name + .replace(/&/g, "&") + .replace(//g, ">") + + " as a proxy.

" + config .generateServerString() .replace(/&/g, "&") @@ -17,7 +22,9 @@ module.exports = (req, res, logFacilities, config, next) => { "

", ); res.end(); - logFacilities.errmessage(name + " doesn't support proxy without proxy mod."); + logFacilities.errmessage( + name + " doesn't support proxy without proxy mod.", + ); return; } diff --git a/src/middleware/nonStandardCodesAndHttpAuthentication.js b/src/middleware/nonStandardCodesAndHttpAuthentication.js index 2cf9957..1fd777d 100644 --- a/src/middleware/nonStandardCodesAndHttpAuthentication.js +++ b/src/middleware/nonStandardCodesAndHttpAuthentication.js @@ -5,6 +5,8 @@ const ipMatch = require("../utils/ipMatch.js"); const matchHostname = require("../utils/matchHostname.js"); const ipBlockList = require("../utils/ipBlockList.js"); const cluster = require("../utils/clusterBunShim.js"); +const svrjsInfo = require("../../svrjs.json"); +const { name } = svrjsInfo; // Brute force protection-related let bruteForceDb = {}; @@ -175,7 +177,8 @@ module.exports = (req, res, logFacilities, config, next) => { res.error( 500, new Error( - name + " doesn't support scrypt-hashed passwords on Node.JS versions without scrypt hash support.", + name + + " doesn't support scrypt-hashed passwords on Node.JS versions without scrypt hash support.", ), ); return; @@ -214,7 +217,8 @@ module.exports = (req, res, logFacilities, config, next) => { res.error( 500, new Error( - name + " doesn't support PBKDF2-hashed passwords on Node.JS versions without crypto support.", + name + + " doesn't support PBKDF2-hashed passwords on Node.JS versions without crypto support.", ), ); return; @@ -262,7 +266,7 @@ module.exports = (req, res, logFacilities, config, next) => { 'Basic realm="' + (authcode.realm ? authcode.realm.replace(/(\\|")/g, "\\$1") - : (name + " HTTP Basic Authorization")) + + : name + " HTTP Basic Authorization") + '", charset="UTF-8"'; const credentials = req.headers["authorization"]; if (!credentials) { diff --git a/src/middleware/staticFileServingAndDirectoryListings.js b/src/middleware/staticFileServingAndDirectoryListings.js index 510ecab..044c287 100644 --- a/src/middleware/staticFileServingAndDirectoryListings.js +++ b/src/middleware/staticFileServingAndDirectoryListings.js @@ -939,7 +939,8 @@ module.exports = (req, res, logFacilities, config, next) => { } else { res.error(501); logFacilities.errmessage( - name + " doesn't support block devices, character devices, FIFOs nor sockets.", + name + + " doesn't support block devices, character devices, FIFOs nor sockets.", ); return; }