add wtv-admin:/reloadconfig
This commit is contained in:
@@ -63,7 +63,7 @@ if (auth === true) {
|
||||
<tr>
|
||||
<td><a href="wtv-admin:/polyzoot">Polyzoot a User</a>
|
||||
<td width = 10>
|
||||
<td><!-- TODO -->
|
||||
<td><a href="wtv-admin:/reloadconfig">Reload Config</a>
|
||||
<tr>
|
||||
<td colspan=3 height=6>
|
||||
<tr>
|
||||
|
||||
56
zefie_wtvp_minisrv/ServiceVault/wtv-admin/reloadconfig.js
Normal file
56
zefie_wtvp_minisrv/ServiceVault/wtv-admin/reloadconfig.js
Normal file
@@ -0,0 +1,56 @@
|
||||
var minisrv_service_file = true;
|
||||
|
||||
var WTVAdmin = require("./WTVAdmin.js");
|
||||
var wtva = new WTVAdmin(minisrv_config, ssid_sessions[socket.ssid], service_name);
|
||||
var auth = wtva.isAuthorized();
|
||||
if (auth === true) {
|
||||
var password = null;
|
||||
if (request_headers.Authorization) {
|
||||
var authheader = request_headers.Authorization.split(' ');
|
||||
if (authheader[0] == "Basic") {
|
||||
password = Buffer.from(authheader[1], 'base64').toString();
|
||||
if (password) password = password.split(':')[1];
|
||||
}
|
||||
}
|
||||
if (wtva.checkPassword(password)) {
|
||||
reloadConfig();
|
||||
headers = `200 OK
|
||||
Content-Type: text/html
|
||||
wtv-expire-all: wtv-admin:/reloadconfig
|
||||
wtv-noback-all: wtv-admin:/reloadconfig`;
|
||||
data = `<html>
|
||||
<body>
|
||||
<display nosave nosend>
|
||||
<title>${minisrv_config.config.service_name} Admin Tricks</title>
|
||||
<sidebar width=20%>
|
||||
<img src="wtv-tricks:/images/Favorites_bg.jpg">
|
||||
</sidebar>
|
||||
<body bgcolor="#0a0a0a" text="#CC1111" link="#ff55ff" vlink="#ff55ff" vspace=0>
|
||||
<br>
|
||||
<br>
|
||||
<h1>${minisrv_config.config.service_name} Admin Tricks</h1>
|
||||
<br>
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan=3 height=6>
|
||||
<h3>Reload Config</h3>
|
||||
The config.json and user_config.json files has been reloaded.<br>
|
||||
If you added a new service, it will not bind without a restart.
|
||||
<tr>
|
||||
</table>
|
||||
<p align="right">
|
||||
<a href="client:goback">Go Back</a>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
} else {
|
||||
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
}
|
||||
} else {
|
||||
var errpage = wtvshared.doErrorPage(403, auth);
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
}
|
||||
@@ -164,8 +164,8 @@ class WTVShared {
|
||||
}
|
||||
|
||||
|
||||
readMiniSrvConfig(user_config = true, notices = true) {
|
||||
if (notices) console.log(" *** Reading global configuration...");
|
||||
readMiniSrvConfig(user_config = true, notices = true, reload_notice = false) {
|
||||
if (notices || reload_notice) console.log(" *** Reading global configuration...");
|
||||
try {
|
||||
var minisrv_config = JSON.parse(this.fs.readFileSync(__dirname + this.path.sep + "config.json"));
|
||||
} catch (e) {
|
||||
@@ -189,7 +189,7 @@ class WTVShared {
|
||||
|
||||
if (user_config) {
|
||||
try {
|
||||
if (notices) console.log(" *** Reading user configuration...");
|
||||
if (notices || reload_notice) console.log(" *** Reading user configuration...");
|
||||
var minisrv_user_config = this.getUserConfig()
|
||||
try {
|
||||
minisrv_config = integrateConfig(minisrv_config, minisrv_user_config)
|
||||
@@ -244,7 +244,7 @@ class WTVShared {
|
||||
}
|
||||
}
|
||||
|
||||
if (notices) console.log(" *** Configuration successfully read.");
|
||||
if (notices || reload_notice) console.log(" *** Configuration successfully read.");
|
||||
this.minisrv_config = minisrv_config;
|
||||
return this.minisrv_config;
|
||||
}
|
||||
|
||||
@@ -1732,7 +1732,7 @@ function getGitRevision() {
|
||||
var minisrv_config = null;
|
||||
|
||||
function reloadConfig() {
|
||||
minisrv_config = wtvshared.readMiniSrvConfig(true, false); // snatches minisrv_config
|
||||
minisrv_config = wtvshared.readMiniSrvConfig(true, false, true); // snatches minisrv_config
|
||||
return minisrv_config;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user