summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2021-03-24 12:47:02 +0100
committerkali kaneko (leap communications) <kali@leap.se>2021-05-04 14:58:39 +0200
commit4e1f3a4f88136e497962e4f976d5c7f216c31a15 (patch)
tree86fd6aea30aca3753b5be785eb684cbb3d205e6b
parentb14d048e6089233f5c698426652e85bfa1d89488 (diff)
Let's rename the API to use location instead of gateway
-rw-r--r--gui/backend.go6
-rw-r--r--gui/handlers.cpp4
-rw-r--r--gui/handlers.h2
-rw-r--r--gui/qml/main.qml2
-rw-r--r--pkg/backend/actions.go8
-rw-r--r--pkg/backend/api.go4
-rw-r--r--pkg/backend/webapi.go3
-rw-r--r--pkg/bitmask/bitmask.go2
-rw-r--r--pkg/vpn/openvpn.go3
9 files changed, 12 insertions, 22 deletions
diff --git a/gui/backend.go b/gui/backend.go
index 3e312cf..064bd94 100644
--- a/gui/backend.go
+++ b/gui/backend.go
@@ -30,9 +30,9 @@ func SwitchOff() {
backend.SwitchOff()
}
-//export UseGateway
-func UseGateway(label string) {
- backend.UseGateway(label)
+//export UseLocation
+func UseLocation(label string) {
+ backend.UseLocation(label)
}
//export UseTransport
diff --git a/gui/handlers.cpp b/gui/handlers.cpp
index 370c67c..558c288 100644
--- a/gui/handlers.cpp
+++ b/gui/handlers.cpp
@@ -42,9 +42,9 @@ void Backend::donateSeen()
DonateSeen();
}
-void Backend::useGateway(QString label)
+void Backend::useLocation(QString label)
{
- UseGateway(toGoStr(label));
+ UseLocation(toGoStr(label));
}
void Backend::login(QString username, QString password)
diff --git a/gui/handlers.h b/gui/handlers.h
index a783207..9d949fc 100644
--- a/gui/handlers.h
+++ b/gui/handlers.h
@@ -36,7 +36,7 @@ public slots:
void switchOff();
void donateAccepted();
void donateSeen();
- void useGateway(QString username);
+ void useLocation(QString username);
void login(QString username, QString password);
void resetError(QString errlabel);
void resetNotification(QString label);
diff --git a/gui/qml/main.qml b/gui/qml/main.qml
index dae5ee5..211dbe5 100644
--- a/gui/qml/main.qml
+++ b/gui/qml/main.qml
@@ -163,7 +163,7 @@ Window {
model: [qsTr("Automatic")]
onActivated: {
console.debug("Selected gateway:", currentText)
- backend.useGateway(currentText.toString())
+ backend.useLocation(currentText.toString())
}
}
} // end column
diff --git a/pkg/backend/actions.go b/pkg/backend/actions.go
index 6e143f9..1860b09 100644
--- a/pkg/backend/actions.go
+++ b/pkg/backend/actions.go
@@ -20,14 +20,6 @@ func stopVPN() {
}
}
-// TODO return bool?
-func useGateway(label string) {
- err := ctx.bm.UseGateway(label)
- if err != nil {
- log.Println(err)
- }
-}
-
func getGateway() string {
return ctx.bm.GetCurrentGateway()
}
diff --git a/pkg/backend/api.go b/pkg/backend/api.go
index 761c03d..f1fed57 100644
--- a/pkg/backend/api.go
+++ b/pkg/backend/api.go
@@ -57,8 +57,8 @@ func SwitchOff() {
// TODO implement Reconnect - do not tear whole fw down in between
-func UseGateway(label string) {
- ctx.bm.UseGateway(string(label))
+func UseLocation(label string) {
+ ctx.bm.UseGateway(label)
time.Sleep(200 * time.Millisecond)
SwitchOff()
time.Sleep(500 * time.Millisecond)
diff --git a/pkg/backend/webapi.go b/pkg/backend/webapi.go
index 3e4efd3..903112e 100644
--- a/pkg/backend/webapi.go
+++ b/pkg/backend/webapi.go
@@ -51,8 +51,7 @@ func webGatewaySet(w http.ResponseWriter, r *http.Request) {
}
gwLabel := r.FormValue("gw")
fmt.Fprintf(w, "selected gateway: %s\n", gwLabel)
- // FIXME catch error here, return it (error code)
- useGateway(gwLabel)
+ ctx.bm.UseGateway(gwLabel)
// TODO make sure we don't tear the fw down on reconnect...
SwitchOff()
// a little sleep is needed, though, because iptables takes some time
diff --git a/pkg/bitmask/bitmask.go b/pkg/bitmask/bitmask.go
index cb7be29..eb2a833 100644
--- a/pkg/bitmask/bitmask.go
+++ b/pkg/bitmask/bitmask.go
@@ -27,7 +27,7 @@ type Bitmask interface {
InstallHelpers() error
VPNCheck() (helpers bool, priviledge bool, err error)
ListLocationFullness(protocol string) map[string]float64
- UseGateway(name string) error
+ UseGateway(name string)
GetCurrentGateway() string
GetCurrentLocation() string
UseTransport(transport string) error
diff --git a/pkg/vpn/openvpn.go b/pkg/vpn/openvpn.go
index 1447458..e4d2781 100644
--- a/pkg/vpn/openvpn.go
+++ b/pkg/vpn/openvpn.go
@@ -235,9 +235,8 @@ func (b *Bitmask) ListLocationFullness(transport string) map[string]float64 {
}
// UseGateway selects a gateway, by label, as the default gateway
-func (b *Bitmask) UseGateway(label string) error {
+func (b *Bitmask) UseGateway(label string) {
b.bonafide.SetManualGateway(label)
- return nil
}
// UseTransport selects an obfuscation transport to use