Skip to content

Commit

Permalink
Fix dns rule match logic
Browse files Browse the repository at this point in the history
  • Loading branch information
wweir committed Dec 8, 2018
1 parent b83f202 commit 049e805
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,17 @@ func manual(w dns.ResponseWriter, r *dns.Msg, domain, dnsServer string) {

if conf.Conf.Verbose != 0 && len(msg.Answer) != 0 {
go func() {
_, err := net.DialTimeout("tcp", domain+":http", 3*time.Second)
if err != nil && strings.Contains(err.Error(), "timeout") {
glog.V(1).Infof("SUGGEST check (%s) http(s) service: %s", domain, err)
_, err := net.DialTimeout("tcp", domain+":http", 2*time.Second)
if err == nil || !strings.Contains(err.Error(), "timeout") {
return
}

_, err = net.DialTimeout("tcp", domain+":https", 3*time.Second)
if err == nil || !strings.Contains(err.Error(), "timeout") {
return
}

glog.V(1).Infof("SUGGEST check (%s) http(s) service: %s", domain, err)
}()
}
}
Expand Down
2 changes: 1 addition & 1 deletion dns/suffixTree.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (n *Node) Match(addr string) bool {
func (n *Node) matchSecs(secs []string) bool {
length := len(secs)
if length == 0 {
return true
return len(n.Node) == 0
}

if n, ok := n.Node[secs[length-1]]; ok {
Expand Down

0 comments on commit 049e805

Please sign in to comment.