Skip to content

Commit

Permalink
Fix: mapping dns should not stale (#675)
Browse files Browse the repository at this point in the history
* Fix: mapping dns should not stale

* Update enhancer.go
  • Loading branch information
Nep-Timeline authored Aug 1, 2023
1 parent f125e1c commit b0fed73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dns/enhancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 4 additions & 0 deletions dns/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}

Expand Down

0 comments on commit b0fed73

Please sign in to comment.