diff --git a/src/config.ts b/src/config.ts index ae0a443..e4b4089 100644 --- a/src/config.ts +++ b/src/config.ts @@ -26,6 +26,7 @@ switch (os.platform()) { config.inject({ "core.confDir": configDir, "core.port": 8080, + "core.relayPort": 0, "core.appPort": 80, "core.logLevel": "info", "core.pluginDir": path.resolve(configDir, "..", "plugins"), diff --git a/src/modules/relay.ts b/src/modules/relay.ts index a0d82fa..6990852 100644 --- a/src/modules/relay.ts +++ b/src/modules/relay.ts @@ -29,5 +29,11 @@ export async function start() { 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" }); }