|
@@ -123,6 +123,20 @@ func serve(w dns.ResponseWriter, req *dns.Msg, z *Zone) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if permitDebug && firstLabel == "_health" {
|
|
|
|
+ if qtype == dns.TypeANY || qtype == dns.TypeTXT {
|
|
|
|
+ baseLabel := strings.Join((strings.Split(label, "."))[1:], ".")
|
|
|
|
+ m.Answer = z.healthRR(label+"."+z.Origin+".", baseLabel)
|
|
|
|
+ m.Authoritative = true
|
|
|
|
+ w.WriteMsg(m)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ m.Ns = append(m.Ns, z.SoaRR())
|
|
|
|
+ m.Authoritative = true
|
|
|
|
+ w.WriteMsg(m)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
if firstLabel == "_country" {
|
|
if firstLabel == "_country" {
|
|
if qtype == dns.TypeANY || qtype == dns.TypeTXT {
|
|
if qtype == dns.TypeANY || qtype == dns.TypeTXT {
|
|
h := dns.RR_Header{Ttl: 1, Class: dns.ClassINET, Rrtype: dns.TypeTXT}
|
|
h := dns.RR_Header{Ttl: 1, Class: dns.ClassINET, Rrtype: dns.TypeTXT}
|
|
@@ -214,6 +228,31 @@ func statusRR(label string) []dns.RR {
|
|
return []dns.RR{&dns.TXT{Hdr: h, Txt: []string{string(js)}}}
|
|
return []dns.RR{&dns.TXT{Hdr: h, Txt: []string{string(js)}}}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (z *Zone) healthRR(label string, baseLabel string) []dns.RR {
|
|
|
|
+ h := dns.RR_Header{Ttl: 1, Class: dns.ClassINET, Rrtype: dns.TypeTXT}
|
|
|
|
+ h.Name = label
|
|
|
|
+
|
|
|
|
+ health := make(map[string]map[string]bool)
|
|
|
|
+
|
|
|
|
+ if l, ok := z.Labels[baseLabel]; ok {
|
|
|
|
+ for qt, records := range l.Records {
|
|
|
|
+ if qts, ok := dns.TypeToString[qt]; ok {
|
|
|
|
+ hmap := make(map[string]bool)
|
|
|
|
+ for _, record := range records {
|
|
|
|
+ if record.Test != nil {
|
|
|
|
+ hmap[(*record.Test).ipAddress.String()] = healthTestRunner.isHealthy(record.Test)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ health[qts] = hmap
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ js, _ := json.Marshal(health)
|
|
|
|
+
|
|
|
|
+ return []dns.RR{&dns.TXT{Hdr: h, Txt: []string{string(js)}}}
|
|
|
|
+}
|
|
|
|
+
|
|
func setupServerFunc(Zone *Zone) func(dns.ResponseWriter, *dns.Msg) {
|
|
func setupServerFunc(Zone *Zone) func(dns.ResponseWriter, *dns.Msg) {
|
|
return func(w dns.ResponseWriter, r *dns.Msg) {
|
|
return func(w dns.ResponseWriter, r *dns.Msg) {
|
|
serve(w, r, Zone)
|
|
serve(w, r, Zone)
|