refactor: add new setting core.relayPort to override core.port for reverse proxies. core.port will be used by plugins, but core.relayPort may be used by core

This commit is contained in:
Derrick Hammer 2023-07-04 00:51:39 -04:00
parent ca7ba89dd7
commit 7e17b477bd
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 8 additions and 1 deletions

View File

@ -26,6 +26,7 @@ switch (os.platform()) {
config.inject({ config.inject({
"core.confDir": configDir, "core.confDir": configDir,
"core.port": 8080, "core.port": 8080,
"core.relayPort": 0,
"core.appPort": 80, "core.appPort": 80,
"core.logLevel": "info", "core.logLevel": "info",
"core.pluginDir": path.resolve(configDir, "..", "plugins"), "core.pluginDir": path.resolve(configDir, "..", "plugins"),

View File

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