summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2020-09-24 12:24:48 +0200
committerRuben Pollan <meskio@sindominio.net>2020-09-24 16:50:04 +0200
commit998b5cb54ad23be1f6df0ee8abd08af5614f38db (patch)
treeaafb1c6f11ba23da120b29170ed712d6a07d5336 /gui
parent3a74c28cce41fe783d9dde707ebb6de941d5cf0a (diff)
[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
Diffstat (limited to 'gui')
-rw-r--r--gui/backend.go8
-rw-r--r--gui/main.cpp38
2 files changed, 44 insertions, 2 deletions
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) {