Improve resolver netenv integration

From PR Review https://github.com/safing/portmaster/pull/83
This commit is contained in:
Daniel 2020-07-12 22:01:21 +02:00
parent 6298d1df30
commit 834d2e326c
2 changed files with 5 additions and 9 deletions

View file

@ -106,8 +106,6 @@ var (
captivePortalURL string captivePortalURL string
captivePortalLock sync.Mutex captivePortalLock sync.Mutex
waitForever = make(chan time.Time)
) )
func init() { func init() {
@ -234,7 +232,7 @@ func getDynamicStatusTrigger() <-chan time.Time {
case StatusSemiOnline: case StatusSemiOnline:
return time.After(5 * time.Minute) return time.After(5 * time.Minute)
case StatusOnline: case StatusOnline:
return waitForever return nil
default: // unknown status default: // unknown status
return time.After(5 * time.Minute) return time.After(5 * time.Minute)
} }

View file

@ -228,13 +228,12 @@ func resolveAndCache(ctx context.Context, q *Query) (rrCache *RRCache, err error
// check if we are online // check if we are online
if netenv.GetOnlineStatus() == netenv.StatusOffline { if netenv.GetOnlineStatus() == netenv.StatusOffline {
if netenv.IsOnlineStatusTestDomain(q.FQDN) { if !netenv.IsOnlineStatusTestDomain(q.FQDN) {
log.Tracer(ctx).Debugf("resolver: permitting online status test domain %s to resolve even though offline", q.FQDN)
} else {
log.Tracer(ctx).Debugf("resolver: not resolving %s, device is offline", q.FQDN) log.Tracer(ctx).Debugf("resolver: not resolving %s, device is offline", q.FQDN)
// we are offline and this is not an online check query // we are offline and this is not an online check query
return nil, ErrOffline return nil, ErrOffline
} }
log.Tracer(ctx).Debugf("resolver: permitting online status test domain %s to resolve even though offline", q.FQDN)
} }
// start resolving // start resolving
@ -253,9 +252,6 @@ resolveLoop:
// resolve // resolve
rrCache, err = resolver.Conn.Query(ctx, q) rrCache, err = resolver.Conn.Query(ctx, q)
if err != nil { if err != nil {
// TODO: check if we are online?
switch { switch {
case errors.Is(err, ErrNotFound): case errors.Is(err, ErrNotFound):
// NXDomain, or similar // NXDomain, or similar
@ -268,6 +264,8 @@ resolveLoop:
log.Tracer(ctx).Debugf("resolver: not resolving %s, device is offline", q.FQDN) log.Tracer(ctx).Debugf("resolver: not resolving %s, device is offline", q.FQDN)
// we are offline and this is not an online check query // we are offline and this is not an online check query
return nil, ErrOffline return nil, ErrOffline
default:
log.Tracer(ctx).Debugf("resolver: failed to resolve %s: %s", q.FQDN, err)
} }
} else { } else {
// no error // no error