This commit is contained in:
Miek Gieben 2012-06-20 20:16:36 +02:00
parent e6fca0be3f
commit 534433a714
6 changed files with 14 additions and 18 deletions

2
dns.go
View File

@ -106,7 +106,7 @@ type RR interface {
// Len returns the length (in octects) of the uncompressed RR in wire format.
Len() int
// Copy returns a copy of the RR
Copy() RR
Copy() RR
}
// Exchange is used in (asynchronous) communication with the resolver. If the

View File

@ -30,7 +30,7 @@ func AssertDelegationSigner(m *Msg, trustdb []*RR_DNSKEY) error {
var sig *RR_RRSIG
for _, r := range m.Ns {
if d, ok := r.(*RR_DS); ok {
dss = append(dss ,d)
dss = append(dss, d)
continue
}
if s, ok := r.(*RR_RRSIG); ok {
@ -50,7 +50,6 @@ func AssertDelegationSigner(m *Msg, trustdb []*RR_DNSKEY) error {
}
println("SIG found")
// Ownername of the DSs should match the qname
if CompareLabels(dss[0].Header().Name, m.Question[0].Name) == 0 {
// No match
@ -60,12 +59,10 @@ func AssertDelegationSigner(m *Msg, trustdb []*RR_DNSKEY) error {
println(dss[0].String())
println(sig.String())
return nil
}
// Types of answers (without looking the RFCs)
// len(m.Ns) > 0
// NS records in there? -> delegation (rcode should be rcode.Success)
@ -74,7 +71,6 @@ func AssertDelegationSigner(m *Msg, trustdb []*RR_DNSKEY) error {
// - plain old DNS delegation -> ...
// SOA record in there? -> nxdomain (rcode should be rcode.Nxdomain)
// Lookup does a (secure) DNS lookup. The message m contains
// the question to be asked. Lookup returns last packet seen
// which is either the answer or a packet somewhere in the
@ -108,7 +104,7 @@ func Lookup(m *Msg) (*Msg, error) {
// n is our reply, deal with it
// Check for DS
// Check for DS absent (NSEC/NSEC3)
if len(n.Ns) > 0 && len(n.Answer) == 0 && n.Rcode == RcodeSuccess { // Referral
if len(n.Ns) > 0 && len(n.Answer) == 0 && n.Rcode == RcodeSuccess { // Referral
// the ns name of the nameservers should match the right most labels. Check the answer
println("Referral")
for i, j := range addrFromReferral4(n) {

10
msg.go
View File

@ -92,16 +92,16 @@ type Msg struct {
var Rr_str = map[uint16]string{
TypeCNAME: "CNAME",
TypeHINFO: "HINFO",
TypeTLSA: "TSLA",
TypeTLSA: "TSLA",
TypeMB: "MB",
TypeMG: "MG",
TypeRP: "RP",
TypeMD: "MD",
TypeMF: "MF",
TypeRP: "RP",
TypeMD: "MD",
TypeMF: "MF",
TypeMINFO: "MINFO",
TypeMR: "MR",
TypeMX: "MX",
TypeWKS: "WKS",
TypeWKS: "WKS",
TypeNS: "NS",
TypePTR: "PTR",
TypeSOA: "SOA",

View File

@ -111,7 +111,7 @@ func (rr *RR_TSIG) Len() int {
}
func (rr *RR_TSIG) Copy() RR {
return &RR_TSIG{*rr.Hdr.CopyHeader(), rr.Algorithm, rr.TimeSigned, rr.Fudge, rr.MACSize, rr.MAC, rr.OrigId, rr.Error, rr.OtherLen, rr.OtherData}
return &RR_TSIG{*rr.Hdr.CopyHeader(), rr.Algorithm, rr.TimeSigned, rr.Fudge, rr.MACSize, rr.MAC, rr.OrigId, rr.Error, rr.OtherLen, rr.OtherData}
}
// The following values must be put in wireformat, so that the MAC can be calculated.

6
xfr.go
View File

@ -90,13 +90,13 @@ func (w *reply) ixfrReceive(c chan *Exchange) {
if first {
// A single SOA RR signals "no changes"
if len(in.Answer) == 1 && checkXfrSOA(in, true) {
c <- &Exchange{Request: w.req, Reply: in, Rtt: w.rtt, RemoteAddr: w.conn.RemoteAddr(), Error: nil}
c <- &Exchange{Request: w.req, Reply: in, Rtt: w.rtt, RemoteAddr: w.conn.RemoteAddr(), Error: nil}
return
}
// Check if the returned answer is ok
if !checkXfrSOA(in, true) {
c <- &Exchange{Request: w.req, Reply: in, Rtt: w.rtt, RemoteAddr: w.conn.RemoteAddr(), Error: ErrXfrSoa}
c <- &Exchange{Request: w.req, Reply: in, Rtt: w.rtt, RemoteAddr: w.conn.RemoteAddr(), Error: ErrXfrSoa}
return
}
// This serial is important
@ -110,7 +110,7 @@ func (w *reply) ixfrReceive(c chan *Exchange) {
// If the last record in the IXFR contains the servers' SOA, we should quit
if v, ok := in.Answer[len(in.Answer)-1].(*RR_SOA); ok {
if v.Serial == serial {
c <- &Exchange{Request: w.req, Reply: in, Rtt: w.rtt, RemoteAddr: w.conn.RemoteAddr(), Error: nil}
c <- &Exchange{Request: w.req, Reply: in, Rtt: w.rtt, RemoteAddr: w.conn.RemoteAddr(), Error: nil}
return
}
}

View File

@ -1093,7 +1093,7 @@ func setWKS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
l = <-c
rr.BitMap = make([]uint16, 0)
var (
k int
k int
err error
)
for l.value != _NEWLINE && l.value != _EOF {
@ -1102,7 +1102,7 @@ func setWKS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
// Ok
case _STRING:
if k, err = net.LookupPort(proto, l.token); err != nil {
if i, e := strconv.Atoi(l.token); e != nil { // If a number use that
if i, e := strconv.Atoi(l.token); e != nil { // If a number use that
rr.BitMap = append(rr.BitMap, uint16(i))
} else {
return nil, &ParseError{f, "bad WKS BitMap", l}