prestium: read i2p port from env

This commit is contained in:
tobtoht 2023-03-04 00:33:08 +01:00
parent 33dd6f3c83
commit 3d7c88e10f
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
3 changed files with 19 additions and 1 deletions

View file

@ -189,7 +189,7 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
// Prestium initial config // Prestium initial config
if (config()->get(Config::firstRun).toBool() && Prestium::detect()) { if (config()->get(Config::firstRun).toBool() && Prestium::detect()) {
config()->set(Config::proxy, Config::Proxy::i2p); config()->set(Config::proxy, Config::Proxy::i2p);
config()->set(Config::socks5Port, 4448); config()->set(Config::socks5Port, Prestium::i2pPort());
} }
if (parser.isSet("use-local-tor")) if (parser.isSet("use-local-tor"))

View file

@ -8,7 +8,24 @@
#include "utils/Utils.h" #include "utils/Utils.h"
#define PRESTIUM_DEFAULT_PORT 4448
bool Prestium::detect() bool Prestium::detect()
{ {
return QSysInfo::prettyProductName().contains("Prestium"); 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;
} }

View file

@ -8,6 +8,7 @@
class Prestium { class Prestium {
public: public:
static bool detect(); static bool detect();
static int i2pPort();
}; };
#endif //FEATHER_PRESTIUM_H #endif //FEATHER_PRESTIUM_H