fix: tun dns
This commit is contained in:
parent
b929a19f48
commit
b2605a9012
2 changed files with 18 additions and 0 deletions
16
dns/patch.go
Normal file
16
dns/patch.go
Normal 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)}
|
||||||
|
}
|
|
@ -122,6 +122,7 @@ func updateDNS(c *config.DNS) {
|
||||||
if !c.Enable {
|
if !c.Enable {
|
||||||
resolver.DefaultResolver = nil
|
resolver.DefaultResolver = nil
|
||||||
resolver.DefaultHostMapper = nil
|
resolver.DefaultHostMapper = nil
|
||||||
|
resolver.DefaultLocalServer = nil
|
||||||
dns.ReCreateServer("", nil, nil)
|
dns.ReCreateServer("", nil, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -158,6 +159,7 @@ func updateDNS(c *config.DNS) {
|
||||||
|
|
||||||
resolver.DefaultResolver = r
|
resolver.DefaultResolver = r
|
||||||
resolver.DefaultHostMapper = m
|
resolver.DefaultHostMapper = m
|
||||||
|
resolver.DefaultLocalServer = dns.NewLocalServer(r, m)
|
||||||
|
|
||||||
if pr.HasProxyServer() {
|
if pr.HasProxyServer() {
|
||||||
resolver.ProxyServerHostResolver = pr
|
resolver.ProxyServerHostResolver = pr
|
||||||
|
|
Loading…
Reference in a new issue