mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-01-04 00:23:43 +08:00
fix: tun dns
This commit is contained in:
parent
b929a19f48
commit
b2605a9012
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 {
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user