diff --git a/dns/enhancer.go b/dns/enhancer.go index 16ae020..faaa072 100644 --- a/dns/enhancer.go +++ b/dns/enhancer.go @@ -78,7 +78,7 @@ func NewEnhancer(cfg Config) *ResolverEnhancer { if cfg.EnhancedMode != C.DNSNormal { fakePool = cfg.Pool - mapping = cache.New(cache.WithSize(4096), cache.WithStale(true)) + mapping = cache.New(cache.WithSize(4096)) } return &ResolverEnhancer{ diff --git a/dns/middleware.go b/dns/middleware.go index deb8015..7ec2890 100644 --- a/dns/middleware.go +++ b/dns/middleware.go @@ -100,6 +100,9 @@ func withMapping(mapping *cache.LruCache) middleware { continue } + if ttl < 1 { + ttl = 1 + } mapping.SetWithExpire(ip.String(), host, time.Now().Add(time.Second*time.Duration(ttl))) }