- network down is ignored if the selected configuration is local responder
parent
0752a7e443
commit
b9f17b3c19
|
@ -13,10 +13,13 @@ import (
|
|||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
var localresponderConfigName string
|
||||
|
||||
type stringarray []string
|
||||
type urlsMap map[string]stringarray
|
||||
|
||||
func init() {
|
||||
localresponderConfigName = "__localresponder__"
|
||||
var MyConfRaw interface{}
|
||||
|
||||
file, err := ioutil.ReadFile("config.json")
|
||||
|
@ -248,7 +251,7 @@ func init() {
|
|||
}
|
||||
|
||||
//************************
|
||||
// Local responser section
|
||||
// Local responder section
|
||||
//************************
|
||||
if MyConf["localresponder"] != nil {
|
||||
localresponder := MyConf["localresponder"].(map[string]interface{})
|
||||
|
@ -258,7 +261,7 @@ func init() {
|
|||
ZabovLocalResponder = localresponder["responder"].(string)
|
||||
if len(ZabovLocalResponder) > 0 {
|
||||
local := ZabovConfig{ZabovDNSArray: []string{ZabovLocalResponder}, references: 1}
|
||||
ZabovConfigs["__localresponder__"] = &local
|
||||
ZabovConfigs[localresponderConfigName] = &local
|
||||
fmt.Println("ZabovLocalResponder:", ZabovLocalResponder)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,8 @@ func ForwardQuery(query *dns.Msg, config string, nocache bool) *dns.Msg {
|
|||
for {
|
||||
// round robin with retry
|
||||
|
||||
if !NetworkUp {
|
||||
// local responder should always be available also if no internet connection
|
||||
if !NetworkUp && localresponderConfigName != config {
|
||||
time.Sleep(10 * time.Second)
|
||||
go incrementStats("Network Problems ", 1)
|
||||
continue
|
||||
|
|
|
@ -269,7 +269,7 @@ func (mydns *handler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
|
|||
if len(ZabovLocalResponder) > 0 {
|
||||
if !strings.Contains(fqdn, ".") ||
|
||||
(len(ZabovLocalDomain) > 0 && strings.HasSuffix(fqdn, ZabovLocalDomain)) {
|
||||
config = "__localresponder__"
|
||||
config = localresponderConfigName
|
||||
ret := ForwardQuery(r, config, true)
|
||||
w.WriteMsg(ret)
|
||||
go logQuery(remIP, fqdn, QType, config, timetable, "localresponder")
|
||||
|
@ -297,7 +297,7 @@ func (mydns *handler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
|
|||
|
||||
if len(ZabovLocalResponder) > 0 {
|
||||
// if set use local responder for reverse lookup (suffix ".in-addr.arpa.")
|
||||
config = "__localresponder__"
|
||||
config = localresponderConfigName
|
||||
}
|
||||
ret := ForwardQuery(r, config, true)
|
||||
w.WriteMsg(ret)
|
||||
|
|
Loading…
Reference in New Issue