1
0

Fix: mapping dns should not stale

This commit is contained in:
Dreamacro 2023-07-27 21:23:08 +08:00
parent 40bbd3dfdb
commit c1d027d6d1
2 changed files with 4 additions and 1 deletions

View File

@ -78,7 +78,7 @@ func NewEnhancer(cfg Config) *ResolverEnhancer {
if cfg.EnhancedMode != C.DNSNormal { if cfg.EnhancedMode != C.DNSNormal {
fakePool = cfg.Pool fakePool = cfg.Pool
mapping = cache.New(cache.WithSize(4096), cache.WithStale(true)) mapping = cache.New(cache.WithSize(4096))
} }
return &ResolverEnhancer{ return &ResolverEnhancer{

View File

@ -100,6 +100,9 @@ func withMapping(mapping *cache.LruCache) middleware {
continue continue
} }
if ttl < 1 {
ttl = 1
}
mapping.SetWithExpire(ip.String(), host, time.Now().Add(time.Second*time.Duration(ttl))) mapping.SetWithExpire(ip.String(), host, time.Now().Add(time.Second*time.Duration(ttl)))
} }