1
0
Fork 0
forked from svrjs/svrjs

Replace "SVR.JS" with references to svrjs.json file

This commit is contained in:
Dorian Niemiec 2024-08-25 13:09:58 +02:00
parent 04ab80cc95
commit fcec27fee1
6 changed files with 24 additions and 16 deletions

View file

@ -1,4 +1,6 @@
const generateServerString = require("../utils/generateServerString");
const svrjsInfo = require("../../svrjs.json");
const { name } = svrjsInfo;
let serverconsole = {};
let middleware = [];
@ -79,7 +81,7 @@ function proxyHandler(req, socket, head) {
}
} else {
logFacilities.errmessage(
"SVR.JS doesn't support proxy without proxy mod.",
name + " doesn't support proxy without proxy mod.",
);
if (!socket.destroyed) socket.end("HTTP/1.1 501 Not Implemented\n\n");
}

View file

@ -3,7 +3,7 @@ const fs = require("fs");
const generateServerString = require("./utils/generateServerString.js");
const deleteFolderRecursive = require("./utils/deleteFolderRecursive.js");
const svrjsInfo = require("../svrjs.json");
const { version } = svrjsInfo;
const { name, version } = svrjsInfo;
let inspector = undefined;
try {
@ -46,14 +46,14 @@ for (
args[i] == "/h" ||
args[i] == "/?"
) {
console.log("SVR.JS usage:");
console.log(name + " usage:");
console.log(
"node svr.js [-h] [--help] [-?] [/h] [/?] [--secure] [--reset] [--clean] [--disable-mods] [--single-threaded] [-v] [--version]",
);
console.log("-h -? /h /? --help -- Displays help");
console.log("--clean -- Cleans up files created by SVR.JS");
console.log("--clean -- Cleans up files created by " + name);
console.log(
"--reset -- Resets SVR.JS 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)");
@ -91,14 +91,14 @@ for (
process.singlethreaded = true;
} else {
console.log("Unrecognized argument: " + args[i]);
console.log("SVR.JS usage:");
console.log(name + " usage:");
console.log(
"node svr.js [-h] [--help] [-?] [/h] [/?] [--secure] [--reset] [--clean] [--disable-mods] [--single-threaded] [-v] [--version]",
);
console.log("-h -? /h /? --help -- Displays help");
console.log("--clean -- Cleans up files created by SVR.JS");
console.log("--clean -- Cleans up files created by " + name);
console.log(
"--reset -- Resets SVR.JS 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)");

View file

@ -6,6 +6,8 @@ const {
isIndexOfForbiddenPath,
forbiddenPaths,
} = require("../utils/forbiddenPaths.js");
const svrjsInfo = require("../../svrjs.json");
const { name } = svrjsInfo;
forbiddenPaths.config = getInitializePath("./config.json");
forbiddenPaths.certificates = [];
@ -88,7 +90,7 @@ module.exports = (req, res, logFacilities, config, next) => {
!config.exposeServerVersion
) {
res.error(403);
logFacilities.errmessage("Access to SVR.JS script is denied.");
logFacilities.errmessage("Access to " + name + " script is denied.");
return;
} else if (
(isForbiddenPath(decodedHrefWithoutDuplicateSlashes, "svrjs") ||

View file

@ -1,4 +1,6 @@
const http = require("http");
const svrjsInfo = require("../../svrjs.json");
const { name } = svrjsInfo;
module.exports = (req, res, logFacilities, config, next) => {
if (req.isProxy) {
@ -6,7 +8,7 @@ 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(
'<!DOCTYPE html><html><head><title>Proxy not implemented</title><meta name="viewport" content="width=device-width, initial-scale=1.0" /><style>html{background-color:#dfffdf;color:#000000;font-family:FreeSans, Helvetica, Tahoma, Verdana, Arial, sans-serif;margin:0.75em}body{background-color:#ffffff;padding:0.5em 0.5em 0.1em;margin:0.5em auto;width:90%;max-width:800px;-webkit-box-shadow:0 5px 10px 0 rgba(0, 0, 0, 0.15);-moz-box-shadow:0 5px 10px 0 rgba(0, 0, 0, 0.15);box-shadow:0 5px 10px 0 rgba(0, 0, 0, 0.15)}h1{text-align:center;font-size:2.25em;margin:0.3em 0 0.5em}code{background-color:#dfffdf;-webkit-box-shadow:0 2px 4px 0 rgba(0, 0, 0, 0.1);-moz-box-shadow:0 2px 4px 0 rgba(0, 0, 0, 0.1);box-shadow:0 2px 4px 0 rgba(0, 0, 0, 0.1);display:block;padding:0.2em;font-family:"DejaVu Sans Mono", "Bitstream Vera Sans Mono", Hack, Menlo, Consolas, Monaco, monospace;font-size:0.85em;margin:auto;width:95%;max-width:600px}table{width:95%;border-collapse:collapse;margin:auto;overflow-wrap:break-word;word-wrap:break-word;word-break:break-all;word-break:break-word;position:relative;z-index:0}table tbody{background-color:#ffffff;color:#000000}table tbody:after{-webkit-box-shadow:0 4px 8px 0 rgba(0, 0, 0, 0.175);-moz-box-shadow:0 4px 8px 0 rgba(0, 0, 0, 0.175);box-shadow:0 4px 8px 0 rgba(0, 0, 0, 0.175);content:\' \';position:absolute;top:0;left:0;right:0;bottom:0;z-index:-1}table img{margin:0;display:inline}th,tr{padding:0.15em;text-align:center}th{background-color:#007000;color:#ffffff}th a{color:#ffffff}td,th{padding:0.225em}td{text-align:left}tr:nth-child(odd){background-color:#dfffdf}hr{color:#ffffff}@media screen and (prefers-color-scheme: dark){html{background-color:#002000;color:#ffffff}body{background-color:#000f00;-webkit-box-shadow:0 5px 10px 0 rgba(127, 127, 127, 0.15);-moz-box-shadow:0 5px 10px 0 rgba(127, 127, 127, 0.15);box-shadow:0 5px 10px 0 rgba(127, 127, 127, 0.15)}code{background-color:#002000;-webkit-box-shadow:0 2px 4px 0 rgba(127, 127, 127, 0.1);-moz-box-shadow:0 2px 4px 0 rgba(127, 127, 127, 0.1);box-shadow:0 2px 4px 0 rgba(127, 127, 127, 0.1)}a{color:#ffffff}a:hover{color:#00ff00}table tbody{background-color:#000f00;color:#ffffff}table tbody:after{-webkit-box-shadow:0 4px 8px 0 rgba(127, 127, 127, 0.175);-moz-box-shadow:0 4px 8px 0 rgba(127, 127, 127, 0.175);box-shadow:0 4px 8px 0 rgba(127, 127, 127, 0.175)}tr:nth-child(odd){background-color:#002000}}</style></head><body><h1>Proxy not implemented</h1><p>SVR.JS doesn\'t support proxy without proxy mod. If you\'re administator of this server, then install this mod in order to use SVR.JS as a proxy.</p><p><i>' +
'<!DOCTYPE html><html><head><title>Proxy not implemented</title><meta name="viewport" content="width=device-width, initial-scale=1.0" /><style>html{background-color:#dfffdf;color:#000000;font-family:FreeSans, Helvetica, Tahoma, Verdana, Arial, sans-serif;margin:0.75em}body{background-color:#ffffff;padding:0.5em 0.5em 0.1em;margin:0.5em auto;width:90%;max-width:800px;-webkit-box-shadow:0 5px 10px 0 rgba(0, 0, 0, 0.15);-moz-box-shadow:0 5px 10px 0 rgba(0, 0, 0, 0.15);box-shadow:0 5px 10px 0 rgba(0, 0, 0, 0.15)}h1{text-align:center;font-size:2.25em;margin:0.3em 0 0.5em}code{background-color:#dfffdf;-webkit-box-shadow:0 2px 4px 0 rgba(0, 0, 0, 0.1);-moz-box-shadow:0 2px 4px 0 rgba(0, 0, 0, 0.1);box-shadow:0 2px 4px 0 rgba(0, 0, 0, 0.1);display:block;padding:0.2em;font-family:"DejaVu Sans Mono", "Bitstream Vera Sans Mono", Hack, Menlo, Consolas, Monaco, monospace;font-size:0.85em;margin:auto;width:95%;max-width:600px}table{width:95%;border-collapse:collapse;margin:auto;overflow-wrap:break-word;word-wrap:break-word;word-break:break-all;word-break:break-word;position:relative;z-index:0}table tbody{background-color:#ffffff;color:#000000}table tbody:after{-webkit-box-shadow:0 4px 8px 0 rgba(0, 0, 0, 0.175);-moz-box-shadow:0 4px 8px 0 rgba(0, 0, 0, 0.175);box-shadow:0 4px 8px 0 rgba(0, 0, 0, 0.175);content:\' \';position:absolute;top:0;left:0;right:0;bottom:0;z-index:-1}table img{margin:0;display:inline}th,tr{padding:0.15em;text-align:center}th{background-color:#007000;color:#ffffff}th a{color:#ffffff}td,th{padding:0.225em}td{text-align:left}tr:nth-child(odd){background-color:#dfffdf}hr{color:#ffffff}@media screen and (prefers-color-scheme: dark){html{background-color:#002000;color:#ffffff}body{background-color:#000f00;-webkit-box-shadow:0 5px 10px 0 rgba(127, 127, 127, 0.15);-moz-box-shadow:0 5px 10px 0 rgba(127, 127, 127, 0.15);box-shadow:0 5px 10px 0 rgba(127, 127, 127, 0.15)}code{background-color:#002000;-webkit-box-shadow:0 2px 4px 0 rgba(127, 127, 127, 0.1);-moz-box-shadow:0 2px 4px 0 rgba(127, 127, 127, 0.1);box-shadow:0 2px 4px 0 rgba(127, 127, 127, 0.1)}a{color:#ffffff}a:hover{color:#00ff00}table tbody{background-color:#000f00;color:#ffffff}table tbody:after{-webkit-box-shadow:0 4px 8px 0 rgba(127, 127, 127, 0.175);-moz-box-shadow:0 4px 8px 0 rgba(127, 127, 127, 0.175);box-shadow:0 4px 8px 0 rgba(127, 127, 127, 0.175)}tr:nth-child(odd){background-color:#002000}}</style></head><body><h1>Proxy not implemented</h1><p>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, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;") + ' as a proxy.</p><p><i>' +
config
.generateServerString()
.replace(/&/g, "&amp;")
@ -15,7 +17,7 @@ module.exports = (req, res, logFacilities, config, next) => {
"</i></p></body></html>",
);
res.end();
logFacilities.errmessage("SVR.JS doesn't support proxy without proxy mod.");
logFacilities.errmessage(name + " doesn't support proxy without proxy mod.");
return;
}

View file

@ -144,7 +144,7 @@ module.exports = (req, res, logFacilities, config, next) => {
} else if (nonscode.scode == 410) {
logFacilities.errmessage("Content is gone.");
} else if (nonscode.scode == 418) {
logFacilities.errmessage("SVR.JS is always a teapot ;)");
logFacilities.errmessage(name + " is always a teapot ;)");
} else {
logFacilities.errmessage("Client fails receiving content.");
}
@ -175,7 +175,7 @@ module.exports = (req, res, logFacilities, config, next) => {
res.error(
500,
new Error(
"SVR.JS 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 +214,7 @@ module.exports = (req, res, logFacilities, config, next) => {
res.error(
500,
new Error(
"SVR.JS 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 +262,7 @@ module.exports = (req, res, logFacilities, config, next) => {
'Basic realm="' +
(authcode.realm
? authcode.realm.replace(/(\\|")/g, "\\$1")
: "SVR.JS HTTP Basic Authorization") +
: (name + " HTTP Basic Authorization")) +
'", charset="UTF-8"';
const credentials = req.headers["authorization"];
if (!credentials) {

View file

@ -8,6 +8,8 @@ const ipMatch = require("../utils/ipMatch.js");
const createRegex = require("../utils/createRegex.js");
const sha256 = require("../utils/sha256.js");
const sizify = require("../utils/sizify.js");
const svrjsInfo = require("../../svrjs.json");
const { name } = svrjsInfo;
// ETag-related
let ETagDB = {};
@ -937,7 +939,7 @@ module.exports = (req, res, logFacilities, config, next) => {
} else {
res.error(501);
logFacilities.errmessage(
"SVR.JS doesn't support block devices, character devices, FIFOs nor sockets.",
name + " doesn't support block devices, character devices, FIFOs nor sockets.",
);
return;
}