Feature: reuse dns resolver cache when hot reload

This commit is contained in:
Dreamacro
2020-08-31 00:32:18 +08:00
parent b8ed738238
commit a32ee13fc9
4 changed files with 48 additions and 0 deletions

View File

@ -186,6 +186,11 @@ func (r *Resolver) IsFakeIP(ip net.IP) bool {
return false
}
// PatchCache overwrite lruCache to the new resolver
func (r *Resolver) PatchCache(n *Resolver) {
r.lruCache.CloneTo(n.lruCache)
}
func (r *Resolver) batchExchange(clients []dnsClient, m *D.Msg) (msg *D.Msg, err error) {
fast, ctx := picker.WithTimeout(context.Background(), time.Second*5)
for _, client := range clients {