From 14600a8170a8af630aa5a6d08c41c725a44816e9 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Sat, 23 Mar 2019 19:41:41 +0800 Subject: [PATCH] Fix: dns hot reload no effect --- dns/server.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dns/server.go b/dns/server.go index 9db92d78..93311aeb 100644 --- a/dns/server.go +++ b/dns/server.go @@ -34,13 +34,18 @@ func (s *Server) ServeDNS(w D.ResponseWriter, r *D.Msg) { w.WriteMsg(msg) } +func (s *Server) setReslover(r *Resolver) { + s.r = r +} + func ReCreateServer(addr string, resolver *Resolver) error { - if server.Server != nil { - server.Shutdown() + if addr == address { + server.setReslover(resolver) + return nil } - if addr == address { - return nil + if server.Server != nil { + server.Shutdown() } _, port, err := net.SplitHostPort(addr)