Skip to content

Commit

Permalink
Fix: mapping dns should not stale
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamacro committed Jul 27, 2023
1 parent 40bbd3d commit c1d027d
Show file tree
Hide file tree
Showing 2 changed files with 4 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 @@ -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{
Expand Down
3 changes: 3 additions & 0 deletions dns/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}

Expand Down

0 comments on commit c1d027d

Please sign in to comment.