Return cached entries if device is offline

This commit is contained in:
Daniel
2021-01-25 17:09:27 +01:00
parent cad957bae0
commit 0e93204caf
3 changed files with 11 additions and 12 deletions

View File

@@ -317,9 +317,8 @@ func resolveAndCache(ctx context.Context, q *Query, oldCache *RRCache) (rrCache
// check if we are online
if netenv.GetOnlineStatus() == netenv.StatusOffline {
if !netenv.IsConnectivityDomain(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
return nil, ErrOffline
return oldCache, ErrOffline
}
log.Tracer(ctx).Debugf("resolver: permitting online status test domain %s to resolve even though offline", q.FQDN)
}
@@ -356,9 +355,8 @@ resolveLoop:
return nil, err
case netenv.GetOnlineStatus() == netenv.StatusOffline &&
!netenv.IsConnectivityDomain(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
return nil, ErrOffline
return oldCache, ErrOffline
case errors.Is(err, ErrContinue):
continue
case errors.Is(err, ErrTimeout):

View File

@@ -324,7 +324,7 @@ func (rrCache *RRCache) GetExtraRRs(ctx context.Context, query *dns.Msg) (extra
extra = addExtra(ctx, extra, "async request to refresh the cache has been started")
}
if rrCache.IsBackup {
extra = addExtra(ctx, extra, "this record is served because a fresh request failed")
extra = addExtra(ctx, extra, "this record is served because a fresh request was unsuccessful")
}
// Add information about filtered entries.