Fix: mapping dns should not stale (#675)

* Fix: mapping dns should not stale

* Update enhancer.go
This commit is contained in:
gVisor bot 2023-08-01 17:30:57 +08:00
parent 61629307e0
commit c61e93e817
2 changed files with 5 additions and 1 deletions

View file

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

View file

@ -129,6 +129,10 @@ func withMapping(mapping *cache.LruCache[netip.Addr, string]) middleware {
continue
}
if ttl < 1 {
ttl = 1
}
mapping.SetWithExpire(ip, host, time.Now().Add(time.Second*time.Duration(ttl)))
}