summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-09-17 19:50:17 +0200
committerkali kaneko (leap communications) <kali@leap.se>2021-10-06 18:38:22 +0200
commitad5f4245ea2874fd8b6eb56691857c69cdf9860d (patch)
tree99b55fd3b12a9cc32148018eea37349c1964d4dc
parent77c518c638f67a2fa38187ef2b29856aab82472c (diff)
[ui] track failed state
-rw-r--r--pkg/vpn/launcher.go3
-rw-r--r--pkg/vpn/launcher_linux.go7
-rw-r--r--pkg/vpn/main.go3
-rw-r--r--pkg/vpn/status.go4
4 files changed, 13 insertions, 4 deletions
diff --git a/pkg/vpn/launcher.go b/pkg/vpn/launcher.go
index eb3794c..1b2d673 100644
--- a/pkg/vpn/launcher.go
+++ b/pkg/vpn/launcher.go
@@ -34,6 +34,7 @@ import (
type launcher struct {
helperAddr string
+ failed bool
}
const initialHelperPort = 7171
@@ -82,7 +83,7 @@ func smellsLikeOurHelperSpirit(port int, c *http.Client) bool {
func newLauncher() (*launcher, error) {
helperPort := probeHelperPort(initialHelperPort)
helperAddr := "http://localhost:" + strconv.Itoa(helperPort)
- return &launcher{helperAddr}, nil
+ return &launcher{helperAddr, false}, nil
}
func (l *launcher) close() error {
diff --git a/pkg/vpn/launcher_linux.go b/pkg/vpn/launcher_linux.go
index 3e872cd..52c87f7 100644
--- a/pkg/vpn/launcher_linux.go
+++ b/pkg/vpn/launcher_linux.go
@@ -39,10 +39,11 @@ var bitmaskRootPaths = []string{
type launcher struct {
openvpnCh chan []string
+ failed bool
}
func newLauncher() (*launcher, error) {
- l := launcher{make(chan []string, 1)}
+ l := launcher{make(chan []string, 1), false}
go l.openvpnRunner()
return &l, nil
}
@@ -139,7 +140,7 @@ func getPolkitPath() string {
// now we get weird
"/usr/libexec/policykit-1-pantheon/pantheon-agent-polkit",
"/usr/lib/polkit-1-dde/dde-polkit-agent",
- // do you know some we"re still missing? :)
+ // do you know some we"re still missing? please send a merge request :)
}
for _, polkit := range polkitPaths {
@@ -191,6 +192,8 @@ func (l *launcher) openvpnRunner(arg ...string) {
err := runBitmaskRoot(arg...)
if err != nil {
log.Printf("An error ocurred running openvpn: %v", err)
+ l.openvpnCh <- nil
+ l.failed = true
}
}
}
diff --git a/pkg/vpn/main.go b/pkg/vpn/main.go
index 3a1f521..0671877 100644
--- a/pkg/vpn/main.go
+++ b/pkg/vpn/main.go
@@ -39,6 +39,7 @@ type Bitmask struct {
shapes *shapeshifter.ShapeShifter
certPemPath string
openvpnArgs []string
+ failed bool
}
// Init the connection to bitmask
@@ -53,7 +54,7 @@ func Init() (*Bitmask, error) {
if err != nil {
return nil, err
}
- b := Bitmask{tempdir, bonafide.Gateway{}, bonafide.Gateway{}, statusCh, nil, bf, launch, "", nil, "", []string{}}
+ b := Bitmask{tempdir, bonafide.Gateway{}, bonafide.Gateway{}, statusCh, nil, bf, launch, "", nil, "", []string{}, false}
b.launch.firewallStop()
/*
diff --git a/pkg/vpn/status.go b/pkg/vpn/status.go
index 88735e6..692bf09 100644
--- a/pkg/vpn/status.go
+++ b/pkg/vpn/status.go
@@ -125,3 +125,7 @@ func (b *Bitmask) getOpenvpnState() (string, error) {
}
return status, nil
}
+
+func (b *Bitmask) isFailed() bool {
+ return b.launch.failed
+}