fix: tun dns

This commit is contained in:
Skyxim 2022-05-02 14:21:37 +08:00
parent b929a19f48
commit b2605a9012
2 changed files with 18 additions and 0 deletions

16
dns/patch.go Normal file
View file

@ -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)}
}

View file

@ -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