Skip to content

Commit

Permalink
Less debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
abh committed Aug 28, 2012
1 parent 3d4020c commit ca218b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
3 changes: 1 addition & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func setupZoneData(data map[string]interface{}, Zone *Zone) {
continue
}

log.Printf("rdata %s TYPE-R %T\n", rdata, rdata)
//log.Printf("rdata %s TYPE-R %T\n", rdata, rdata)

records := make(map[string][]interface{})

Expand Down Expand Up @@ -248,7 +248,6 @@ func setupZoneData(data map[string]interface{}, Zone *Zone) {
rr.Ns = rec.(string)
case []string:
recl := rec.([]string)
log.Println("RECL:", recl)
rr.Ns = recl[0]
if len(recl[1]) > 0 {
log.Println("NS records with names syntax not supported")
Expand Down
6 changes: 0 additions & 6 deletions picker.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package main

import (
"log"
"math/rand"
)

func (label *Label) Picker(dnsType uint16, max int) Records {

if label_rr := label.Records[dnsType]; label_rr != nil {

log.Printf("REGION_RR %i %T %v\n", len(label_rr), label_rr, label_rr)

// not "balanced", just return all
if label.Weight[dnsType] == 0 {
return label_rr
Expand All @@ -33,7 +30,6 @@ func (label *Label) Picker(dnsType uint16, max int) Records {
for i := range servers {
s += int(servers[i].Weight)
if s >= n {
log.Println("Picked record", i, servers[i])
sum -= servers[i].Weight
result[si] = servers[i]

Expand All @@ -44,8 +40,6 @@ func (label *Label) Picker(dnsType uint16, max int) Records {
}
}

log.Println("SERVERS", result)

return result
}
return nil
Expand Down
15 changes: 6 additions & 9 deletions serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ func serve(w dns.ResponseWriter, req *dns.Msg, z *Zone) {
logPrintf("[zone %s] incoming %s %s %d from %s\n", z.Origin, req.Question[0].Name,
dns.Rr_str[qtype], req.MsgHdr.Id, w.RemoteAddr())

//log.Printf("ZONE DATA %#v\n", z)

log.Println("Got request", req)
if *flaglog {
log.Println("Got request", req)
}

label := getQuestionName(z, req)

var country string
if geoIP != nil {
country = geoIP.GetCountry(w.RemoteAddr().String())
log.Println("Country:", country)
if *flaglog {
log.Println("Country:", country)
}
}

m := new(dns.Msg)
Expand Down Expand Up @@ -59,13 +61,10 @@ func serve(w dns.ResponseWriter, req *dns.Msg, z *Zone) {
return
}

log.Println("Has the label, looking for records")

if servers := labels.Picker(qtype, 4); servers != nil {
var rrs []dns.RR
for _, record := range servers {
rr := record.RR
log.Println("RR", rr)
rr.Header().Name = req.Question[0].Name
log.Println(rr)
rrs = append(rrs, rr)
Expand All @@ -84,8 +83,6 @@ func serve(w dns.ResponseWriter, req *dns.Msg, z *Zone) {
}
}

log.Println("Writing reply")

w.Write(m)
return
}
Expand Down

0 comments on commit ca218b3

Please sign in to comment.