diff --git a/README b/README index 0dc13665..98e8c2ca 100644 --- a/README +++ b/README @@ -5,6 +5,10 @@ to send it. The library is asynchronise (thanks to Go) from the get go. +Implemented RFCS + +* RFC2671, EDNS + * ldns * NSD * Net::DNS diff --git a/dnssectest.go b/dnssectest.go index 5755233d..39941d1a 100644 --- a/dnssectest.go +++ b/dnssectest.go @@ -60,6 +60,10 @@ func main() { in = <-ch fmt.Printf("%v\n", in.Dns) + m.Question[0] = dns.Question{"xxxx.nlnetlabs.nl", dns.TypeDNSKEY, dns.ClassINET} + ch <- dns.DnsMsg{m, nil} + in = <-ch + fmt.Printf("%v\n", in.Dns) ch <- dns.DnsMsg{nil, nil} time.Sleep(1.0e9) // wait for Go routine to do something diff --git a/msg.go b/msg.go index a89b34a5..47a4b276 100644 --- a/msg.go +++ b/msg.go @@ -491,6 +491,9 @@ type MsgHdr struct { Truncated bool Recursion_desired bool Recursion_available bool + Z bool + Authenticated_data bool + Checking_disabled bool Rcode int } @@ -506,6 +509,9 @@ func (h *MsgHdr) String() string { s += ", id: " + strconv.Itoa(int(h.Id)) + "\n" s += ";; flags: " + if h.Response { + s += "qr " + } if h.Authoritative { s += "aa " } @@ -518,6 +524,16 @@ func (h *MsgHdr) String() string { if h.Recursion_available { s += "ra " } + if h.Z { + s += "z " + } + if h.Authenticated_data { + s += "ad " + } + if h.Checking_disabled { + s += "cd " + } + s += ";" return s } @@ -538,20 +554,29 @@ func (dns *Msg) Pack() (msg []byte, ok bool) { // Convert convenient Msg into wire-like Header. dh.Id = dns.Id dh.Bits = uint16(dns.Opcode)<<11 | uint16(dns.Rcode) - if dns.Recursion_available { - dh.Bits |= _RA - } - if dns.Recursion_desired { - dh.Bits |= _RD - } - if dns.Truncated { - dh.Bits |= _TC + if dns.Response { + dh.Bits |= _QR } if dns.Authoritative { dh.Bits |= _AA } - if dns.Response { - dh.Bits |= _QR + if dns.Truncated { + dh.Bits |= _TC + } + if dns.Recursion_desired { + dh.Bits |= _RD + } + if dns.Recursion_available { + dh.Bits |= _RA + } + if dns.Z { + dh.Bits |= _Z + } + if dns.Authenticated_data { + dh.Bits |= _AD + } + if dns.Checking_disabled { + dh.Bits |= _CD } // Prepare variable sized arrays. diff --git a/packtest.go b/packtest.go index 33adcf4c..4208842a 100644 --- a/packtest.go +++ b/packtest.go @@ -44,6 +44,4 @@ func main() { msg, _ = out.Pack() in.Unpack(msg) fmt.Printf("%v\n", in) - - } diff --git a/restest.go b/restest.go index dce4d692..eedde8ca 100644 --- a/restest.go +++ b/restest.go @@ -25,38 +25,13 @@ func main() { m.MsgHdr.Recursion_desired = true //only set this bit m.Question = make([]dns.Question, 1) - for i:=0; i< NLOOP; i++ { - // ask something - m.Question[0] = dns.Question{"miek.nl", dns.TypeSOA, dns.ClassINET} - ch <- dns.DnsMsg{m, nil} + m.Question[0] = dns.Question{"forfunsec.org", dns.TypeRRSIG, dns.ClassINET} + ch <- dns.DnsMsg{m, nil} - // wait for an reply - in := <-ch - fmt.Printf("%v\n", in.Dns) + // wait for an reply + in := <-ch + fmt.Printf("%v\n", in.Dns) - m.Question[0] = dns.Question{"a.miek.nl", dns.TypeTXT, dns.ClassINET} - ch <- dns.DnsMsg{m, nil} - in = <-ch - fmt.Printf("%v\n", in.Dns) - - m.Question[0] = dns.Question{"miek.nl", dns.TypeTXT, dns.ClassINET} - ch <- dns.DnsMsg{m, nil} - in = <-ch - fmt.Printf("%v\n", in.Dns) - - m.Question[0] = dns.Question{"nl", dns.TypeDNSKEY, dns.ClassINET} - ch <- dns.DnsMsg{m, nil} - in = <-ch - fmt.Printf("%v\n", in.Dns) - - m.Question[0] = dns.Question{"pa1ton.nl", dns.TypeDS, dns.ClassINET} - ch <- dns.DnsMsg{m, nil} - in = <-ch - fmt.Printf("%v\n", in.Dns) - - - - } ch <- dns.DnsMsg{nil, nil} time.Sleep(2.0e9) // wait for Go routine to do something diff --git a/types.go b/types.go index 55d568d8..369105b7 100644 --- a/types.go +++ b/types.go @@ -84,8 +84,10 @@ const ( _TC = 1 << 9 // truncated _RD = 1 << 8 // recursion desired _RA = 1 << 7 // recursion available - // _AD = 1 << ? // authenticated data - // _CD = 1 << ? // checking disabled + _Z = 1 << 6 // Z + _AD = 1 << 5 // authticated data + _CD = 1 << 4 // checking disabled + // EDNS // _DO = 1 << ? // dnssec ok )