forked from svrjs/svrjs
Added default config.json setting from SVR.JS 3.x, and fixed core middleware.
This commit is contained in:
parent
2dda7d73ab
commit
be33f83ed1
2 changed files with 57 additions and 8 deletions
62
src/index.js
62
src/index.js
|
@ -18,14 +18,60 @@ const serverconsoleConstructor = require("./utils/serverconsole.js");
|
||||||
let configJSON = {};
|
let configJSON = {};
|
||||||
|
|
||||||
// TODO: configuration from config.json
|
// TODO: configuration from config.json
|
||||||
if (!configJSON.page404) configJSON.page404 = "404.html"
|
if (configJSON.users === undefined) configJSON.users = [];
|
||||||
if (!configJSON.errorPages) configJSON.errorPages = [];
|
if (configJSON.secure) {
|
||||||
if (!configJSON.stackHidden) configJSON.stackHidden = true;
|
if (configJSON.key === undefined) configJSON.key = "cert/key.key";
|
||||||
if (!configJSON.exposeServerVersion) configJSON.exposeServerVersion = false;
|
if (configJSON.cert === undefined) configJSON.cert = "cert/cert.crt";
|
||||||
if (!configJSON.exposeModsInErrorPages) configJSON.exposeModsInErrorPages = false;
|
if (configJSON.sport === undefined) configJSON.sport = 443;
|
||||||
if (!configJSON.enableLogging) configJSON.enableLogging = true;
|
if (configJSON.spubport === undefined) configJSON.spubport = 443;
|
||||||
if (!configJSON.serverAdministratorEmail) configJSON.serverAdministratorEmail = "webmaster@svrjs.org";
|
if (configJSON.sni === undefined) configJSON.sni = {};
|
||||||
if (!configJSON.customHeaders) configJSON.customHeaders = {};
|
if (configJSON.enableOCSPStapling === undefined) configJSON.enableOCSPStapling = false;
|
||||||
|
}
|
||||||
|
if (configJSON.port === undefined) configJSON.port = 80;
|
||||||
|
if (configJSON.pubport === undefined) configJSON.pubport = 80;
|
||||||
|
if (configJSON.domain === undefined && configJSON.domian !== undefined) configJSON.domain = configJSON.domian;
|
||||||
|
delete configJSON.domian;
|
||||||
|
if (configJSON.page404 === undefined) configJSON.page404 = "404.html";
|
||||||
|
//configJSON.timestamp = timestamp; //TODO
|
||||||
|
//configJSON.blacklist = blocklist.raw; //TODO
|
||||||
|
if (configJSON.nonStandardCodes === undefined) configJSON.nonStandardCodes = [];
|
||||||
|
if (configJSON.enableCompression === undefined) configJSON.enableCompression = true;
|
||||||
|
if (configJSON.customHeaders === undefined) configJSON.customHeaders = {};
|
||||||
|
if (configJSON.enableHTTP2 === undefined) configJSON.enableHTTP2 = false;
|
||||||
|
if (configJSON.enableLogging === undefined) configJSON.enableLogging = true;
|
||||||
|
if (configJSON.enableDirectoryListing === undefined) configJSON.enableDirectoryListing = true;
|
||||||
|
if (configJSON.enableDirectoryListingWithDefaultHead === undefined) configJSON.enableDirectoryListingWithDefaultHead = false;
|
||||||
|
if (configJSON.serverAdministratorEmail === undefined) configJSON.serverAdministratorEmail = "[no contact information]";
|
||||||
|
if (configJSON.stackHidden === undefined) configJSON.stackHidden = false;
|
||||||
|
if (configJSON.enableRemoteLogBrowsing === undefined) configJSON.enableRemoteLogBrowsing = false;
|
||||||
|
if (configJSON.exposeServerVersion === undefined) configJSON.exposeServerVersion = true;
|
||||||
|
if (configJSON.disableServerSideScriptExpose === undefined) configJSON.disableServerSideScriptExpose = true;
|
||||||
|
if (configJSON.allowStatus === undefined) configJSON.allowStatus = true;
|
||||||
|
if (configJSON.rewriteMap === undefined) configJSON.rewriteMap = [];
|
||||||
|
if (configJSON.dontCompress === undefined) configJSON.dontCompress = ["/.*\\.ipxe$/", "/.*\\.(?:jpe?g|png|bmp|tiff|jfif|gif|webp)$/", "/.*\\.(?:[id]mg|iso|flp)$/", "/.*\\.(?:zip|rar|bz2|[gb7x]z|lzma|tar)$/", "/.*\\.(?:mp[34]|mov|wm[av]|avi|webm|og[gv]|mk[va])$/"];
|
||||||
|
if (configJSON.enableIPSpoofing === undefined) configJSON.enableIPSpoofing = false;
|
||||||
|
if (configJSON.secure === undefined) configJSON.secure = false;
|
||||||
|
if (configJSON.disableNonEncryptedServer === undefined) configJSON.disableNonEncryptedServer = false;
|
||||||
|
if (configJSON.disableToHTTPSRedirect === undefined) configJSON.disableToHTTPSRedirect = false;
|
||||||
|
if (configJSON.enableETag === undefined) configJSON.enableETag = true;
|
||||||
|
if (configJSON.disableUnusedWorkerTermination === undefined) configJSON.disableUnusedWorkerTermination = false;
|
||||||
|
if (configJSON.rewriteDirtyURLs === undefined) configJSON.rewriteDirtyURLs = false;
|
||||||
|
if (configJSON.errorPages === undefined) configJSON.errorPages = [];
|
||||||
|
if (configJSON.useWebRootServerSideScript === undefined) configJSON.useWebRootServerSideScript = true;
|
||||||
|
if (configJSON.exposeModsInErrorPages === undefined) configJSON.exposeModsInErrorPages = true;
|
||||||
|
if (configJSON.disableTrailingSlashRedirects === undefined) configJSON.disableTrailingSlashRedirects = false;
|
||||||
|
if (configJSON.environmentVariables === undefined) configJSON.environmentVariables = {};
|
||||||
|
if (configJSON.allowDoubleSlashes === undefined) configJSON.allowDoubleSlashes = false;
|
||||||
|
if (configJSON.optOutOfStatisticsServer === undefined) configJSON.optOutOfStatisticsServer = false;
|
||||||
|
|
||||||
|
configJSON.version = version; // Compatiblity for very old SVR.JS mods
|
||||||
|
|
||||||
|
var wwwrootError = null;
|
||||||
|
try {
|
||||||
|
if (cluster.isPrimary || cluster.isPrimary === undefined) process.chdir(configJSON.wwwroot != undefined ? configJSON.wwwroot : __dirname);
|
||||||
|
} catch (err) {
|
||||||
|
wwwrootError = err;
|
||||||
|
}
|
||||||
|
|
||||||
const serverconsole = serverconsoleConstructor(configJSON.enableLogging);
|
const serverconsole = serverconsoleConstructor(configJSON.enableLogging);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@ const fs = require("fs");
|
||||||
const generateErrorStack = require("../utils/generateErrorStack.js");
|
const generateErrorStack = require("../utils/generateErrorStack.js");
|
||||||
const serverHTTPErrorDescs = require("../res/httpErrorDescriptions.js");
|
const serverHTTPErrorDescs = require("../res/httpErrorDescriptions.js");
|
||||||
const fixNodeMojibakeURL = require("../utils/urlMojibakeFixer.js");
|
const fixNodeMojibakeURL = require("../utils/urlMojibakeFixer.js");
|
||||||
|
const getOS = require("../utils/getOS.js");
|
||||||
|
const svrjsInfo = require("../../svrjs.json");
|
||||||
|
const version = svrjsInfo.version;
|
||||||
|
|
||||||
if (!process.err4xxcounter) process.err4xxcounter = 0;
|
if (!process.err4xxcounter) process.err4xxcounter = 0;
|
||||||
if (!process.err5xxcounter) process.err5xxcounter = 0;
|
if (!process.err5xxcounter) process.err5xxcounter = 0;
|
||||||
|
|
Reference in a new issue