feat(dns): add optimistic caching (#5237)

This commit is contained in:
Meow
2025-11-21 13:38:06 +08:00
committed by GitHub
parent 4956e65824
commit cd51f57535
17 changed files with 338 additions and 183 deletions
+6 -1
View File
@@ -121,6 +121,11 @@ func New(ctx context.Context, config *Config) (*DNS, error) {
}
disableCache := config.DisableCache || ns.DisableCache
serveStale := config.ServeStale || ns.ServeStale
serveExpiredTTL := config.ServeExpiredTTL
if ns.ServeExpiredTTL != nil {
serveExpiredTTL = *ns.ServeExpiredTTL
}
var tag = defaultTag
if len(ns.Tag) > 0 {
@@ -131,7 +136,7 @@ func New(ctx context.Context, config *Config) (*DNS, error) {
return nil, errors.New("no QueryStrategy available for ", ns.Address)
}
client, err := NewClient(ctx, ns, myClientIP, disableCache, tag, clientIPOption, &matcherInfos, updateDomain)
client, err := NewClient(ctx, ns, myClientIP, disableCache, serveStale, serveExpiredTTL, tag, clientIPOption, &matcherInfos, updateDomain)
if err != nil {
return nil, errors.New("failed to create client").Base(err)
}