Fix handling of connectivity / captive portal domains
Also, improve handling of queries during being captive.
This commit is contained in:
@@ -180,6 +180,11 @@ func checkCache(ctx context.Context, q *Query) *RRCache {
|
||||
|
||||
// check if expired
|
||||
if rrCache.Expired() {
|
||||
if netenv.IsConnectivityDomain(rrCache.Domain) {
|
||||
// do not use cache, resolve immediately
|
||||
return nil
|
||||
}
|
||||
|
||||
rrCache.Lock()
|
||||
rrCache.requestingNew = true
|
||||
rrCache.Unlock()
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/safing/portmaster/netenv"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
@@ -75,9 +77,17 @@ func (rrCache *RRCache) Clean(minExpires uint32) {
|
||||
lowestTTL = minExpires
|
||||
}
|
||||
|
||||
// shorten NXDomain caching
|
||||
if len(rrCache.Answer) == 0 {
|
||||
// shorten caching
|
||||
switch {
|
||||
case rrCache.IsNXDomain():
|
||||
// NXDomain
|
||||
lowestTTL = 10
|
||||
case netenv.IsConnectivityDomain(rrCache.Domain):
|
||||
// Responses from these domains might change very quickly depending on the environment.
|
||||
lowestTTL = 3
|
||||
case !netenv.Online():
|
||||
// Not being fully online could mean that we get funny responses.
|
||||
lowestTTL = 60
|
||||
}
|
||||
|
||||
// log.Tracef("lowest TTL is %d", lowestTTL)
|
||||
|
||||
Reference in New Issue
Block a user