forked from svrjs/svrjs
Add notice about user being logged in.
This commit is contained in:
parent
9946c301e4
commit
8dd707c44d
2 changed files with 30 additions and 29 deletions
|
@ -3,7 +3,7 @@
|
|||
"port": 80,
|
||||
"pubport": 80,
|
||||
"page404": "404.html",
|
||||
"timestamp": 1693728019823,
|
||||
"timestamp": 1693729629944,
|
||||
"blacklist": [],
|
||||
"nonStandardCodes": [],
|
||||
"enableCompression": true,
|
||||
|
|
13
svr.js
13
svr.js
|
@ -1978,6 +1978,7 @@ if (!cluster.isPrimary) {
|
|||
});
|
||||
|
||||
server2.on("listening", function () {
|
||||
attmtsRedir = 5;
|
||||
listeningMessage();
|
||||
});
|
||||
|
||||
|
@ -3405,7 +3406,9 @@ if (!cluster.isPrimary) {
|
|||
res.end((head == "" ? "<html><head><title>SVR.JS status" + (req.headers.host == undefined ? "" : " for " + String(req.headers.host).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")) + "</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /></head><body>" : head.replace(/<head>/i, "<head><title>SVR.JS status" + (req.headers.host == undefined ? "" : " for " + String(req.headers.host).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")) + "</title>")) + "<h1>SVR.JS status" + (req.headers.host == undefined ? "" : " for " + String(req.headers.host).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")) + "</h1>Server version: " + (exposeServerVersion ? "SVR.JS/" + version + " (" + getOS() + "; " + (process.isBun ? ("Bun/v" + process.versions.bun + "; like Node.JS/" + process.version) : ("Node.JS/" + process.version)) + ")" : "SVR.JS") + "<br/><hr/>Current time: " + new Date().toString() + "<br/>Thread start time: " + new Date(new Date() - (process.uptime() * 1000)).toString() + "<br/>Thread uptime: " + formatRelativeTime(Math.floor(process.uptime())) + "<br/>OS uptime: " + formatRelativeTime(os.uptime()) + "<br/>Total request count: " + reqcounter + "<br/>Average request rate: " + (Math.round((reqcounter / process.uptime()) * 100) / 100) + " requests/s" + (process.memoryUsage ? ("<br/>Memory usage of thread: " + sizify(process.memoryUsage().rss) + "B") : "") + (process.cpuUsage ? ("<br/>Total CPU usage by thread: u" + (process.cpuUsage().user / 1000) + "ms s" + (process.cpuUsage().system / 1000) + "ms - " + (Math.round((((process.cpuUsage().user + process.cpuUsage().system) / 1000000) / process.uptime()) * 1000) / 1000) + "%") : "") + "<br/>Thread PID: " + process.pid + "<br/>" + (foot == "" ? "</body></html>" : foot));
|
||||
return;
|
||||
} else if (version.indexOf("Nightly-") === 0 && (href == "/crash.svr" || (os.platform() == "win32" && href.toLowerCase() == "/crash.svr"))) {
|
||||
process.nextTick(function () {
|
||||
throw new Error("Intentionally crashed");
|
||||
});
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
|
@ -4446,7 +4449,7 @@ if (!cluster.isPrimary) {
|
|||
}
|
||||
}
|
||||
callServerError(401, undefined, undefined, ha);
|
||||
serverconsole.errmessage("User " + username + " failed to log in.");
|
||||
serverconsole.errmessage("User \"" + username + "\" failed to log in.");
|
||||
} else {
|
||||
if (bruteProtection) {
|
||||
if (process.send) {
|
||||
|
@ -4457,6 +4460,7 @@ if (!cluster.isPrimary) {
|
|||
};
|
||||
}
|
||||
}
|
||||
serverconsole.reqmessage("Client is logged in as \"" + username + "\"");
|
||||
modExecute(mods, vres(req, res, serverconsole, responseEnd, href, ext, uobject, search, "index.html", users, page404, head, foot, fd, callServerError, getCustomHeaders, origHref, redirect, parsePostData));
|
||||
}
|
||||
} catch(err) {
|
||||
|
@ -4505,12 +4509,8 @@ if (!cluster.isPrimary) {
|
|||
}
|
||||
}
|
||||
} catch (err) {
|
||||
//CRASH HANDLER
|
||||
if (err.message == "Intentionally crashed") throw err; //If intentionally crashed, then crash SVR.JS
|
||||
callServerError(500, undefined, generateErrorStack(err)); //Else just return 500 error
|
||||
callServerError(500, undefined, generateErrorStack(err));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
server.on("error", function (err) {
|
||||
|
@ -4584,6 +4584,7 @@ if (!cluster.isPrimary) {
|
|||
});
|
||||
|
||||
server.on("listening", function () {
|
||||
attmts = 5;
|
||||
listeningMessage();
|
||||
});
|
||||
}
|
||||
|
|
Reference in a new issue