Semicolon separate multiple domain list files and update examples

This commit is contained in:
kenshinx 2018-02-01 19:22:45 +08:00
parent dc60b4c9a2
commit ea21c87183
7 changed files with 119 additions and 14 deletions

View File

@ -27,13 +27,12 @@ Similar to [dnsmasq](http://www.thekelleys.org.uk/dnsmasq/doc.html), but support
3. Running
$ sudo ./godns -c godns.conf
$ sudo ./godns -c ./etc/godns.conf
4. Test
$ dig www.github.com @127.0.0.1
More details about how to install and running godns can reference my [blog (Chinese)](http://blog.kenshinx.me/blog/compile-godns/)
## Use godns
@ -58,6 +57,12 @@ resolv-file = "/etc/resolv.conf"
If multiple `namerservers` are set in resolv.conf, the upsteam server will try in a top to bottom order
#### server-list-file
Domain-specific nameservers configuration, formatting keep compatible with Dnsmasq.
>server=/google.com/8.8.8.8
More cases please refererence [dnsmasq-china-list](https://github.com/felixonmars/dnsmasq-china-list)
#### cache

46
etc/apple.china.conf Normal file
View File

@ -0,0 +1,46 @@
server=/adcdownload.apple.com/114.114.114.114
server=/appldnld.apple.com/114.114.114.114
server=/cdn-cn1.apple-mapkit.com/114.114.114.114
server=/cdn-cn2.apple-mapkit.com/114.114.114.114
server=/cdn-cn3.apple-mapkit.com/114.114.114.114
server=/cdn-cn4.apple-mapkit.com/114.114.114.114
server=/cdn.apple-mapkit.com/114.114.114.114
server=/cdn1.apple-mapkit.com/114.114.114.114
server=/cdn2.apple-mapkit.com/114.114.114.114
server=/cdn3.apple-mapkit.com/114.114.114.114
server=/cdn4.apple-mapkit.com/114.114.114.114
server=/cds.apple.com/114.114.114.114
server=/cl1.apple.com/114.114.114.114
server=/cl2.apple.com.edgekey.net.globalredir.akadns.net/114.114.114.114
server=/cl2.apple.com.edgekey.net/114.114.114.114
server=/cl2.apple.com/114.114.114.114
server=/cl3.apple.com/114.114.114.114
server=/cl4.apple.com/114.114.114.114
server=/cl5.apple.com/114.114.114.114
server=/gsp11-cn.ls.apple.com/114.114.114.114
server=/gsp12-cn.ls.apple.com/114.114.114.114
server=/gsp13-cn.ls.apple.com/114.114.114.114
server=/gsp4-cn.ls.apple.com.edgekey.net.globalredir.akadns.net/114.114.114.114
server=/gsp4-cn.ls.apple.com.edgekey.net/114.114.114.114
server=/gsp4-cn.ls.apple.com/114.114.114.114
server=/gsp5-cn.ls.apple.com/114.114.114.114
server=/gspe19-cn.ls-apple.com.akadns.net/114.114.114.114
server=/gspe19-cn.ls.apple.com/114.114.114.114
server=/gspe21.ls.apple.com/114.114.114.114
server=/gspe21-ssl.ls.apple.com/114.114.114.114
server=/gspe35-ssl.ls.apple.com/114.114.114.114
server=/icloud.cdn-apple.com/114.114.114.114
server=/images.apple.com/114.114.114.114
server=/itunes-apple.com.akadns.net/114.114.114.114
server=/itunes.apple.com/114.114.114.114
server=/itunesconnect.apple.com/114.114.114.114
server=/mesu.apple.com/114.114.114.114
server=/mesu-china.apple.com.akadns.net/114.114.114.114
server=/phobos-apple.com.akadns.net/114.114.114.114
server=/phobos.apple.com/114.114.114.114
server=/store.apple.com/114.114.114.114
server=/store.storeimages.cdn-apple.com/114.114.114.114
server=/support.apple.com/114.114.114.114
server=/swcdn.apple.com/114.114.114.114
server=/swdist.apple.com/114.114.114.114
server=/www.apple.com/114.114.114.114

View File

@ -1,5 +0,0 @@
server=8.8.8.8#53
server=127.0.0.1#5553
server=/baidu.com/114.114.114.114
# refer https://github.com/felixonmars/dnsmasq-china-list

View File

@ -12,8 +12,9 @@ host = "127.0.0.1"
port = 53
[resolv]
#Domain-specific nameservers configuration, formatting keep compatible with Dnsmasq
server-list-file = "./etc/china.conf"
# Domain-specific nameservers configuration, formatting keep compatible with Dnsmasq
# Semicolon separate multiple files.
server-list-file = "./etc/apple.china.conf;./etc/google.china.conf"
resolv-file = "/etc/resolv.conf"
timeout = 5 # 5 seconds
# The concurrency interval request upstream recursive server

42
etc/google.china.conf Normal file
View File

@ -0,0 +1,42 @@
server=/265.com/114.114.114.114
server=/2mdn.net/114.114.114.114
server=/app-measurement.com/114.114.114.114
server=/beacons.gcp.gvt2.com/114.114.114.114
server=/beacons.gvt2.com/114.114.114.114
server=/beacons3.gvt2.com/114.114.114.114
server=/c.admob.com/114.114.114.114
server=/c.android.clients.google.com/114.114.114.114
server=/cache.pack.google.com/114.114.114.114
server=/clientservices.googleapis.com/114.114.114.114
server=/connectivitycheck.gstatic.com/114.114.114.114
server=/csi.gstatic.com/114.114.114.114
server=/dl.google.com/114.114.114.114
server=/doubleclick.net/114.114.114.114
server=/e.admob.com/114.114.114.114
server=/fonts.googleapis.com/114.114.114.114
server=/fonts.gstatic.com/114.114.114.114
server=/google-analytics.com/114.114.114.114
server=/googleadservices.com/114.114.114.114
server=/googleanalytics.com/114.114.114.114
server=/googlesyndication.com/114.114.114.114
server=/googletagmanager.com/114.114.114.114
server=/googletagservices.com/114.114.114.114
server=/imasdk.googleapis.com/114.114.114.114
server=/kh.google.com/114.114.114.114
server=/khm.google.com/114.114.114.114
server=/khm.googleapis.com/114.114.114.114
server=/khm0.google.com/114.114.114.114
server=/khm0.googleapis.com/114.114.114.114
server=/khm1.google.com/114.114.114.114
server=/khm1.googleapis.com/114.114.114.114
server=/khm2.google.com/114.114.114.114
server=/khm2.googleapis.com/114.114.114.114
server=/khm3.google.com/114.114.114.114
server=/khm3.googleapis.com/114.114.114.114
server=/khmdb.google.com/114.114.114.114
server=/khmdb.googleapis.com/114.114.114.114
server=/media.admob.com/114.114.114.114
server=/mediavisor.doubleclick.com/114.114.114.114
server=/redirector.gvt1.com/114.114.114.114
server=/toolbarqueries.google.com/114.114.114.114
server=/update.googleapis.com/114.114.114.114

View File

@ -0,0 +1,7 @@
# Default upstream servers which have higher priority than the nameserver
# that configuration in `/etc/resolv.conf`
server=8.8.8.8#53
server=/google.com/8.8.8.8
server=/baidu.com/114.114.114.114
# refer https://github.com/felixonmars/dnsmasq-china-list

View File

@ -62,11 +62,7 @@ func NewResolver(c ResolvSettings) *Resolver {
return r
}
func (r *Resolver) ReadServerListFile(file string) {
buf, err := os.Open(file)
if err != nil {
panic("Can't open " + file)
}
func (r *Resolver) parseServerListFile(buf *os.File) {
scanner := bufio.NewScanner(buf)
for scanner.Scan() {
line := scanner.Text()
@ -88,6 +84,7 @@ func (r *Resolver) ReadServerListFile(file string) {
case 3:
domain := tokens[1]
ip := tokens[2]
if !isDomain(domain) || !isIP(ip) {
continue
}
@ -116,6 +113,18 @@ func (r *Resolver) ReadServerListFile(file string) {
}
func (r *Resolver) ReadServerListFile(path string) {
files := strings.Split(path, ";")
for _, file := range files {
buf, err := os.Open(file)
if err != nil {
panic("Can't open " + file)
}
defer buf.Close()
r.parseServerListFile(buf)
}
}
// Lookup will ask each nameserver in top-to-bottom fashion, starting a new request
// in every second, and return as early as possbile (have an answer).
// It returns an error if no request has succeeded.