summaryrefslogtreecommitdiff
path: root/pkg/vpn/status.go
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-08-26 00:35:01 +0200
committerkali kaneko (leap communications) <kali@leap.se>2021-05-04 14:58:38 +0200
commit2124a55d4a3d0ca00f8eab8f86c292ba1e7ccccf (patch)
treef6ded94b316c605a67b5c1f7342cb751affcfc75 /pkg/vpn/status.go
parented3f393b1a81f040406a2b622a82c8f86a27c460 (diff)
[feat] store gateway we connect to
firs step on an usable gateway selector
Diffstat (limited to 'pkg/vpn/status.go')
-rw-r--r--pkg/vpn/status.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/pkg/vpn/status.go b/pkg/vpn/status.go
index a4d7ada..cc2fb62 100644
--- a/pkg/vpn/status.go
+++ b/pkg/vpn/status.go
@@ -18,6 +18,7 @@ package vpn
import (
"fmt"
"log"
+ "strings"
"github.com/apparentlymart/go-openvpn-mgmt/openvpn"
)
@@ -66,10 +67,14 @@ func (b *Bitmask) eventHandler(eventCh <-chan openvpn.Event) {
if !ok {
continue
}
- status, ok := statusNames[stateEvent.NewState()]
+ statusName := stateEvent.NewState()
+ status, ok := statusNames[statusName]
if ok {
b.statusCh <- status
}
+ if statusName == "CONNECTED" {
+ b.onGateway = strings.Split(stateEvent.String(), ": ")[1]
+ }
}
b.statusCh <- Off
}