Improve online status check triggers and logging
This commit is contained in:
@@ -377,17 +377,21 @@ func monitorOnlineStatus(ctx context.Context) error {
|
|||||||
func getDynamicStatusTrigger() <-chan time.Time {
|
func getDynamicStatusTrigger() <-chan time.Time {
|
||||||
switch GetOnlineStatus() {
|
switch GetOnlineStatus() {
|
||||||
case StatusOffline:
|
case StatusOffline:
|
||||||
return time.After(1 * time.Second)
|
// Will be triggered by network change anyway.
|
||||||
|
return time.After(20 * time.Second)
|
||||||
case StatusLimited, StatusPortal:
|
case StatusLimited, StatusPortal:
|
||||||
|
// Change will not be detected otherwise, but impact is minor.
|
||||||
return time.After(5 * time.Second)
|
return time.After(5 * time.Second)
|
||||||
case StatusSemiOnline:
|
case StatusSemiOnline:
|
||||||
|
// Very small impact.
|
||||||
return time.After(20 * time.Second)
|
return time.After(20 * time.Second)
|
||||||
case StatusOnline:
|
case StatusOnline:
|
||||||
|
// Don't check until resolver reports problems.
|
||||||
return nil
|
return nil
|
||||||
case StatusUnknown:
|
case StatusUnknown:
|
||||||
return time.After(2 * time.Second)
|
return time.After(5 * time.Second)
|
||||||
default: // other unknown status
|
default: // other unknown status
|
||||||
return time.After(1 * time.Minute)
|
return time.After(5 * time.Minute)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,7 +505,9 @@ func checkOnlineStatus(ctx context.Context) {
|
|||||||
|
|
||||||
// Check with primary dns check domain.
|
// Check with primary dns check domain.
|
||||||
ips, err := net.LookupIP(DNSTestDomain)
|
ips, err := net.LookupIP(DNSTestDomain)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
|
log.Warningf("netenv: dns check query failed: %s", err)
|
||||||
|
} else {
|
||||||
// check for expected response
|
// check for expected response
|
||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
if ip.Equal(DNSTestExpectedIP) {
|
if ip.Equal(DNSTestExpectedIP) {
|
||||||
@@ -514,6 +520,7 @@ func checkOnlineStatus(ctx context.Context) {
|
|||||||
// If that did not work, check with fallback dns check domain.
|
// If that did not work, check with fallback dns check domain.
|
||||||
ips, err = net.LookupIP(DNSFallbackTestDomain)
|
ips, err = net.LookupIP(DNSFallbackTestDomain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Warningf("netenv: dns fallback check query failed: %s", err)
|
||||||
updateOnlineStatus(StatusLimited, nil, "dns fallback check query failed")
|
updateOnlineStatus(StatusLimited, nil, "dns fallback check query failed")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user