Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions client/ui/client_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"fyne.io/systray"

Check failure on line 31 in client/ui/client_ui.go

View workflow job for this annotation

GitHub Actions / JS / Lint

could not import fyne.io/systray (-: # fyne.io/systray
"github.com/cenkalti/backoff/v4"
log "github.com/sirupsen/logrus"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
Expand Down Expand Up @@ -280,6 +280,7 @@
blockLANAccess bool

connected bool
connectivityLost bool
update *version.Update
daemonVersion string
updateIndicationLock sync.Mutex
Expand Down Expand Up @@ -703,21 +704,41 @@
return nil
}

func (s *serviceClient) onStatusFailed(err error) {
log.Errorf("get client daemon service status: %v", err)
if s.connected {
s.connectivityLost = true
s.app.SendNotification(fyne.NewNotification(
"Warning",
"NetBird client service controls were interrupted.\n"+
"They should restore automatically.",
))
}
s.setDisconnectedStatus()
}
func (s *serviceClient) onStatusSucceeded() {
if s.connectivityLost {
s.connectivityLost = false
s.app.SendNotification(fyne.NewNotification(
"Info",
"NetBird client service controls were restored.",
))
}
}

func (s *serviceClient) updateStatus() error {
conn, err := s.getSrvClient(defaultFailTimeout)
if err != nil {
s.onStatusFailed(err)
return err
}
err = backoff.Retry(func() error {
status, err := conn.Status(s.ctx, &proto.StatusRequest{})
if err != nil {
log.Errorf("get service status: %v", err)
if s.connected {
s.app.SendNotification(fyne.NewNotification("Error", "Connection to service lost"))
}
s.setDisconnectedStatus()
s.onStatusFailed(err)
return err
}
s.onStatusSucceeded()

s.updateIndicationLock.Lock()
defer s.updateIndicationLock.Unlock()
Expand Down
Loading