diff --git a/dns/patch.go b/dns/patch.go new file mode 100644 index 00000000..76974243 --- /dev/null +++ b/dns/patch.go @@ -0,0 +1,16 @@ +package dns + +import D "github.com/miekg/dns" + +type LocalServer struct { + handler handler +} + +// ServeMsg implement resolver.LocalServer ResolveMsg +func (s *LocalServer) ServeMsg(msg *D.Msg) (*D.Msg, error) { + return handlerWithContext(s.handler, msg) +} + +func NewLocalServer(resolver *Resolver, mapper *ResolverEnhancer) *LocalServer { + return &LocalServer{handler: NewHandler(resolver, mapper)} +} diff --git a/hub/executor/executor.go b/hub/executor/executor.go index 04a02dc7..54faccb1 100644 --- a/hub/executor/executor.go +++ b/hub/executor/executor.go @@ -122,6 +122,7 @@ func updateDNS(c *config.DNS) { if !c.Enable { resolver.DefaultResolver = nil resolver.DefaultHostMapper = nil + resolver.DefaultLocalServer = nil dns.ReCreateServer("", nil, nil) return } @@ -158,6 +159,7 @@ func updateDNS(c *config.DNS) { resolver.DefaultResolver = r resolver.DefaultHostMapper = m + resolver.DefaultLocalServer = dns.NewLocalServer(r, m) if pr.HasProxyServer() { resolver.ProxyServerHostResolver = pr