Skip to content
Snippets Groups Projects
Commit 2124a55d authored by Kali Kaneko's avatar Kali Kaneko
Browse files

[feat] store gateway we connect to

firs step on an usable gateway selector
parent ed3f393b
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ import (
// Bitmask holds the bitmask client data
type Bitmask struct {
tempdir string
onGateway string
statusCh chan string
managementClient *openvpn.MgmtClient
bonafide *bonafide.Bonafide
......@@ -49,7 +50,7 @@ func Init() (*Bitmask, error) {
if err != nil {
return nil, err
}
b := Bitmask{tempdir, statusCh, nil, bonafide, launch, "", nil}
b := Bitmask{tempdir, "", statusCh, nil, bonafide, launch, "", nil}
/*
TODO -- we still want to do this, since it resets the fw/vpn if running
......
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment