|
|
@ -84,8 +84,6 @@ func handleRoot(w dns.ResponseWriter, r *dns.Msg) {
|
|
|
|
var res *dns.Msg
|
|
|
|
var res *dns.Msg
|
|
|
|
domain := r.Question[0].Name
|
|
|
|
domain := r.Question[0].Name
|
|
|
|
|
|
|
|
|
|
|
|
var done int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
reply from hosts
|
|
|
|
reply from hosts
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -135,7 +133,6 @@ func handleRoot(w dns.ResponseWriter, r *dns.Msg) {
|
|
|
|
|
|
|
|
|
|
|
|
// forward to upstream server
|
|
|
|
// forward to upstream server
|
|
|
|
for i := 0; i < 2; i++ {
|
|
|
|
for i := 0; i < 2; i++ {
|
|
|
|
done = 0
|
|
|
|
|
|
|
|
for _, sv := range Servers {
|
|
|
|
for _, sv := range Servers {
|
|
|
|
if sv.match(domain) {
|
|
|
|
if sv.match(domain) {
|
|
|
|
|
|
|
|
|
|
|
@ -165,14 +162,14 @@ func handleRoot(w dns.ResponseWriter, r *dns.Msg) {
|
|
|
|
dns_cache.Add(key, strings.Join(v, "|"))
|
|
|
|
dns_cache.Add(key, strings.Join(v, "|"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
w.WriteMsg(res)
|
|
|
|
w.WriteMsg(res)
|
|
|
|
done = 1
|
|
|
|
return
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// fallback to default upstream server
|
|
|
|
// fallback to default upstream server
|
|
|
|
if done != 1 {
|
|
|
|
for i := 0; i < 2; i++ {
|
|
|
|
logger.Debug("%s query %s %s %s, use default server\n",
|
|
|
|
logger.Debug("%s query %s %s %s, use default server\n",
|
|
|
|
w.RemoteAddr(),
|
|
|
|
w.RemoteAddr(),
|
|
|
|
domain,
|
|
|
|
domain,
|
|
|
@ -192,20 +189,12 @@ func handleRoot(w dns.ResponseWriter, r *dns.Msg) {
|
|
|
|
dns_cache.Add(key, strings.Join(v, "|"))
|
|
|
|
dns_cache.Add(key, strings.Join(v, "|"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
w.WriteMsg(res)
|
|
|
|
w.WriteMsg(res)
|
|
|
|
done = 1
|
|
|
|
return
|
|
|
|
break
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if done == 1 {
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if done != 1 {
|
|
|
|
|
|
|
|
dns.HandleFailed(w, r)
|
|
|
|
dns.HandleFailed(w, r)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
func main() {
|
|
|
|