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/backend.go | 8 +++++++- gui/main.cpp | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) (limited to 'gui') diff --git a/gui/backend.go b/gui/backend.go index 7632bb4..92fbb97 100644 --- a/gui/backend.go +++ b/gui/backend.go @@ -53,9 +53,15 @@ func SubscribeToEvent(event string, f unsafe.Pointer) { } //export InitializeBitmaskContext -func InitializeBitmaskContext(provider string, jsonPtr unsafe.Pointer, jsonLen C.int) { +func InitializeBitmaskContext(provider string, + jsonPtr unsafe.Pointer, jsonLen C.int, + obfs4 bool, disableAutostart bool, startVPN string) { + json := C.GoBytes(jsonPtr, jsonLen) opts := backend.InitOptsFromJSON(provider, string(json)) + opts.Obfs4 = obfs4 + opts.DisableAutostart = disableAutostart + opts.StartVPN = startVPN backend.InitializeBitmaskContext(opts) } 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