Wait with first update cycle until online
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
// Event Names
|
||||
const (
|
||||
ModuleName = "netenv"
|
||||
NetworkChangedEvent = "network changed"
|
||||
OnlineStatusChangedEvent = "online status changed"
|
||||
)
|
||||
@@ -15,7 +16,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
module = modules.Register("netenv", prep, start, nil)
|
||||
module = modules.Register(ModuleName, prep, start, nil)
|
||||
module.RegisterEvent(NetworkChangedEvent, true)
|
||||
module.RegisterEvent(OnlineStatusChangedEvent, true)
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/safing/portbase/notifications"
|
||||
"github.com/tevino/abool"
|
||||
|
||||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portbase/notifications"
|
||||
"github.com/safing/portmaster/network/netutils"
|
||||
|
||||
"github.com/tevino/abool"
|
||||
"github.com/safing/portmaster/updates"
|
||||
)
|
||||
|
||||
// OnlineStatus represent a state of connectivity to the Internet.
|
||||
@@ -200,13 +200,18 @@ func updateOnlineStatus(status OnlineStatus, portalURL *url.URL, comment string)
|
||||
|
||||
// trigger event
|
||||
if changed {
|
||||
module.TriggerEvent(OnlineStatusChangedEvent, nil)
|
||||
module.TriggerEvent(OnlineStatusChangedEvent, status)
|
||||
if status == StatusPortal {
|
||||
log.Infof(`netenv: setting online status to %s at "%s" (%s)`, status, portalURL, comment)
|
||||
} else {
|
||||
log.Infof("netenv: setting online status to %s (%s)", status, comment)
|
||||
}
|
||||
triggerNetworkChangeCheck()
|
||||
|
||||
// Trigger update check when coming (semi) online.
|
||||
if Online() {
|
||||
_ = updates.TriggerUpdate(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user