From 998b5cb54ad23be1f6df0ee8abd08af5614f38db Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Thu, 24 Sep 2020 12:24:48 +0200 Subject: [feat] send cmd flags to the go backend Also disable autostart if manual quit, remove custom printer that was used for i18n and disable previous autostart if -disable-autostart We didn't disable autostart after the migration to qt. - Resolves: #355 #289 --- gui/main.cpp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'gui/main.cpp') diff --git a/gui/main.cpp b/gui/main.cpp index 4ba9dd6..42123ae 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -76,15 +76,50 @@ int main(int argc, char **argv) { "main", "Install helpers (linux only, requires sudo)."), }, + { + {"v", "version"}, + QApplication::translate( + "main", + "Version of the bitmask-vpn."), + }, + { + {"o", "obfs4"}, + QApplication::translate( + "main", + "Use obfs4 to obfuscate the traffic is available in the provider."), + }, + { + {"a", "disable-autostart"}, + QApplication::translate( + "main", + "Disable the autostart for the next run."), + }, + { + {"s", "start-vpn"}, + QApplication::translate( + "main", + "Start the vpn in turned 'on' or 'off'."), + }, }); QCommandLineOption webPortOption("web-port", QApplication::translate("main", "Web api port (default: 8080)"), "port", "8080"); parser.addOption(webPortOption); + QCommandLineOption startVPNOption("start-vpn", QApplication::translate("main", "Start the vpn in turned 'on' or 'off'."), "status", ""); + parser.addOption(startVPNOption); 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"); + bool version = parser.isSet("version"); + bool obfs4 = parser.isSet("obfs4"); + bool disAutostart = parser.isSet("disable-autostart"); + QString startVPN = parser.value("start-vpn"); + + if (version) { + qDebug() << backend.getVersion(); + exit(0); + } if (hideSystray) { qDebug() << "Not showing systray icon because --no-systray option is set."; @@ -152,7 +187,8 @@ int main(int argc, char **argv) { /* let the Go side initialize its internal state */ InitializeBitmaskContext( toGoStr(defaultProvider.toString()), - (char*)QProvidersJSON.toUtf8().data(), strlen(QProvidersJSON.toUtf8().data())); + (char*)QProvidersJSON.toUtf8().data(), strlen(QProvidersJSON.toUtf8().data()), + obfs4, disAutostart, toGoStr(startVPN)); /* if requested, enable web api for controlling the VPN */ if (webAPI) { -- cgit v1.2.3