mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-16 01:17:30 -05:00
default value of dns config
This commit is contained in:
parent
dac1339d6e
commit
10d1d9288b
@ -156,3 +156,27 @@ func (this *UDPNameServer) QueryA(domain string) <-chan *ARecord {
|
|||||||
|
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LocalNameServer struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *LocalNameServer) QueryA(domain string) <-chan *ARecord {
|
||||||
|
response := make(chan *ARecord)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer close(response)
|
||||||
|
|
||||||
|
ips, err := net.LookupIP(domain)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("DNS: Failed to lookup IPs for domain ", domain)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
response <- &ARecord{
|
||||||
|
IPs: ips,
|
||||||
|
Expire: time.Now().Add(time.Second * time.Duration(DefaultTTL)),
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
@ -32,7 +32,11 @@ func NewCacheServer(space app.Space, config *Config) *CacheServer {
|
|||||||
}
|
}
|
||||||
dispatcher := space.GetApp(dispatcher.APP_ID).(dispatcher.PacketDispatcher)
|
dispatcher := space.GetApp(dispatcher.APP_ID).(dispatcher.PacketDispatcher)
|
||||||
for idx, ns := range config.NameServers {
|
for idx, ns := range config.NameServers {
|
||||||
server.servers[idx] = NewUDPNameServer(ns, dispatcher)
|
if ns.Address().IsDomain() && ns.Address().Domain() == "localhost" {
|
||||||
|
server.servers[idx] = &LocalNameServer{}
|
||||||
|
} else {
|
||||||
|
server.servers[idx] = NewUDPNameServer(ns, dispatcher)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return server
|
return server
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,13 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
|||||||
this.OutboundConfig = jsonConfig.OutboundConfig
|
this.OutboundConfig = jsonConfig.OutboundConfig
|
||||||
this.InboundDetours = jsonConfig.InboundDetours
|
this.InboundDetours = jsonConfig.InboundDetours
|
||||||
this.OutboundDetours = jsonConfig.OutboundDetours
|
this.OutboundDetours = jsonConfig.OutboundDetours
|
||||||
|
if jsonConfig.DNSConfig == nil {
|
||||||
|
jsonConfig.DNSConfig = &dns.Config{
|
||||||
|
NameServers: []v2net.Destination{
|
||||||
|
v2net.UDPDestination(v2net.DomainAddress("localhost"), v2net.Port(53)),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
this.DNSConfig = jsonConfig.DNSConfig
|
this.DNSConfig = jsonConfig.DNSConfig
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user