Skip to content

Commit

Permalink
Fix unsigned domain point to local
Browse files Browse the repository at this point in the history
  • Loading branch information
wweir committed Dec 2, 2018
1 parent c11162d commit 1c45fae
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
36 changes: 26 additions & 10 deletions conf/sower.toml
Original file line number Diff line number Diff line change
@@ -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
verbose=0
13 changes: 5 additions & 8 deletions dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 1c45fae

Please sign in to comment.