You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/tools/conf/dns.go

33 lines
672 B

package conf
import (
"v2ray.com/core/app/dns"
v2net "v2ray.com/core/common/net"
)
type DnsConfig struct {
Servers []*Address `json:"servers"`
Hosts map[string]*Address `json:"hosts"`
}
8 years ago
func (v *DnsConfig) Build() *dns.Config {
config := new(dns.Config)
8 years ago
config.NameServers = make([]*v2net.Endpoint, len(v.Servers))
for idx, server := range v.Servers {
config.NameServers[idx] = &v2net.Endpoint{
Network: v2net.Network_UDP,
Address: server.Build(),
Port: 53,
}
}
8 years ago
if v.Hosts != nil {
config.Hosts = make(map[string]*v2net.IPOrDomain)
8 years ago
for domain, ip := range v.Hosts {
config.Hosts[domain] = ip.Build()
}
}
return config
}