From 1c45fae006d39aabf245ed9dc50198f57d034f7b Mon Sep 17 00:00:00 2001 From: wweir Date: Sun, 2 Dec 2018 09:37:59 +0800 Subject: [PATCH] Fix unsigned domain point to local --- conf/sower.toml | 36 ++++++++++++++++++++++++++---------- dns/dns.go | 13 +++++-------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/conf/sower.toml b/conf/sower.toml index 4dfef43..314a1f2 100644 --- a/conf/sower.toml +++ b/conf/sower.toml @@ -1,35 +1,51 @@ server_port="5533" server_addr="127.0.0.1:5533" # replce it to server "IP" +server_addr="remote-server:5533" # replce it to remote server dns_server="114.114.114.114" # client_ip="192.168.0.1" blocklist=[ - "*.google.com", # google + "*.*.google.com", # google "*.googleusercontent.com", + "gmail.com", "*.youtube.com", # youtube "*.ytimg.com", "*.ggpht.com", "*.googlevideo.com", "*.vimeo.com", "*.facebook.com", # facebook - "*.xx.fbcdn.net", + "*.xx.fbcdn.net", "*.twitter.com", # twitter - "*.twimg.com", + "*.twimg.com", + "www.reddit.com", # reddit + "www.redditmedia.com", "*.*.blogspot.com", # blogspot "www.blogger.com", "www.feedburner.com", "img1.blogblog.com", + "*.*.aws.amazon.com", # amazon + "m.media-amazon.com", + "*.awsstatic.com", + "*.atlassian.net", # atlassian + "*.atlassian.com", + "*.prod.public.atl-paas.net", + "*.cloudfront.net", "*.golang.org", # golang "go.googlesource.com", "gist.github.com", + "*.k8s.io", "*.wikipedia.org", # wikipeida - "*.wikimedia.org", - "*.wikisource.org", - "lookup-api.apple.com", - "lookup-api.apple.com.edgekey.net", - "e16991.b.akamaiedge.net", + "*.wikimedia.org", + "*.wikisource.org", + "lookup-api.apple.com", + "lookup-api.apple.com.edgekey.net", + "e16991.b.akamaiedge.net", "*.web.telegram.org", # telegram - "cloud.feedly.com", # feedly + "t.me", + "*.slack.com", #slack + "*.slack-edge.com", + "js.driftt.com", + "cloud.feedly.com", # feedly "*.nytimes.com", # New York times "*.nyt.com", ] -verbose=0 \ No newline at end of file +verbose=0 diff --git a/dns/dns.go b/dns/dns.go index 94d13e1..e4d1d25 100644 --- a/dns/dns.go +++ b/dns/dns.go @@ -34,9 +34,9 @@ func StartDNS(dnsServer string) { } func bestTry(w dns.ResponseWriter, r *dns.Msg, domain, dnsServer string) { - msg, err := dns.Exchange(r, dnsServer+":53") - if err != nil || len(msg.Answer) == 0 { - w.WriteMsg(localA(r, domain)) + msg, _ := dns.Exchange(r, dnsServer+":53") + if len(msg.Answer) == 0 { // expose any response + w.WriteMsg(msg) return } @@ -66,11 +66,8 @@ func manual(w dns.ResponseWriter, r *dns.Msg, domain, dnsServer string) { } glog.V(2).Infof("match %s fail", domain) - msg, err := dns.Exchange(r, dnsServer+":53") - if err != nil || len(msg.Answer) == 0 { - w.WriteMsg(localA(r, domain)) - return - } + // expose any response + msg, _ := dns.Exchange(r, dnsServer+":53") w.WriteMsg(msg) }