Browse Source

Merge pull request #4 from miekg/master

small tweaks from miekg
Ask Bjørn Hansen 13 years ago
parent
commit
0c48ff74c0
1 changed files with 4 additions and 16 deletions
  1. 4 16
      serve.go

+ 4 - 16
serve.go

@@ -30,19 +30,17 @@ func serve(w dns.ResponseWriter, req *dns.Msg, z *Zone) {
 
 
 	label := getQuestionName(z, req)
 	label := getQuestionName(z, req)
 
 
-	raddr := w.RemoteAddr()
-
 	var country *string
 	var country *string
 	if geoIP != nil {
 	if geoIP != nil {
-		country = geoIP.GetCountry(raddr.String())
+		country = geoIP.GetCountry(w.RemoteAddr().String())
 		fmt.Println("Country:", country)
 		fmt.Println("Country:", country)
 	}
 	}
 
 
 	m := new(dns.Msg)
 	m := new(dns.Msg)
 	m.SetReply(req)
 	m.SetReply(req)
-	ednsFromRequest(req, m)
-
-	m.MsgHdr.Authoritative = true
+	if e := m.IsEdns0(); e != nil {
+		m.SetEdns0(4096, e.Do())
+	}
 	m.Authoritative = true
 	m.Authoritative = true
 
 
 	labels := z.findLabels(label, *country, qtype)
 	labels := z.findLabels(label, *country, qtype)
@@ -115,13 +113,3 @@ func runServe(Zones *Zones) {
 	}
 	}
 
 
 }
 }
-
-func ednsFromRequest(req, m *dns.Msg) {
-	for _, r := range req.Extra {
-		if r.Header().Rrtype == dns.TypeOPT {
-			m.SetEdns0(4096, r.(*dns.RR_OPT).Do())
-			return
-		}
-	}
-	return
-}