From: tobtoht Date: Fri, 3 Mar 2023 23:33:08 +0000 (+0100) Subject: prestium: read i2p port from env X-Git-Url: https://git.nutra.tk/v1?a=commitdiff_plain;h=3d7c88e10fb509bc5a1e741c5b570627d8bba55d;p=gamesguru%2Ffeather.git prestium: read i2p port from env --- diff --git a/src/main.cpp b/src/main.cpp index cf78968a..b40ce828 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -189,7 +189,7 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) { // Prestium initial config if (config()->get(Config::firstRun).toBool() && Prestium::detect()) { config()->set(Config::proxy, Config::Proxy::i2p); - config()->set(Config::socks5Port, 4448); + config()->set(Config::socks5Port, Prestium::i2pPort()); } if (parser.isSet("use-local-tor")) diff --git a/src/utils/os/Prestium.cpp b/src/utils/os/Prestium.cpp index 80a58291..4cfe081a 100644 --- a/src/utils/os/Prestium.cpp +++ b/src/utils/os/Prestium.cpp @@ -8,7 +8,24 @@ #include "utils/Utils.h" +#define PRESTIUM_DEFAULT_PORT 4448 + bool Prestium::detect() { return QSysInfo::prettyProductName().contains("Prestium"); +} + +int Prestium::i2pPort() +{ + QString portStr = qgetenv("PRESTIUM_FEATHER_I2P_PORT"); + if (portStr.isEmpty()) { + return PRESTIUM_DEFAULT_PORT; + } + + int port = portStr.toInt(); + if (port < 1 || port > 65535) { + return PRESTIUM_DEFAULT_PORT; + } + + return port; } \ No newline at end of file diff --git a/src/utils/os/Prestium.h b/src/utils/os/Prestium.h index 879c9a3d..66bf1b98 100644 --- a/src/utils/os/Prestium.h +++ b/src/utils/os/Prestium.h @@ -8,6 +8,7 @@ class Prestium { public: static bool detect(); + static int i2pPort(); }; #endif //FEATHER_PRESTIUM_H