Skip to content
Snippets Groups Projects
Verified Commit 11b2ca66 authored by meskio's avatar meskio :tent:
Browse files

[feat] timeout if bitmaskd doesn't respond

- Resolves: #7
parent a52abd0c
No related branches found
No related tags found
1 merge request!1[feat] install helpers if needed
...@@ -19,6 +19,7 @@ import ( ...@@ -19,6 +19,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"log" "log"
"time"
"github.com/pebbe/zmq4" "github.com/pebbe/zmq4"
) )
...@@ -26,6 +27,7 @@ import ( ...@@ -26,6 +27,7 @@ import (
const ( const (
// On win should be: tcp://127.0.0.1:5001 // On win should be: tcp://127.0.0.1:5001
coreEndpoint = "ipc:///tmp/bitmask.core.sock" coreEndpoint = "ipc:///tmp/bitmask.core.sock"
timeout = time.Second * 40
) )
// Bitmask holds the bitmask client data // Bitmask holds the bitmask client data
...@@ -47,6 +49,8 @@ func Init() (*Bitmask, error) { ...@@ -47,6 +49,8 @@ func Init() (*Bitmask, error) {
return nil, err return nil, err
} }
coresoc.SetRcvtimeo(timeout)
b := Bitmask{coresoc, eventsoc, statusCh} b := Bitmask{coresoc, eventsoc, statusCh}
go b.eventsHandler() go b.eventsHandler()
return &b, nil return &b, nil
......
...@@ -49,7 +49,8 @@ func checkAndInstallHelpers(b *bitmask.Bitmask, notify *notificator) { ...@@ -49,7 +49,8 @@ func checkAndInstallHelpers(b *bitmask.Bitmask, notify *notificator) {
log.Printf("No polkit found") log.Printf("No polkit found")
notify.authAgent() notify.authAgent()
} else if err != nil { } else if err != nil {
log.Fatal(err) notify.bitmaskNotRunning()
log.Fatal("Is bitmask running? ", err)
} }
if !helpers { if !helpers {
......
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
const ( 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` 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.` 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 { type notificator struct {
...@@ -55,6 +56,10 @@ func (n *notificator) donations() { ...@@ -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() { func (n *notificator) authAgent() {
n.notify.Push("Missing authentication agent", missingAuthAgent, "", notif.UR_CRITICAL) n.notify.Push("Missing authentication agent", missingAuthAgent, "", notif.UR_CRITICAL)
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment