Compare commits
1 Commits
sync-clien
...
feat/bette
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec4d09215c |
@@ -280,6 +280,7 @@ type serviceClient struct {
|
|||||||
blockLANAccess bool
|
blockLANAccess bool
|
||||||
|
|
||||||
connected bool
|
connected bool
|
||||||
|
connectivityLost bool
|
||||||
update *version.Update
|
update *version.Update
|
||||||
daemonVersion string
|
daemonVersion string
|
||||||
updateIndicationLock sync.Mutex
|
updateIndicationLock sync.Mutex
|
||||||
@@ -703,21 +704,41 @@ func (s *serviceClient) menuDownClick() error {
|
|||||||
return nil
|
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 {
|
func (s *serviceClient) updateStatus() error {
|
||||||
conn, err := s.getSrvClient(defaultFailTimeout)
|
conn, err := s.getSrvClient(defaultFailTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
s.onStatusFailed(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = backoff.Retry(func() error {
|
err = backoff.Retry(func() error {
|
||||||
status, err := conn.Status(s.ctx, &proto.StatusRequest{})
|
status, err := conn.Status(s.ctx, &proto.StatusRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("get service status: %v", err)
|
s.onStatusFailed(err)
|
||||||
if s.connected {
|
|
||||||
s.app.SendNotification(fyne.NewNotification("Error", "Connection to service lost"))
|
|
||||||
}
|
|
||||||
s.setDisconnectedStatus()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
s.onStatusSucceeded()
|
||||||
|
|
||||||
s.updateIndicationLock.Lock()
|
s.updateIndicationLock.Lock()
|
||||||
defer s.updateIndicationLock.Unlock()
|
defer s.updateIndicationLock.Unlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user