From f720f40f05d5ed5193dfe86827a5b90323c2d682 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 18 Apr 2023 20:12:01 -0400 Subject: [PATCH] *namespace all core options --- src/config.ts | 15 +++++++-------- src/lib/seed.ts | 2 +- src/modules/plugin.ts | 4 ++-- src/modules/relay.ts | 2 +- src/modules/ssl.ts | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/config.ts b/src/config.ts index 18309e7..e175bc6 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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; diff --git a/src/lib/seed.ts b/src/lib/seed.ts index 6355b8a..cb0be8b 100644 --- a/src/lib/seed.ts +++ b/src/lib/seed.ts @@ -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) { diff --git a/src/modules/plugin.ts b/src/modules/plugin.ts index 5675746..55acc9b 100644 --- a/src/modules/plugin.ts +++ b/src/modules/plugin.ts @@ -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); } diff --git a/src/modules/relay.ts b/src/modules/relay.ts index 0d0e564..53cdf82 100644 --- a/src/modules/relay.ts +++ b/src/modules/relay.ts @@ -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" }); } diff --git a/src/modules/ssl.ts b/src/modules/ssl.ts index 322ab06..a4f2da4 100644 --- a/src/modules/ssl.ts +++ b/src/modules/ssl.ts @@ -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;