|
@@ -2,6 +2,7 @@ package main
|
|
|
|
|
|
import (
|
|
import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
|
+ "geodns/countries"
|
|
"github.com/miekg/dns"
|
|
"github.com/miekg/dns"
|
|
"log"
|
|
"log"
|
|
"os"
|
|
"os"
|
|
@@ -62,6 +63,22 @@ func serve(w dns.ResponseWriter, req *dns.Msg, z *Zone) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if label == "_country" && (qtype == dns.TypeANY || qtype == dns.TypeTXT) {
|
|
|
|
+ h := dns.RR_Header{Ttl: 1, Class: dns.ClassINET, Rrtype: dns.TypeTXT}
|
|
|
|
+ h.Name = "_country." + z.Origin + "."
|
|
|
|
+
|
|
|
|
+ m.Answer = []dns.RR{&dns.RR_TXT{Hdr: h,
|
|
|
|
+ Txt: []string{
|
|
|
|
+ string(country),
|
|
|
|
+ string(countries.CountryContinent[country]),
|
|
|
|
+ },
|
|
|
|
+ }}
|
|
|
|
+
|
|
|
|
+ m.Authoritative = true
|
|
|
|
+ w.Write(m)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
// return NXDOMAIN
|
|
// return NXDOMAIN
|
|
m.SetRcode(req, dns.RcodeNameError)
|
|
m.SetRcode(req, dns.RcodeNameError)
|
|
m.Authoritative = true
|
|
m.Authoritative = true
|