diff --git a/bitmask/main.go b/bitmask/main.go index 4efaae1b98b7544d4e2fb1bd302c988c00131f06..185c3a0330e8bf1b50365fd92f53f82b9c049ccb 100644 --- a/bitmask/main.go +++ b/bitmask/main.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" "log" + "time" "github.com/pebbe/zmq4" ) @@ -26,6 +27,7 @@ import ( const ( // On win should be: tcp://127.0.0.1:5001 coreEndpoint = "ipc:///tmp/bitmask.core.sock" + timeout = time.Second * 40 ) // Bitmask holds the bitmask client data @@ -47,6 +49,8 @@ func Init() (*Bitmask, error) { return nil, err } + coresoc.SetRcvtimeo(timeout) + b := Bitmask{coresoc, eventsoc, statusCh} go b.eventsHandler() return &b, nil diff --git a/main.go b/main.go index 82a3a9ef09cfeb732f193c5814358a840fad22d7..99383599d3c36085f84b0ed4a1fc5b96307162e2 100644 --- a/main.go +++ b/main.go @@ -49,7 +49,8 @@ func checkAndInstallHelpers(b *bitmask.Bitmask, notify *notificator) { log.Printf("No polkit found") notify.authAgent() } else if err != nil { - log.Fatal(err) + notify.bitmaskNotRunning() + log.Fatal("Is bitmask running? ", err) } if !helpers { diff --git a/notificator.go b/notificator.go index dce1a79dfb588165c2c740a3a2a174b8f1f48aed..375b8837c4979bdeb7820e58af28b67055acc7ef 100644 --- a/notificator.go +++ b/notificator.go @@ -26,6 +26,7 @@ import ( const ( donationText = `The RiseupVPN service is expensive to run. Because we don't want to store personal information about you, there is no accounts or billing for this service. But if you want the service to continue, donate at least $5 each month at https://riseup.net/donate-vpn` missingAuthAgent = `Could not find a polkit authentication agent. Please run one and try again.` + notRunning = `Is bitmaskd running? Start bitmask and try again.` ) type notificator struct { @@ -55,6 +56,10 @@ func (n *notificator) donations() { } } +func (n *notificator) bitmaskNotRunning() { + n.notify.Push("Can't contact bitmask", notRunning, "", notif.UR_CRITICAL) +} + func (n *notificator) authAgent() { n.notify.Push("Missing authentication agent", missingAuthAgent, "", notif.UR_CRITICAL) }