This commit is contained in:
Miek Gieben 2012-01-20 12:24:20 +01:00
parent 509912d4c4
commit 5917838cbb
9 changed files with 59 additions and 59 deletions

View File

@ -128,8 +128,8 @@ type Client struct {
Retry bool // retry with TCP Retry bool // retry with TCP
QueryChan chan *Request // read DNS request from this channel QueryChan chan *Request // read DNS request from this channel
ReplyChan chan *Exchange // write the reply (together with the DNS request) to this channel ReplyChan chan *Exchange // write the reply (together with the DNS request) to this channel
ReadTimeout time.Duration // the net.Conn.SetReadTimeout value for new connections (ns) ReadTimeout time.Duration // the net.Conn.SetReadTimeout value for new connections (ns)
WriteTimeout time.Duration // the net.Conn.SetWriteTimeout value for new connections (ns) WriteTimeout time.Duration // the net.Conn.SetWriteTimeout value for new connections (ns)
TsigSecret map[string]string // secret(s) for Tsig map[<zonename>]<base64 secret> TsigSecret map[string]string // secret(s) for Tsig map[<zonename>]<base64 secret>
Hijacked net.Conn // if set the calling code takes care of the connection Hijacked net.Conn // if set the calling code takes care of the connection
// LocalAddr string // Local address to use // LocalAddr string // Local address to use

View File

@ -54,10 +54,10 @@ func (dns *Msg) SetRcodeFormatError(request *Msg) {
// SetUpdate makes the message a dynamic update packet. It // SetUpdate makes the message a dynamic update packet. It
// sets the ZONE section to: z, TypeSOA, classINET. // sets the ZONE section to: z, TypeSOA, classINET.
func (dns *Msg) SetUpdate(z string) { func (dns *Msg) SetUpdate(z string) {
dns.MsgHdr.Id = Id() dns.MsgHdr.Id = Id()
dns.MsgHdr.Opcode = OpcodeUpdate dns.MsgHdr.Opcode = OpcodeUpdate
dns.Question = make([]Question, 1) dns.Question = make([]Question, 1)
dns.Question[0] = Question{z, TypeSOA, ClassINET} dns.Question[0] = Question{z, TypeSOA, ClassINET}
} }
// SetIxfr creates dns msg suitable for requesting an ixfr. // SetIxfr creates dns msg suitable for requesting an ixfr.

View File

@ -411,7 +411,7 @@ func (k *RR_DNSKEY) pubKeyCurve() *ecdsa.PublicKey {
case ECDSAP384SHA384: case ECDSAP384SHA384:
c = elliptic.P384() c = elliptic.P384()
} }
x, y := elliptic.Unmarshal(c,keybuf) x, y := elliptic.Unmarshal(c, keybuf)
pubkey := new(ecdsa.PublicKey) pubkey := new(ecdsa.PublicKey)
pubkey.X = x pubkey.X = x
pubkey.Y = y pubkey.Y = y
@ -484,32 +484,32 @@ func rawSignatureData(rrset RRset, s *RR_RRSIG) (buf []byte) {
name := h.Name name := h.Name
h.Name = strings.ToLower(h.Name) h.Name = strings.ToLower(h.Name)
// 6.2. Canonical RR Form. (3) - domain rdata to lowercaser // 6.2. Canonical RR Form. (3) - domain rdata to lowercaser
/* /*
switch h.Rrtype { switch h.Rrtype {
case TypeNS: case TypeNS:
r.(*RR_NS).Ns = strings.ToLower(r.(*RR_NS).Ns) r.(*RR_NS).Ns = strings.ToLower(r.(*RR_NS).Ns)
case TypeCNAME: case TypeCNAME:
r.(*RR_CNAME).Cname = strings.ToLower(r.(*RR_CNAME).Cname) r.(*RR_CNAME).Cname = strings.ToLower(r.(*RR_CNAME).Cname)
case TypeSOA: case TypeSOA:
r.(*RR_SOA).Ns = strings.ToLower(r.(*RR_SOA).Ns) r.(*RR_SOA).Ns = strings.ToLower(r.(*RR_SOA).Ns)
r.(*RR_SOA).Mbox = strings.ToLower(r.(*RR_SOA).Mbox) r.(*RR_SOA).Mbox = strings.ToLower(r.(*RR_SOA).Mbox)
case TypeMB: case TypeMB:
case TypeMG: case TypeMG:
case TypeMR: case TypeMR:
case TypePTR: case TypePTR:
r.(*RR_PTR).Ptr = strings.ToLower(r.(*RR_PTR).Ptr) r.(*RR_PTR).Ptr = strings.ToLower(r.(*RR_PTR).Ptr)
case TypeMINFO: case TypeMINFO:
case TypeMX: case TypeMX:
r.(*RR_MX).Mx = strings.ToLower(r.(*RR_MX).Mx) r.(*RR_MX).Mx = strings.ToLower(r.(*RR_MX).Mx)
case TypeSIG: case TypeSIG:
case TypeRRSIG: case TypeRRSIG:
case TypeSRV: case TypeSRV:
case TypeNSEC: case TypeNSEC:
r.(*RR_NSEC).NextDomain = strings.ToLower(r.(*RR_NSEC).NextDomain) r.(*RR_NSEC).NextDomain = strings.ToLower(r.(*RR_NSEC).NextDomain)
case TypeNSEC3: case TypeNSEC3:
r.(*RR_NSEC3).NextDomain = strings.ToLower(r.(*RR_NSEC3).NextDomain) r.(*RR_NSEC3).NextDomain = strings.ToLower(r.(*RR_NSEC3).NextDomain)
} }
*/ */
// 6.2. Canonical RR Form. (4) - wildcards // 6.2. Canonical RR Form. (4) - wildcards
// dont have to do anything // dont have to do anything

View File

@ -237,15 +237,15 @@ func TestKeyRSA(t *testing.T) {
sig.KeyTag = key.KeyTag() sig.KeyTag = key.KeyTag()
sig.SignerName = key.Hdr.Name sig.SignerName = key.Hdr.Name
if err := sig.Sign(priv, []RR{soa}); err != nil { if err := sig.Sign(priv, []RR{soa}); err != nil {
t.Logf("Failed to sign") t.Logf("Failed to sign")
t.Fail() t.Fail()
return return
} }
if err := sig.Verify(key, []RR{soa}); err != nil { if err := sig.Verify(key, []RR{soa}); err != nil {
t.Logf("Failed to verify") t.Logf("Failed to verify")
t.Fail() t.Fail()
} }
} }
func TestKeyToDS(t *testing.T) { func TestKeyToDS(t *testing.T) {

12
edns.go
View File

@ -129,12 +129,12 @@ func (rr *RR_OPT) SetDo() {
// Nsid returns the NSID as hex character string. // Nsid returns the NSID as hex character string.
func (rr *RR_OPT) Nsid() string { func (rr *RR_OPT) Nsid() string {
for i := 0; i < len(rr.Option); i++ { for i := 0; i < len(rr.Option); i++ {
if rr.Option[i].Code == OptionCodeNSID { if rr.Option[i].Code == OptionCodeNSID {
return "NSID: " + rr.Option[i].Data return "NSID: " + rr.Option[i].Data
} }
} }
return "Not found" return "Not found"
} }
// SetNsid sets the NSID from a hex character string. // SetNsid sets the NSID from a hex character string.

4
msg.go
View File

@ -53,8 +53,8 @@ var (
ErrRRset error = &Error{Err: "invalid rrset"} ErrRRset error = &Error{Err: "invalid rrset"}
ErrDenialNsec3 error = &Error{Err: "no NSEC3 records"} ErrDenialNsec3 error = &Error{Err: "no NSEC3 records"}
ErrDenialCe error = &Error{Err: "no matching closest encloser found"} ErrDenialCe error = &Error{Err: "no matching closest encloser found"}
ErrDenialNc error = &Error{Err: "no covering NSEC3 found for next closer"} ErrDenialNc error = &Error{Err: "no covering NSEC3 found for next closer"}
ErrDenialSo error = &Error{Err: "no covering NSEC3 found for source of synthesis"} ErrDenialSo error = &Error{Err: "no covering NSEC3 found for source of synthesis"}
) )
// A manually-unpacked version of (id, bits). // A manually-unpacked version of (id, bits).

View File

@ -129,31 +129,31 @@ func (m *Msg) Nsec3Verify(q Question) error {
hashednc := HashName(nc, hash, iter, salt) hashednc := HashName(nc, hash, iter, salt)
if hashednc > firstlab && hashednc < nextdom { if hashednc > firstlab && hashednc < nextdom {
ncdenied = true ncdenied = true
break break
} }
} }
if !ncdenied { if !ncdenied {
return ErrDenialNc return ErrDenialNc
} }
// Check if the source of synthesis is covered and thus denied // Check if the source of synthesis is covered and thus denied
for _, nsec := range nsec3 { for _, nsec := range nsec3 {
firstlab := strings.ToUpper(SplitLabels(nsec.Header().Name)[0]) firstlab := strings.ToUpper(SplitLabels(nsec.Header().Name)[0])
nextdom := strings.ToUpper(nsec.NextDomain) nextdom := strings.ToUpper(nsec.NextDomain)
hashedso := HashName(so, hash, iter, salt) hashedso := HashName(so, hash, iter, salt)
if hashedso > firstlab && hashedso < nextdom { if hashedso > firstlab && hashedso < nextdom {
sodenied = true sodenied = true
break break
} }
} }
if !sodenied { if !sodenied {
return ErrDenialSo return ErrDenialSo
} }
println("NSEC3 proof succesfully proofed") println("NSEC3 proof succesfully proofed")
return nil return nil
} }
/* /*
*/ */
return nil return nil
} }

View File

@ -143,8 +143,8 @@ type Server struct {
Net string // if "tcp" it will invoke a TCP listener, otherwise an UDP one Net string // if "tcp" it will invoke a TCP listener, otherwise an UDP one
Handler Handler // handler to invoke, dns.DefaultServeMux if nil Handler Handler // handler to invoke, dns.DefaultServeMux if nil
UDPSize int // default buffer to use to read incoming UDP messages UDPSize int // default buffer to use to read incoming UDP messages
ReadTimeout time.Duration // the net.Conn.SetReadTimeout value for new connections ReadTimeout time.Duration // the net.Conn.SetReadTimeout value for new connections
WriteTimeout time.Duration // the net.Conn.SetWriteTimeout value for new connections WriteTimeout time.Duration // the net.Conn.SetWriteTimeout value for new connections
TsigSecret map[string]string // secret(s) for Tsig map[<zonename>]<base64 secret> TsigSecret map[string]string // secret(s) for Tsig map[<zonename>]<base64 secret>
} }

View File

@ -34,7 +34,7 @@ package dns
import ( import (
"crypto/hmac" "crypto/hmac"
"crypto/md5" "crypto/md5"
"encoding/hex" "encoding/hex"
"io" "io"
"strings" "strings"