*namespace all core options

This commit is contained in:
Derrick Hammer 2023-04-18 20:12:01 -04:00
parent d3d0f387b6
commit f720f40f05
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
5 changed files with 13 additions and 14 deletions

View File

@ -19,21 +19,20 @@ switch (os.platform()) {
case "linux":
default:
configDir = "/etc/lumeweb/relay/config.d";
configDir = "/etc/lumeweb/relay/conf.d";
break;
}
config.inject({
configDir,
port: 8080,
logLevel: "info",
pluginDir: path.resolve(configDir, "..", "plugins"),
cache: true,
"core.confdir": configDir,
"core.port": 8080,
"core.loglevel": "info",
"core.plugindir": path.resolve(configDir, "..", "plugins"),
});
config.load();
configDir = config.str("configdir");
configDir = config.str("core.confdir");
if (fs.existsSync(configDir)) {
try {
@ -45,6 +44,6 @@ if (fs.existsSync(configDir)) {
config.load();
log.level = config.get("loglevel");
log.level = config.get("core.loglevel");
export default config;

View File

@ -8,7 +8,7 @@ import b4a from "b4a";
const BIP44_PATH = "m/44'/1627'/0'/0'/0'";
export function getSeed() {
const seed = config.str("seed");
const seed = config.str("core.seed");
let valid = bip39.validateMnemonic(seed, wordlist);
if (!valid) {

View File

@ -130,7 +130,7 @@ export class PluginAPIManager {
const paths = [];
for (const modulePath of [`${moduleName}.js`, `${moduleName}.mjs`]) {
const fullPath = path.join(config.get("plugindir"), modulePath);
const fullPath = path.join(config.get("core.plugindir"), modulePath);
if (fs.existsSync(fullPath)) {
paths.push(fullPath);
break;
@ -239,7 +239,7 @@ export async function loadPlugins() {
await apiManager.loadPluginInstance(plugin);
}
for (const plugin of [...new Set(config.array("plugins", []))] as []) {
for (const plugin of [...new Set(config.array("core.plugins", []))] as []) {
await apiManager.loadPlugin(plugin);
}

View File

@ -38,5 +38,5 @@ export async function start() {
relay(dht, new Stream(false, connection.socket));
});
await relayServer.listen({ port: config.uint("port"), host: "0.0.0.0" });
await relayServer.listen({ port: config.uint("core.port"), host: "0.0.0.0" });
}

View File

@ -51,7 +51,7 @@ export class SSLManager {
}
get enabled() {
return config.bool("ssl") && this._renewHandler;
return config.bool("core.ssl") && this._renewHandler;
}
}
@ -59,7 +59,7 @@ let sslManager: SSLManager;
export function get(): SSLManager {
if (!sslManager) {
sslManager = new SSLManager(config.get("domain"));
sslManager = new SSLManager(config.get("core.domain"));
}
return sslManager;