From 5ba62c56b2a94b9f5ae06b150713f84d5a3144fa Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Tue, 11 Aug 2020 22:38:13 +0200 Subject: [refactor] simplify, make port optional --- gui/main.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'gui/main.cpp') diff --git a/gui/main.cpp b/gui/main.cpp index 6d01d49..2a300e2 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -69,7 +69,7 @@ int main(int argc, char **argv) { {"w", "web-api"}, QApplication::translate( "main", - "Enable web api (on port 8080)."), + "Enable web api."), }, { {"i", "install-helpers"}, @@ -78,11 +78,14 @@ int main(int argc, char **argv) { "Install helpers (linux only, requires sudo)."), }, }); + QCommandLineOption webPortOption("web-port", QApplication::translate("main", "Web api port (default: 8080)"), "port", "8080"); + parser.addOption(webPortOption); parser.process(app); bool hideSystray = parser.isSet("no-systray"); bool installHelpers = parser.isSet("install-helpers"); bool webAPI = parser.isSet("web-api"); + QString webPort = parser.value("web-port"); if (hideSystray) { qDebug() << "Not showing systray icon because --no-systray option is set."; @@ -140,7 +143,11 @@ int main(int argc, char **argv) { InitializeBitmaskContext(); /* if requested, enable web api for controlling the VPN */ - if (webAPI) { EnableWebAPI(); }; + if (webAPI) { + char* wp = webPort.toLocal8Bit().data(); + GoString p = {wp, (long int)strlen(wp)}; + EnableWebAPI(p); + }; /* kick off your shoes, put your feet up */ return app.exec(); -- cgit v1.2.3