Revert "update: change user_config.json to be a complete override instead of hacky override. copy config.json to user_config.json to get started."
Instead, fix it.
This commit is contained in:
@@ -789,10 +789,9 @@ async function handleSocket(socket) {
|
|||||||
|
|
||||||
function integrateConfig(main, user) {
|
function integrateConfig(main, user) {
|
||||||
Object.keys(user).forEach(function (k) {
|
Object.keys(user).forEach(function (k) {
|
||||||
if (typeof (user[k]) == 'object') {
|
if (typeof (user[k]) == 'object' && user[k] != null) {
|
||||||
// new entry
|
// new entry
|
||||||
if (!main[k]) main[k] = new Array();
|
if (!main[k]) main[k] = new Array();
|
||||||
|
|
||||||
// go down the rabbit hole
|
// go down the rabbit hole
|
||||||
main[k] = integrateConfig(main[k], user[k]);
|
main[k] = integrateConfig(main[k], user[k]);
|
||||||
} else {
|
} else {
|
||||||
@@ -819,33 +818,36 @@ function returnAbsolsutePath(path) {
|
|||||||
|
|
||||||
var z_title = "zefie's wtv minisrv v" + require('./package.json').version;
|
var z_title = "zefie's wtv minisrv v" + require('./package.json').version;
|
||||||
console.log("**** Welcome to " + z_title + " ****");
|
console.log("**** Welcome to " + z_title + " ****");
|
||||||
var read_config = false;
|
console.log(" *** Reading global configuration...");
|
||||||
|
try {
|
||||||
if (fs.existsSync(__dirname + "/user_config.json")) {
|
var minisrv_config = JSON.parse(fs.readFileSync(__dirname + "/config.json"));
|
||||||
try {
|
} catch (e) {
|
||||||
var minisrv_config = JSON.parse(fs.readFileSync(__dirname + "/user_config.json"));
|
throw ("ERROR: Could not read config.json", e);
|
||||||
console.log(" *** Reading user configuration...");
|
|
||||||
read_config = true;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.log("Error reading user_config.json, failling back to global config", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs.existsSync(__dirname + "/config.json") && !read_config) {
|
|
||||||
try {
|
|
||||||
console.log(" *** Reading global configuration...");
|
|
||||||
var minisrv_config = JSON.parse(fs.readFileSync(__dirname + "/config.json"));
|
|
||||||
read_config = true;
|
|
||||||
} catch (e) {
|
|
||||||
console.log ("ERROR: Could not read config.json", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var service_vaults = new Array();
|
var service_vaults = new Array();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (fs.lstatSync(__dirname + "/user_config.json")) {
|
||||||
|
console.log(" *** Reading user configuration...");
|
||||||
|
try {
|
||||||
|
var minisrv_user_config = JSON.parse(fs.readFileSync(__dirname + "/user_config.json"));
|
||||||
|
} catch (e) {
|
||||||
|
console.log("ERROR: Could not read user_config.json", e);
|
||||||
|
var throw_me = true;
|
||||||
|
}
|
||||||
|
// file exists and we read and parsed it, but the variable is undefined
|
||||||
|
// Likely a syntax parser error that did not trip the exception check above
|
||||||
|
try {
|
||||||
|
minisrv_config = integrateConfig(minisrv_config, minisrv_user_config)
|
||||||
|
} catch (e) {
|
||||||
|
console.log("ERROR: Could not read user_config.json", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (zdebug) console.log(" * Notice: Could not find user configuration (user_config.json). Using default configuration.");
|
||||||
|
}
|
||||||
|
|
||||||
if (!read_config) {
|
if (throw_me) {
|
||||||
throw ("An error has occured while reading the configuration files.");
|
throw ("An error has occured while reading the configuration files.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,16 +55,16 @@
|
|||||||
"http": {
|
"http": {
|
||||||
"port": 1650,
|
"port": 1650,
|
||||||
"connections": 3,
|
"connections": 3,
|
||||||
"use_external_proxy": true,
|
"use_external_proxy": false,
|
||||||
"external_proxy_is_socks": true,
|
"external_proxy_is_socks": false,
|
||||||
"external_proxy_host": "127.0.0.1",
|
"external_proxy_host": "127.0.0.1",
|
||||||
"external_proxy_port": 1080
|
"external_proxy_port": 1080
|
||||||
},
|
},
|
||||||
"https": {
|
"https": {
|
||||||
"port": 1650,
|
"port": 1650,
|
||||||
"connections": 3,
|
"connections": 3,
|
||||||
"use_external_proxy": true,
|
"use_external_proxy": false,
|
||||||
"external_proxy_is_socks": true,
|
"external_proxy_is_socks": false,
|
||||||
"external_proxy_host": "127.0.0.1",
|
"external_proxy_host": "127.0.0.1",
|
||||||
"external_proxy_port": 1080
|
"external_proxy_port": 1080
|
||||||
}
|
}
|
||||||
|
|||||||
26
zefie_wtvp_minisrv/user_config.example.json
Normal file
26
zefie_wtvp_minisrv/user_config.example.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"config": {
|
||||||
|
"service_ip": "192.168.11.8",
|
||||||
|
"service_name": "MyWebTV",
|
||||||
|
"send_tellyscripts": true,
|
||||||
|
"hide_ssid_in_logs": true,
|
||||||
|
"verbosity": 0
|
||||||
|
},
|
||||||
|
"services": {
|
||||||
|
"wtv-log": {
|
||||||
|
"write_logs_to_disk": true
|
||||||
|
},
|
||||||
|
"wtv-some-custom-service": {
|
||||||
|
"port": 1609,
|
||||||
|
"connections": 1
|
||||||
|
},
|
||||||
|
"wtv-tricks": {
|
||||||
|
"service_ip": "192.168.11.8",
|
||||||
|
"port": 1702,
|
||||||
|
"nobind": true
|
||||||
|
},
|
||||||
|
"wtv-music": {
|
||||||
|
"disabled": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user