Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
miekg committed Aug 31, 2012
1 parent 3f189ca commit 0e0cd57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
26 changes: 10 additions & 16 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,32 +228,26 @@ func setupZoneData(data map[string]interface{}, Zone *Zone) {
}
switch dnsType {
case dns.TypeA:
rr := &dns.RR_A{Hdr: h}
rr.A = net.ParseIP(ip)
if rr.A == nil {
panic("Bad A record")
if x := net.ParseIP(ip); x != nil {
record.RR = &dns.RR_A{Hdr: h, A: x}
break
}
record.RR = rr
panic("Bad A record")
case dns.TypeAAAA:
rr := &dns.RR_AAAA{Hdr: h}
rr.AAAA = net.ParseIP(ip)
if rr.AAAA == nil {
panic("Bad AAAA record")
if x := net.ParseIP(ip); x != nil {
record.RR = &dns.RR_AAAA{Hdr: h, AAAA: x}
break
}
record.RR = rr
panic("Bad AAAA record")
}

case dns.TypeCNAME:
rec := records[rType][i]
rr := &dns.RR_CNAME{Hdr: h}
rr.Target = rec.(string)
record.RR = rr
record.RR = &dns.RR_CNAME{Hdr: h, Target: dns.Fqdn(rec.(string))}

case dns.TypeMF:
rec := records[rType][i]
rr := &dns.RR_MF{Hdr: h}
rr.Mf = rec.(string)
record.RR = rr
record.RR = &dns.RR_MF{Hdr: h, Mf: dns.Fqdn(rec.(string))}

case dns.TypeNS:
rec := records[rType][i]
Expand Down
2 changes: 2 additions & 0 deletions serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ func serve(w dns.ResponseWriter, req *dns.Msg, z *Zone) {

logPrintln(m)

// Ideally you would check the return code here, and perform SERVFAIL in case of
// an error.
w.Write(m)
return
}
Expand Down

0 comments on commit 0e0cd57

Please sign in to comment.