Rename the RR types drop the RR_ prefix

This is also done in the official Go library. It also make the
code shorter.
This commit is contained in:
Miek Gieben 2012-12-09 19:23:25 +01:00
parent 3609f3e7a5
commit 235e892dfc
22 changed files with 530 additions and 530 deletions

View File

@ -95,7 +95,7 @@ func TestUpdateLeaseTSIG(t *testing.T) {
rrs[0] = rr
m.Insert(rrs)
lease_rr := new(RR_OPT)
lease_rr := new(OPT)
lease_rr.Hdr.Name = "."
lease_rr.Hdr.Rrtype = TypeOPT
e := new(EDNS0_UPDATE_LEASE)

View File

@ -85,7 +85,7 @@ func (dns *Msg) SetIxfr(z string, serial uint32) *Msg {
dns.Id = Id()
dns.Question = make([]Question, 1)
dns.Ns = make([]RR, 1)
s := new(RR_SOA)
s := new(SOA)
s.Hdr = RR_Header{z, TypeSOA, ClassINET, defaultTtl, 0}
s.Serial = serial
dns.Question[0] = Question{z, TypeIXFR, ClassINET}
@ -105,7 +105,7 @@ func (dns *Msg) SetAxfr(z string) *Msg {
// This is only a skeleton TSIG RR that is added as the last RR in the
// additional section. The Tsig is calculated when the message is being send.
func (dns *Msg) SetTsig(z, algo string, fudge, timesigned int64) *Msg {
t := new(RR_TSIG)
t := new(TSIG)
t.Hdr = RR_Header{z, TypeTSIG, ClassANY, 0, 0}
t.Algorithm = algo
t.Fudge = 300
@ -118,7 +118,7 @@ func (dns *Msg) SetTsig(z, algo string, fudge, timesigned int64) *Msg {
// SetEdns0 appends a EDNS0 OPT RR to the message.
// TSIG should always the last RR in a message.
func (dns *Msg) SetEdns0(udpsize uint16, do bool) *Msg {
e := new(RR_OPT)
e := new(OPT)
e.Hdr.Name = "."
e.Hdr.Rrtype = TypeOPT
e.SetUDPSize(udpsize)
@ -131,10 +131,10 @@ func (dns *Msg) SetEdns0(udpsize uint16, do bool) *Msg {
// IsTsig checks if the message has a TSIG record as the last record
// in the additional section. It returns the TSIG record found or nil.
func (dns *Msg) IsTsig() *RR_TSIG {
func (dns *Msg) IsTsig() *TSIG {
if len(dns.Extra) > 0 {
if dns.Extra[len(dns.Extra)-1].Header().Rrtype == TypeTSIG {
return dns.Extra[len(dns.Extra)-1].(*RR_TSIG)
return dns.Extra[len(dns.Extra)-1].(*TSIG)
}
}
return nil
@ -143,10 +143,10 @@ func (dns *Msg) IsTsig() *RR_TSIG {
// IsEdns0 checks if the message has a EDNS0 (OPT) record, any EDNS0
// record in the additional section will do. It returns the OPT record
// found or nil.
func (dns *Msg) IsEdns0() *RR_OPT {
func (dns *Msg) IsEdns0() *OPT {
for _, r := range dns.Extra {
if r.Header().Rrtype == TypeOPT {
return r.(*RR_OPT)
return r.(*OPT)
}
}
return nil

View File

@ -11,8 +11,8 @@ import (
func TestPackUnpack(t *testing.T) {
out := new(Msg)
out.Answer = make([]RR, 1)
key := new(RR_DNSKEY)
key = &RR_DNSKEY{Flags: 257, Protocol: 3, Algorithm: RSASHA1}
key := new(DNSKEY)
key = &DNSKEY{Flags: 257, Protocol: 3, Algorithm: RSASHA1}
key.Hdr = RR_Header{Name: "miek.nl.", Rrtype: TypeDNSKEY, Class: ClassINET, Ttl: 3600}
key.PublicKey = "AwEAAaHIwpx3w4VHKi6i1LHnTaWeHCL154Jug0Rtc9ji5qwPXpBo6A5sRv7cSsPQKPIwxLpyCrbJ4mr2L0EPOdvP6z6YfljK2ZmTbogU9aSU2fiq/4wjxbdkLyoDVgtO+JsxNN4bjr4WcWhsmk1Hg93FV9ZpkWb0Tbad8DFqNDzr//kZ"
@ -28,8 +28,8 @@ func TestPackUnpack(t *testing.T) {
t.Fail()
}
sig := new(RR_RRSIG)
sig = &RR_RRSIG{TypeCovered: TypeDNSKEY, Algorithm: RSASHA1, Labels: 2,
sig := new(RRSIG)
sig = &RRSIG{TypeCovered: TypeDNSKEY, Algorithm: RSASHA1, Labels: 2,
OrigTtl: 3600, Expiration: 4000, Inception: 4000, KeyTag: 34641, SignerName: "miek.nl.",
Signature: "AwEAAaHIwpx3w4VHKi6i1LHnTaWeHCL154Jug0Rtc9ji5qwPXpBo6A5sRv7cSsPQKPIwxLpyCrbJ4mr2L0EPOdvP6z6YfljK2ZmTbogU9aSU2fiq/4wjxbdkLyoDVgtO+JsxNN4bjr4WcWhsmk1Hg93FV9ZpkWb0Tbad8DFqNDzr//kZ"}
sig.Hdr = RR_Header{Name: "miek.nl.", Rrtype: TypeRRSIG, Class: ClassINET, Ttl: 3600}
@ -52,11 +52,11 @@ func TestPackUnpack2(t *testing.T) {
m.Extra = make([]RR, 1)
m.Answer = make([]RR, 1)
dom := "miek.nl."
rr := new(RR_A)
rr := new(A)
rr.Hdr = RR_Header{Name: dom, Rrtype: TypeA, Class: ClassINET, Ttl: 0}
rr.A = net.IPv4(127, 0, 0, 1)
x := new(RR_TXT)
x := new(TXT)
x.Hdr = RR_Header{Name: dom, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}
x.Txt = []string{"heelalaollo"}
@ -119,7 +119,7 @@ func TestPack(t *testing.T) {
}
x := new(Msg)
ns, _ := NewRR("pool.ntp.org. 390 IN NS a.ntpns.org")
ns.(*RR_NS).Ns = "a.ntpns.org"
ns.(*NS).Ns = "a.ntpns.org"
x.Ns = append(m.Ns, ns)
x.Ns = append(m.Ns, ns)
x.Ns = append(m.Ns, ns)

View File

@ -99,7 +99,7 @@ type dnskeyWireFmt struct {
}
// KeyTag calculates the keytag (or key-id) of the DNSKEY.
func (k *RR_DNSKEY) KeyTag() uint16 {
func (k *DNSKEY) KeyTag() uint16 {
if k == nil {
return 0
}
@ -140,11 +140,11 @@ func (k *RR_DNSKEY) KeyTag() uint16 {
}
// ToDS converts a DNSKEY record to a DS record.
func (k *RR_DNSKEY) ToDS(h int) *RR_DS {
func (k *DNSKEY) ToDS(h int) *DS {
if k == nil {
return nil
}
ds := new(RR_DS)
ds := new(DS)
ds.Hdr.Name = k.Hdr.Name
ds.Hdr.Class = k.Hdr.Class
ds.Hdr.Rrtype = TypeDS
@ -205,7 +205,7 @@ func (k *RR_DNSKEY) ToDS(h int) *RR_DS {
// The rest is copied from the RRset. Sign returns true when the signing went OK,
// otherwise false.
// There is no check if RRSet is a proper (RFC 2181) RRSet.
func (rr *RR_RRSIG) Sign(k PrivateKey, rrset []RR) error {
func (rr *RRSIG) Sign(k PrivateKey, rrset []RR) error {
if k == nil {
return ErrPrivKey
}
@ -310,7 +310,7 @@ func (rr *RR_RRSIG) Sign(k PrivateKey, rrset []RR) error {
// Verify validates an RRSet with the signature and key. This is only the
// cryptographic test, the signature validity period must be checked separately.
// This function copies the rdata of some RRs (to lowercase domain names) for the validation to work.
func (rr *RR_RRSIG) Verify(k *RR_DNSKEY, rrset []RR) error {
func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error {
// First the easy checks
if len(rrset) == 0 {
return ErrRRset
@ -425,7 +425,7 @@ func (rr *RR_RRSIG) Verify(k *RR_DNSKEY, rrset []RR) error {
// ValidityPeriod uses RFC1982 serial arithmetic to calculate
// if a signature period is valid.
func (rr *RR_RRSIG) ValidityPeriod() bool {
func (rr *RRSIG) ValidityPeriod() bool {
utc := time.Now().UTC().Unix()
modi := (int64(rr.Inception) - utc) / year68
mode := (int64(rr.Expiration) - utc) / year68
@ -435,7 +435,7 @@ func (rr *RR_RRSIG) ValidityPeriod() bool {
}
// Return the signatures base64 encodedig sigdata as a byte slice.
func (s *RR_RRSIG) sigBuf() []byte {
func (s *RRSIG) sigBuf() []byte {
sigbuf, err := packBase64([]byte(s.Signature))
if err != nil {
return nil
@ -444,7 +444,7 @@ func (s *RR_RRSIG) sigBuf() []byte {
}
// setPublicKeyInPrivate sets the public key in the private key.
func (k *RR_DNSKEY) setPublicKeyInPrivate(p PrivateKey) bool {
func (k *DNSKEY) setPublicKeyInPrivate(p PrivateKey) bool {
switch t := p.(type) {
case *dsa.PrivateKey:
x := k.publicKeyDSA()
@ -469,7 +469,7 @@ func (k *RR_DNSKEY) setPublicKeyInPrivate(p PrivateKey) bool {
}
// publicKeyRSA returns the RSA public key from a DNSKEY record.
func (k *RR_DNSKEY) publicKeyRSA() *rsa.PublicKey {
func (k *DNSKEY) publicKeyRSA() *rsa.PublicKey {
keybuf, err := packBase64([]byte(k.PublicKey))
if err != nil {
return nil
@ -507,7 +507,7 @@ func (k *RR_DNSKEY) publicKeyRSA() *rsa.PublicKey {
}
// publicKeyCurve returns the Curve public key from the DNSKEY record.
func (k *RR_DNSKEY) publicKeyCurve() *ecdsa.PublicKey {
func (k *DNSKEY) publicKeyCurve() *ecdsa.PublicKey {
keybuf, err := packBase64([]byte(k.PublicKey))
if err != nil {
return nil
@ -534,7 +534,7 @@ func (k *RR_DNSKEY) publicKeyCurve() *ecdsa.PublicKey {
return pubkey
}
func (k *RR_DNSKEY) publicKeyDSA() *dsa.PublicKey {
func (k *DNSKEY) publicKeyDSA() *dsa.PublicKey {
keybuf, err := packBase64([]byte(k.PublicKey))
if err != nil {
return nil
@ -557,7 +557,7 @@ func (k *RR_DNSKEY) publicKeyDSA() *dsa.PublicKey {
}
// Set the public key (the value E and N)
func (k *RR_DNSKEY) setPublicKeyRSA(_E int, _N *big.Int) bool {
func (k *DNSKEY) setPublicKeyRSA(_E int, _N *big.Int) bool {
if _E == 0 || _N == nil {
return false
}
@ -568,7 +568,7 @@ func (k *RR_DNSKEY) setPublicKeyRSA(_E int, _N *big.Int) bool {
}
// Set the public key for Elliptic Curves
func (k *RR_DNSKEY) setPublicKeyCurve(_X, _Y *big.Int) bool {
func (k *DNSKEY) setPublicKeyCurve(_X, _Y *big.Int) bool {
if _X == nil || _Y == nil {
return false
}
@ -579,7 +579,7 @@ func (k *RR_DNSKEY) setPublicKeyCurve(_X, _Y *big.Int) bool {
}
// Set the public key for DSA
func (k *RR_DNSKEY) setPublicKeyDSA(_Q, _P, _G, _Y *big.Int) bool {
func (k *DNSKEY) setPublicKeyDSA(_Q, _P, _G, _Y *big.Int) bool {
if _Q == nil || _P == nil || _G == nil || _Y == nil {
return false
}
@ -637,7 +637,7 @@ func (p wireSlice) Less(i, j int) bool {
func (p wireSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
// Return the raw signature data.
func rawSignatureData(rrset []RR, s *RR_RRSIG) (buf []byte) {
func rawSignatureData(rrset []RR, s *RRSIG) (buf []byte) {
wires := make(wireSlice, len(rrset))
for i, r := range rrset {
r1 := r.Copy()
@ -655,33 +655,33 @@ func rawSignatureData(rrset []RR, s *RR_RRSIG) (buf []byte) {
// HINFO, MINFO, MX, RP, AFSDB, RT, SIG, PX, NXT, NAPTR, KX,
// SRV, DNAME, A6
switch x := r.(type) {
case *RR_NS:
case *NS:
x.Ns = strings.ToLower(x.Ns)
case *RR_CNAME:
case *CNAME:
x.Target = strings.ToLower(x.Target)
case *RR_SOA:
case *SOA:
x.Ns = strings.ToLower(x.Ns)
x.Mbox = strings.ToLower(x.Mbox)
case *RR_MB:
case *MB:
x.Mb = strings.ToLower(x.Mb)
case *RR_MG:
case *MG:
x.Mg = strings.ToLower(x.Mg)
case *RR_MR:
case *MR:
x.Mr = strings.ToLower(x.Mr)
case *RR_PTR:
case *PTR:
x.Ptr = strings.ToLower(x.Ptr)
case *RR_MINFO:
case *MINFO:
x.Rmail = strings.ToLower(x.Rmail)
x.Email = strings.ToLower(x.Email)
case *RR_MX:
case *MX:
x.Mx = strings.ToLower(x.Mx)
case *RR_NAPTR:
case *NAPTR:
x.Replacement = strings.ToLower(x.Replacement)
case *RR_KX:
case *KX:
x.Exchanger = strings.ToLower(x.Exchanger)
case *RR_SRV:
case *SRV:
x.Target = strings.ToLower(x.Target)
case *RR_DNAME:
case *DNAME:
x.Target = strings.ToLower(x.Target)
}
// 6.2. Canonical RR Form. (5) - origTTL

View File

@ -6,8 +6,8 @@ import (
"testing"
)
func getKey() *RR_DNSKEY {
key := new(RR_DNSKEY)
func getKey() *DNSKEY {
key := new(DNSKEY)
key.Hdr.Name = "miek.nl."
key.Hdr.Class = ClassINET
key.Hdr.Ttl = 14400
@ -18,8 +18,8 @@ func getKey() *RR_DNSKEY {
return key
}
func getSoa() *RR_SOA {
soa := new(RR_SOA)
func getSoa() *SOA {
soa := new(SOA)
soa.Hdr = RR_Header{"miek.nl.", TypeSOA, ClassINET, 14400, 0}
soa.Ns = "open.nlnetlabs.nl."
soa.Mbox = "miekg.atoom.net."
@ -32,7 +32,7 @@ func getSoa() *RR_SOA {
}
func TestGenerateEC(t *testing.T) {
key := new(RR_DNSKEY)
key := new(DNSKEY)
key.Hdr.Rrtype = TypeDNSKEY
key.Hdr.Name = "miek.nl."
key.Hdr.Class = ClassINET
@ -46,7 +46,7 @@ func TestGenerateEC(t *testing.T) {
}
func TestGenerateDSA(t *testing.T) {
key := new(RR_DNSKEY)
key := new(DNSKEY)
key.Hdr.Rrtype = TypeDNSKEY
key.Hdr.Name = "miek.nl."
key.Hdr.Class = ClassINET
@ -60,7 +60,7 @@ func TestGenerateDSA(t *testing.T) {
}
func TestGenerateRSA(t *testing.T) {
key := new(RR_DNSKEY)
key := new(DNSKEY)
key.Hdr.Rrtype = TypeDNSKEY
key.Hdr.Name = "miek.nl."
key.Hdr.Class = ClassINET
@ -76,7 +76,7 @@ func TestGenerateRSA(t *testing.T) {
func TestSecure(t *testing.T) {
soa := getSoa()
sig := new(RR_RRSIG)
sig := new(RRSIG)
sig.Hdr = RR_Header{"miek.nl.", TypeRRSIG, ClassINET, 14400, 0}
sig.TypeCovered = TypeSOA
sig.Algorithm = RSASHA256
@ -88,7 +88,7 @@ func TestSecure(t *testing.T) {
sig.SignerName = "miek.nl."
sig.Signature = "oMCbslaAVIp/8kVtLSms3tDABpcPRUgHLrOR48OOplkYo+8TeEGWwkSwaz/MRo2fB4FxW0qj/hTlIjUGuACSd+b1wKdH5GvzRJc2pFmxtCbm55ygAh4EUL0F6U5cKtGJGSXxxg6UFCQ0doJCmiGFa78LolaUOXImJrk6AFrGa0M="
key := new(RR_DNSKEY)
key := new(DNSKEY)
key.Hdr.Name = "miek.nl."
key.Hdr.Class = ClassINET
key.Hdr.Ttl = 14400
@ -105,7 +105,7 @@ func TestSecure(t *testing.T) {
}
func TestSignature(t *testing.T) {
sig := new(RR_RRSIG)
sig := new(RRSIG)
sig.Hdr.Name = "miek.nl."
sig.Hdr.Class = ClassINET
sig.Hdr.Ttl = 3600
@ -135,7 +135,7 @@ func TestSignature(t *testing.T) {
func TestSignVerify(t *testing.T) {
// The record we want to sign
soa := new(RR_SOA)
soa := new(SOA)
soa.Hdr = RR_Header{"miek.nl.", TypeSOA, ClassINET, 14400, 0}
soa.Ns = "open.nlnetlabs.nl."
soa.Mbox = "miekg.atoom.net."
@ -145,7 +145,7 @@ func TestSignVerify(t *testing.T) {
soa.Expire = 604800
soa.Minttl = 86400
soa1 := new(RR_SOA)
soa1 := new(SOA)
soa1.Hdr = RR_Header{"*.miek.nl.", TypeSOA, ClassINET, 14400, 0}
soa1.Ns = "open.nlnetlabs.nl."
soa1.Mbox = "miekg.atoom.net."
@ -156,7 +156,7 @@ func TestSignVerify(t *testing.T) {
soa1.Minttl = 86400
// With this key
key := new(RR_DNSKEY)
key := new(DNSKEY)
key.Hdr.Rrtype = TypeDNSKEY
key.Hdr.Name = "miek.nl."
key.Hdr.Class = ClassINET
@ -167,7 +167,7 @@ func TestSignVerify(t *testing.T) {
privkey, _ := key.Generate(512)
// Fill in the values of the Sig, before signing
sig := new(RR_RRSIG)
sig := new(RRSIG)
sig.Hdr = RR_Header{"miek.nl.", TypeRRSIG, ClassINET, 14400, 0}
sig.TypeCovered = soa.Hdr.Rrtype
sig.Labels, _, _ = IsDomainName(soa.Hdr.Name)
@ -197,14 +197,14 @@ func TestDnskey(t *testing.T) {
f, _ := os.Open("t/Kmiek.nl.+010+05240.key")
pubkey, _ := ReadRR(f, "t/Kmiek.nl.+010+05240.key")
f, _ = os.Open("t/Kmiek.nl.+010+05240.private")
privkey, _ := pubkey.(*RR_DNSKEY).ReadPrivateKey(f, "t/Kmiek.nl.+010+05240.private")
privkey, _ := pubkey.(*DNSKEY).ReadPrivateKey(f, "t/Kmiek.nl.+010+05240.private")
// Okay, we assume this has gone OK
if pubkey.(*RR_DNSKEY).PublicKey != "AwEAAZuMCu2FdugHkTrXYgl5qixvcDw1aDDlvL46/xJKbHBAHY16fNUb2b65cwko2Js/aJxUYJbZk5dwCDZxYfrfbZVtDPQuc3o8QaChVxC7/JYz2AHc9qHvqQ1j4VrH71RWINlQo6VYjzN/BGpMhOZoZOEwzp1HfsOE3lNYcoWU1smL" {
if pubkey.(*DNSKEY).PublicKey != "AwEAAZuMCu2FdugHkTrXYgl5qixvcDw1aDDlvL46/xJKbHBAHY16fNUb2b65cwko2Js/aJxUYJbZk5dwCDZxYfrfbZVtDPQuc3o8QaChVxC7/JYz2AHc9qHvqQ1j4VrH71RWINlQo6VYjzN/BGpMhOZoZOEwzp1HfsOE3lNYcoWU1smL" {
t.Log("Pubkey is not what we've read")
t.Fail()
}
// Coefficient looks fishy...
t.Logf("%s", pubkey.(*RR_DNSKEY).PrivateKeyString(privkey))
t.Logf("%s", pubkey.(*DNSKEY).PrivateKeyString(privkey))
}
/*
@ -255,7 +255,7 @@ func TestDnskey(t *testing.T) {
*/
func TestTag(t *testing.T) {
key := new(RR_DNSKEY)
key := new(DNSKEY)
key.Hdr.Name = "miek.nl."
key.Hdr.Rrtype = TypeDNSKEY
key.Hdr.Class = ClassINET
@ -273,7 +273,7 @@ func TestTag(t *testing.T) {
}
func TestKeyRSA(t *testing.T) {
key := new(RR_DNSKEY)
key := new(DNSKEY)
key.Hdr.Name = "miek.nl."
key.Hdr.Rrtype = TypeDNSKEY
key.Hdr.Class = ClassINET
@ -283,7 +283,7 @@ func TestKeyRSA(t *testing.T) {
key.Algorithm = RSASHA256
priv, _ := key.Generate(2048)
soa := new(RR_SOA)
soa := new(SOA)
soa.Hdr = RR_Header{"miek.nl.", TypeSOA, ClassINET, 14400, 0}
soa.Ns = "open.nlnetlabs.nl."
soa.Mbox = "miekg.atoom.net."
@ -293,7 +293,7 @@ func TestKeyRSA(t *testing.T) {
soa.Expire = 604800
soa.Minttl = 86400
sig := new(RR_RRSIG)
sig := new(RRSIG)
sig.Hdr = RR_Header{"miek.nl.", TypeRRSIG, ClassINET, 14400, 0}
sig.TypeCovered = TypeSOA
sig.Algorithm = RSASHA256
@ -316,7 +316,7 @@ func TestKeyRSA(t *testing.T) {
}
func TestKeyToDS(t *testing.T) {
key := new(RR_DNSKEY)
key := new(DNSKEY)
key.Hdr.Name = "miek.nl."
key.Hdr.Rrtype = TypeDNSKEY
key.Hdr.Class = ClassINET

24
edns.go
View File

@ -41,16 +41,16 @@ const (
_DO = 1 << 7 // dnssec ok
)
type RR_OPT struct {
type OPT struct {
Hdr RR_Header
Option []EDNS0 `dns:"opt"`
}
func (rr *RR_OPT) Header() *RR_Header {
func (rr *OPT) Header() *RR_Header {
return &rr.Hdr
}
func (rr *RR_OPT) String() string {
func (rr *OPT) String() string {
s := "\n;; OPT PSEUDOSECTION:\n; EDNS: version " + strconv.Itoa(int(rr.Version())) + "; "
if rr.Do() {
s += "flags: do; "
@ -80,7 +80,7 @@ func (rr *RR_OPT) String() string {
return s
}
func (rr *RR_OPT) Len() int {
func (rr *OPT) Len() int {
l := rr.Hdr.Len()
for i := 0; i < len(rr.Option); i++ {
lo, _ := rr.Option[i].pack()
@ -89,37 +89,37 @@ func (rr *RR_OPT) Len() int {
return l
}
func (rr *RR_OPT) Copy() RR {
return &RR_OPT{*rr.Hdr.CopyHeader(), rr.Option}
func (rr *OPT) Copy() RR {
return &OPT{*rr.Hdr.CopyHeader(), rr.Option}
}
// Version returns the EDNS version used. Only zero is defined.
func (rr *RR_OPT) Version() uint8 {
func (rr *OPT) Version() uint8 {
return uint8(rr.Hdr.Ttl & 0x00FF00FFFF)
}
// SetVersion sets the version of EDNS. This is usually zero.
func (rr *RR_OPT) SetVersion(v uint8) {
func (rr *OPT) SetVersion(v uint8) {
rr.Hdr.Ttl = rr.Hdr.Ttl&0xFF00FFFF | uint32(v)
}
// UDPSize returns the UDP buffer size.
func (rr *RR_OPT) UDPSize() uint16 {
func (rr *OPT) UDPSize() uint16 {
return rr.Hdr.Class
}
// SetUDPSize sets the UDP buffer size.
func (rr *RR_OPT) SetUDPSize(size uint16) {
func (rr *OPT) SetUDPSize(size uint16) {
rr.Hdr.Class = size
}
// Do returns the value of the DO (DNSSEC OK) bit.
func (rr *RR_OPT) Do() bool {
func (rr *OPT) Do() bool {
return byte(rr.Hdr.Ttl>>8)&_DO == _DO
}
// SetDo sets the DO (DNSSEC OK) bit.
func (rr *RR_OPT) SetDo() {
func (rr *OPT) SetDo() {
b1 := byte(rr.Hdr.Ttl >> 24)
b2 := byte(rr.Hdr.Ttl >> 16)
b3 := byte(rr.Hdr.Ttl >> 8)

View File

@ -19,7 +19,7 @@ func ExampleRR_MX() {
return
}
for _, a := range r.Answer {
if mx, ok := a.(*RR_MX); ok {
if mx, ok := a.(*MX); ok {
fmt.Printf("%s\n", mx.String())
}
}
@ -44,7 +44,7 @@ func ExampleToDs(zone string) {
return
}
for _, k := range r.Answer {
if key, ok := k.(*RR_DNSKEY); ok {
if key, ok := k.(*DNSKEY); ok {
for _, alg := range []int{SHA1, SHA256, SHA384} {
fmt.Printf("%s; %d\n", key.ToDS(alg).String(), key.Flags)
}

View File

@ -22,7 +22,7 @@ type PrivateKey interface{}
// what kind of DNSKEY will be generated.
// The ECDSA algorithms imply a fixed keysize, in that case
// bits should be set to the size of the algorithm.
func (r *RR_DNSKEY) Generate(bits int) (PrivateKey, error) {
func (r *DNSKEY) Generate(bits int) (PrivateKey, error) {
switch r.Algorithm {
case DSA, DSANSEC3SHA1:
if bits != 1024 {
@ -90,7 +90,7 @@ func (r *RR_DNSKEY) Generate(bits int) (PrivateKey, error) {
// PrivateKeyString converts a PrivateKey to a string. This
// string has the same format as the private-key-file of BIND9 (Private-key-format: v1.3).
// It needs some info from the key (hashing, keytag), so its a method of the RR_DNSKEY.
func (r *RR_DNSKEY) PrivateKeyString(p PrivateKey) (s string) {
func (r *DNSKEY) PrivateKeyString(p PrivateKey) (s string) {
switch t := p.(type) {
case *rsa.PrivateKey:
algorithm := strconv.Itoa(int(r.Algorithm)) + " (" + AlgorithmToString[r.Algorithm] + ")"

View File

@ -9,7 +9,7 @@ import (
"strings"
)
func (k *RR_DNSKEY) NewPrivateKey(s string) (PrivateKey, error) {
func (k *DNSKEY) NewPrivateKey(s string) (PrivateKey, error) {
if s[len(s)-1] != '\n' { // We need a closing newline
return k.ReadPrivateKey(strings.NewReader(s+"\n"), "")
}
@ -20,7 +20,7 @@ func (k *RR_DNSKEY) NewPrivateKey(s string) (PrivateKey, error) {
// only used in error reporting.
// The public key must be
// known, because some cryptographics algorithms embed the public inside the privatekey.
func (k *RR_DNSKEY) ReadPrivateKey(q io.Reader, file string) (PrivateKey, error) {
func (k *DNSKEY) ReadPrivateKey(q io.Reader, file string) (PrivateKey, error) {
m, e := parseKey(q, file)
if m == nil {
return nil, e

2
msg.go
View File

@ -1094,7 +1094,7 @@ func UnpackRR(msg []byte, off int) (rr RR, off1 int, err error) {
// make an rr of that type and re-unpack.
mk, known := rr_mk[h.Rrtype]
if !known {
rr = new(RR_RFC3597)
rr = new(RFC3597)
} else {
rr = mk()
}

View File

@ -56,22 +56,22 @@ func HashName(label string, ha uint8, iter uint16, salt string) string {
}
// Implement the HashNames method of Denialer
func (rr *RR_NSEC3) HashNames(domain string) {
func (rr *NSEC3) HashNames(domain string) {
rr.Header().Name = strings.ToLower(HashName(rr.Header().Name, rr.Hash, rr.Iterations, rr.Salt)) + "." + domain
rr.NextDomain = HashName(rr.NextDomain, rr.Hash, rr.Iterations, rr.Salt)
}
// Implement the Match method of Denialer
func (rr *RR_NSEC3) Match(domain string) bool {
func (rr *NSEC3) Match(domain string) bool {
return strings.ToUpper(SplitLabels(rr.Header().Name)[0]) == strings.ToUpper(HashName(domain, rr.Hash, rr.Iterations, rr.Salt))
}
// Implement the Match method of Denialer
func (rr *RR_NSEC) Match(domain string) bool {
func (rr *NSEC) Match(domain string) bool {
return strings.ToUpper(rr.Header().Name) == strings.ToUpper(domain)
}
func (rr *RR_NSEC3) MatchType(rrtype uint16) bool {
func (rr *NSEC3) MatchType(rrtype uint16) bool {
for _, t := range rr.TypeBitMap {
if t == rrtype {
return true
@ -83,7 +83,7 @@ func (rr *RR_NSEC3) MatchType(rrtype uint16) bool {
return false
}
func (rr *RR_NSEC) MatchType(rrtype uint16) bool {
func (rr *NSEC) MatchType(rrtype uint16) bool {
for _, t := range rr.TypeBitMap {
if t == rrtype {
return true
@ -98,7 +98,7 @@ func (rr *RR_NSEC) MatchType(rrtype uint16) bool {
// Cover checks if domain is covered by the NSEC3 record. Domain must be given in plain text (i.e. not hashed)
// TODO(mg): this doesn't loop around
// TODO(mg): make a CoverHashed variant?
func (rr *RR_NSEC3) Cover(domain string) bool {
func (rr *NSEC3) Cover(domain string) bool {
hashdom := strings.ToUpper(HashName(domain, rr.Hash, rr.Iterations, rr.Salt))
nextdom := strings.ToUpper(rr.NextDomain)
owner := strings.ToUpper(SplitLabels(rr.Header().Name)[0]) // The hashed part
@ -116,6 +116,6 @@ func (rr *RR_NSEC3) Cover(domain string) bool {
}
// Cover checks if domain is covered by the NSEC record. Domain must be given in plain text.
func (rr *RR_NSEC) Cover(domain string) bool {
func (rr *NSEC) Cover(domain string) bool {
return false
}

View File

@ -29,7 +29,7 @@ Publish: 20110302104537
Activate: 20110302104537`
xk, _ := NewRR(pub)
k := xk.(*RR_DNSKEY)
k := xk.(*DNSKEY)
p, err := k.NewPrivateKey(priv)
if err != nil {
t.Logf("%v\n", err)
@ -51,7 +51,7 @@ Activate: 20110302104537`
t.Fail()
}
soa := new(RR_SOA)
soa := new(SOA)
soa.Hdr = RR_Header{"miek.nl.", TypeSOA, ClassINET, 14400, 0}
soa.Ns = "open.nlnetlabs.nl."
soa.Mbox = "miekg.atoom.net."
@ -61,7 +61,7 @@ Activate: 20110302104537`
soa.Expire = 604800
soa.Minttl = 86400
sig := new(RR_RRSIG)
sig := new(RRSIG)
sig.Hdr = RR_Header{"miek.nl.", TypeRRSIG, ClassINET, 14400, 0}
sig.Expiration = 1296534305 // date -u '+%s' -d"2011-02-01 04:25:05"
sig.Inception = 1293942305 // date -u '+%s' -d"2011-01-02 04:25:05"
@ -90,11 +90,11 @@ PrivateKey: WURgWHCcYIYUPWgeLmiPY2DJJk02vgrmTfitxgqcL4vwW7BOrbawVmVe0d9V94SR`
if err != nil {
t.Fatal(err.Error())
}
privkey, err := eckey.(*RR_DNSKEY).NewPrivateKey(priv)
privkey, err := eckey.(*DNSKEY).NewPrivateKey(priv)
if err != nil {
t.Fatal(err.Error())
}
ds := eckey.(*RR_DNSKEY).ToDS(SHA384)
ds := eckey.(*DNSKEY).ToDS(SHA384)
if ds.KeyTag != 10771 {
t.Fatal("Wrong keytag on DS")
}
@ -102,18 +102,18 @@ PrivateKey: WURgWHCcYIYUPWgeLmiPY2DJJk02vgrmTfitxgqcL4vwW7BOrbawVmVe0d9V94SR`
t.Fatal("Wrong DS Digest")
}
a, _ := NewRR("www.example.net. 3600 IN A 192.0.2.1")
sig := new(RR_RRSIG)
sig := new(RRSIG)
sig.Hdr = RR_Header{"example.net.", TypeRRSIG, ClassINET, 14400, 0}
sig.Expiration, _ = StringToTime("20100909102025")
sig.Inception, _ = StringToTime("20100812102025")
sig.KeyTag = eckey.(*RR_DNSKEY).KeyTag()
sig.SignerName = eckey.(*RR_DNSKEY).Hdr.Name
sig.Algorithm = eckey.(*RR_DNSKEY).Algorithm
sig.KeyTag = eckey.(*DNSKEY).KeyTag()
sig.SignerName = eckey.(*DNSKEY).Hdr.Name
sig.Algorithm = eckey.(*DNSKEY).Algorithm
sig.Sign(privkey, []RR{a})
t.Logf("%s", sig.String())
if e := sig.Verify(eckey.(*RR_DNSKEY), []RR{a}); e != nil {
if e := sig.Verify(eckey.(*DNSKEY), []RR{a}); e != nil {
t.Logf("Failure to validate: %s", e.Error())
t.Fail()
}
@ -622,7 +622,7 @@ func TestSRVPacking(t *testing.T) {
port = tmp
}
rr := &RR_SRV{
rr := &SRV{
Hdr: RR_Header{Name: "somename.",
Rrtype: TypeSRV,
Class: ClassINET,

View File

@ -116,7 +116,7 @@ func HandleAuthors(w ResponseWriter, r *Msg) {
m.SetReply(r)
for _, author := range Authors {
h := RR_Header{r.Question[0].Name, TypeTXT, ClassCHAOS, 0, 0}
m.Answer = append(m.Answer, &RR_TXT{h, []string{author}})
m.Answer = append(m.Answer, &TXT{h, []string{author}})
}
w.WriteMsg(m)
}
@ -147,7 +147,7 @@ func HandleVersion(w ResponseWriter, r *Msg) {
m := new(Msg)
m.SetReply(r)
h := RR_Header{r.Question[0].Name, TypeTXT, ClassCHAOS, 0, 0}
m.Answer = append(m.Answer, &RR_TXT{h, []string{Version}})
m.Answer = append(m.Answer, &TXT{h, []string{Version}})
w.WriteMsg(m)
}
@ -388,7 +388,7 @@ func serve(a net.Addr, h Handler, m []byte, u *net.UDPConn, t *net.TCPConn, tsig
}
w.tsigStatus = TsigVerify(m, tsigSecret[secret], "", false)
w.tsigTimersOnly = false
w.tsigRequestMAC = req.Extra[len(req.Extra)-1].(*RR_TSIG).MAC
w.tsigRequestMAC = req.Extra[len(req.Extra)-1].(*TSIG).MAC
}
}
h.ServeDNS(w, req) // this does the writing back to the client

View File

@ -10,7 +10,7 @@ func HelloServer(w ResponseWriter, req *Msg) {
m.SetReply(req)
m.Extra = make([]RR, 1)
m.Extra[0] = &RR_TXT{Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello world"}}
m.Extra[0] = &TXT{Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello world"}}
w.WriteMsg(m)
}
@ -19,7 +19,7 @@ func AnotherHelloServer(w ResponseWriter, req *Msg) {
m.SetReply(req)
m.Extra = make([]RR, 1)
m.Extra[0] = &RR_TXT{Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello example"}}
m.Extra[0] = &TXT{Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello example"}}
w.WriteMsg(m)
}
@ -39,14 +39,14 @@ func TestServing(t *testing.T) {
m.SetQuestion("miek.nl.", TypeTXT)
r, _, _ := c.Exchange(m, "127.0.0.1:8053")
txt := r.Extra[0].(*RR_TXT).Txt[0]
txt := r.Extra[0].(*TXT).Txt[0]
if txt != "Hello world" {
t.Log("Unexpected result for miek.nl", txt, "!= Hello world")
t.Fail()
}
m.SetQuestion("example.com.", TypeTXT)
r, _, _ = c.Exchange(m, "127.0.0.1:8053")
txt = r.Extra[0].(*RR_TXT).Txt[0]
txt = r.Extra[0].(*TXT).Txt[0]
if txt != "Hello example" {
t.Log("Unexpected result for example.com", txt, "!= Hello example")
t.Fail()

View File

@ -43,7 +43,7 @@ func CertificateToDANE(selector, matchingType uint8, cert *x509.Certificate) str
}
// Sign creates a TLSA record from an SSL certificate.
func (r *RR_TLSA) Sign(usage, selector, matchingType int, cert *x509.Certificate) error {
func (r *TLSA) Sign(usage, selector, matchingType int, cert *x509.Certificate) error {
r.Hdr.Rrtype = TypeTLSA
r.Usage = uint8(usage)
r.Selector = uint8(selector)
@ -55,7 +55,7 @@ func (r *RR_TLSA) Sign(usage, selector, matchingType int, cert *x509.Certificate
// Verify verifies a TLSA record against an SSL certificate. If it is OK
// a nil error is returned.
func (r *RR_TLSA) Verify(cert *x509.Certificate) error {
func (r *TLSA) Verify(cert *x509.Certificate) error {
if r.Certificate == CertificateToDANE(r.Selector, r.MatchingType, cert) {
return nil
}

24
tsig.go
View File

@ -73,7 +73,7 @@ const (
HmacSHA256 = "hmac-sha256."
)
type RR_TSIG struct {
type TSIG struct {
Hdr RR_Header
Algorithm string `dns:"domain-name"`
TimeSigned uint64 `dns:"uint48"`
@ -86,13 +86,13 @@ type RR_TSIG struct {
OtherData string `dns:"size-hex"`
}
func (rr *RR_TSIG) Header() *RR_Header {
func (rr *TSIG) Header() *RR_Header {
return &rr.Hdr
}
// TSIG has no official presentation format, but this will suffice.
func (rr *RR_TSIG) String() string {
func (rr *TSIG) String() string {
s := "\n;; TSIG PSEUDOSECTION:\n"
s += rr.Hdr.String() +
" " + rr.Algorithm +
@ -107,13 +107,13 @@ func (rr *RR_TSIG) String() string {
return s
}
func (rr *RR_TSIG) Len() int {
func (rr *TSIG) Len() int {
return rr.Hdr.Len() + len(rr.Algorithm) + 1 + 6 +
4 + len(rr.MAC)/2 + 1 + 6 + len(rr.OtherData)/2 + 1
}
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}
func (rr *TSIG) Copy() RR {
return &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.
@ -164,7 +164,7 @@ func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) ([]byte, s
return nil, "", err
}
rr := m.Extra[len(m.Extra)-1].(*RR_TSIG)
rr := m.Extra[len(m.Extra)-1].(*TSIG)
m.Extra = m.Extra[0 : len(m.Extra)-1] // kill the TSIG from the msg
mbuf, err := m.Pack()
if err != nil {
@ -172,7 +172,7 @@ func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) ([]byte, s
}
buf := tsigBuffer(mbuf, rr, requestMAC, timersOnly)
t := new(RR_TSIG)
t := new(TSIG)
var h hash.Hash
switch rr.Algorithm {
case HmacMD5:
@ -245,7 +245,7 @@ func TsigVerify(msg []byte, secret, requestMAC string, timersOnly bool) error {
}
// Create a wiredata buffer for the MAC calculation.
func tsigBuffer(msgbuf []byte, rr *RR_TSIG, requestMAC string, timersOnly bool) []byte {
func tsigBuffer(msgbuf []byte, rr *TSIG, requestMAC string, timersOnly bool) []byte {
var buf []byte
if rr.TimeSigned == 0 {
rr.TimeSigned = uint64(time.Now().Unix())
@ -295,13 +295,13 @@ func tsigBuffer(msgbuf []byte, rr *RR_TSIG, requestMAC string, timersOnly bool)
}
// Strip the TSIG from the raw message
func stripTsig(msg []byte) ([]byte, *RR_TSIG, error) {
func stripTsig(msg []byte) ([]byte, *TSIG, error) {
// Copied from msg.go's Unpack()
// Header.
var dh Header
var err error
dns := new(Msg)
rr := new(RR_TSIG)
rr := new(TSIG)
off := 0
tsigoff := 0
if off, err = UnpackStruct(&dh, msg, off); err != nil {
@ -346,7 +346,7 @@ func stripTsig(msg []byte) ([]byte, *RR_TSIG, error) {
return nil, nil, err
}
if dns.Extra[i].Header().Rrtype == TypeTSIG {
rr = dns.Extra[i].(*RR_TSIG)
rr = dns.Extra[i].(*TSIG)
// Adjust Arcount.
arcount, _ := unpackUint16(msg, 10)
msg[10], msg[11] = packUint16(arcount - 1)

660
types.go

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,7 @@ package dns
func (u *Msg) NameUsed(rr []RR) {
u.Answer = make([]RR, len(rr))
for i, r := range rr {
u.Answer[i] = &RR_ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}
u.Answer[i] = &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}
}
}
@ -49,7 +49,7 @@ func (u *Msg) NameUsed(rr []RR) {
func (u *Msg) NameNotUsed(rr []RR) {
u.Answer = make([]RR, len(rr))
for i, r := range rr {
u.Answer[i] = &RR_ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassNONE}}
u.Answer[i] = &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassNONE}}
}
}
@ -117,7 +117,7 @@ func (u *Msg) RemoveRRset(rr []RR) {
func (u *Msg) RemoveName(rr []RR) {
u.Ns = make([]RR, len(rr))
for i, r := range rr {
u.Ns[i] = &RR_ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}
u.Ns[i] = &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}
}
}

4
xfr.go
View File

@ -107,7 +107,7 @@ func (w *reply) ixfrIn(q *Msg, c chan *Envelope) {
return
}
// This serial is important
serial = in.Answer[0].(*RR_SOA).Serial
serial = in.Answer[0].(*SOA).Serial
first = !first
}
@ -115,7 +115,7 @@ func (w *reply) ixfrIn(q *Msg, c chan *Envelope) {
if !first {
w.tsigTimersOnly = true
// 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, ok := in.Answer[len(in.Answer)-1].(*SOA); ok {
if v.Serial == serial {
c <- &Envelope{in.Answer, nil}
return

42
zone.go
View File

@ -91,10 +91,10 @@ func NewZone(origin string) *Zone {
// ZoneData holds all the RRs having their owner name equal to Name.
type ZoneData struct {
Name string // Domain name for this node
RR map[uint16][]RR // Map of the RR type to the RR
Signatures map[uint16][]*RR_RRSIG // DNSSEC signatures for the RRs, stored under type covered
NonAuth bool // Always false, except for NSsets that differ from z.Origin
Name string // Domain name for this node
RR map[uint16][]RR // Map of the RR type to the RR
Signatures map[uint16][]*RRSIG // DNSSEC signatures for the RRs, stored under type covered
NonAuth bool // Always false, except for NSsets that differ from z.Origin
*sync.RWMutex
}
@ -103,7 +103,7 @@ func NewZoneData(s string) *ZoneData {
zd := new(ZoneData)
zd.Name = s
zd.RR = make(map[uint16][]RR)
zd.Signatures = make(map[uint16][]*RR_RRSIG)
zd.Signatures = make(map[uint16][]*RRSIG)
zd.RWMutex = new(sync.RWMutex)
return zd
}
@ -214,8 +214,8 @@ func (z *Zone) Insert(r RR) error {
zd := NewZoneData(r.Header().Name)
switch t := r.Header().Rrtype; t {
case TypeRRSIG:
sigtype := r.(*RR_RRSIG).TypeCovered
zd.Signatures[sigtype] = append(zd.Signatures[sigtype], r.(*RR_RRSIG))
sigtype := r.(*RRSIG).TypeCovered
zd.Signatures[sigtype] = append(zd.Signatures[sigtype], r.(*RRSIG))
case TypeNS:
// NS records with other names than z.Origin are non-auth
if r.Header().Name != z.Origin {
@ -234,8 +234,8 @@ func (z *Zone) Insert(r RR) error {
// Name already there
switch t := r.Header().Rrtype; t {
case TypeRRSIG:
sigtype := r.(*RR_RRSIG).TypeCovered
zd.Value.(*ZoneData).Signatures[sigtype] = append(zd.Value.(*ZoneData).Signatures[sigtype], r.(*RR_RRSIG))
sigtype := r.(*RRSIG).TypeCovered
zd.Value.(*ZoneData).Signatures[sigtype] = append(zd.Value.(*ZoneData).Signatures[sigtype], r.(*RRSIG))
case TypeNS:
if r.Header().Name != z.Origin {
zd.Value.(*ZoneData).NonAuth = true
@ -263,7 +263,7 @@ func (z *Zone) Remove(r RR) error {
remove := false
switch t := r.Header().Rrtype; t {
case TypeRRSIG:
sigtype := r.(*RR_RRSIG).TypeCovered
sigtype := r.(*RRSIG).TypeCovered
for i, zr := range zd.Value.(*ZoneData).Signatures[sigtype] {
if r == zr {
zd.Value.(*ZoneData).Signatures[sigtype] = append(zd.Value.(*ZoneData).Signatures[sigtype][:i], zd.Value.(*ZoneData).Signatures[sigtype][i+1:]...)
@ -420,14 +420,14 @@ func (z *Zone) isSubDomain(child string) bool {
//
// TODO(mg): resigning is not implemented
// TODO(mg): NSEC3 is not implemented
func (z *Zone) Sign(keys map[*RR_DNSKEY]PrivateKey, config *SignatureConfig) error {
func (z *Zone) Sign(keys map[*DNSKEY]PrivateKey, config *SignatureConfig) error {
z.Lock()
defer z.Unlock()
if config == nil {
config = DefaultSignatureConfig
}
// Pre-calc the key tag
keytags := make(map[*RR_DNSKEY]uint16)
keytags := make(map[*DNSKEY]uint16)
for k := range keys {
keytags[k] = k.KeyTag()
}
@ -446,7 +446,7 @@ func (z *Zone) Sign(keys map[*RR_DNSKEY]PrivateKey, config *SignatureConfig) err
if !e {
return ErrSoa
}
config.Minttl = apex.Value.(*ZoneData).RR[TypeSOA][0].(*RR_SOA).Minttl
config.Minttl = apex.Value.(*ZoneData).RR[TypeSOA][0].(*SOA).Minttl
next := apex.Next()
radChan <- apex
@ -471,7 +471,7 @@ Sign:
}
// signerRoutine is a small helper routine to make the concurrent signing work.
func signerRoutine(wg *sync.WaitGroup, keys map[*RR_DNSKEY]PrivateKey, keytags map[*RR_DNSKEY]uint16, config *SignatureConfig, in chan *radix.Radix, err chan error) {
func signerRoutine(wg *sync.WaitGroup, keys map[*DNSKEY]PrivateKey, keytags map[*DNSKEY]uint16, config *SignatureConfig, in chan *radix.Radix, err chan error) {
defer wg.Done()
for {
select {
@ -494,11 +494,11 @@ func signerRoutine(wg *sync.WaitGroup, keys map[*RR_DNSKEY]PrivateKey, keytags m
// For a more complete description see zone.Sign.
// Note: as this method has no (direct)
// access to the zone's SOA record, the SOA's Minttl value should be set in *config.
func (node *ZoneData) Sign(next *ZoneData, keys map[*RR_DNSKEY]PrivateKey, keytags map[*RR_DNSKEY]uint16, config *SignatureConfig) error {
func (node *ZoneData) Sign(next *ZoneData, keys map[*DNSKEY]PrivateKey, keytags map[*DNSKEY]uint16, config *SignatureConfig) error {
node.Lock()
defer node.Unlock()
nsec := new(RR_NSEC)
nsec := new(NSEC)
nsec.Hdr.Rrtype = TypeNSEC
nsec.Hdr.Ttl = config.Minttl // SOA's minimum value
nsec.Hdr.Name = node.Name
@ -522,7 +522,7 @@ func (node *ZoneData) Sign(next *ZoneData, keys map[*RR_DNSKEY]PrivateKey, keyta
}
// which sigs to check??
s := new(RR_RRSIG)
s := new(RRSIG)
s.SignerName = k.Hdr.Name
s.Hdr.Ttl = k.Hdr.Ttl
s.Algorithm = k.Algorithm
@ -536,7 +536,7 @@ func (node *ZoneData) Sign(next *ZoneData, keys map[*RR_DNSKEY]PrivateKey, keyta
node.Signatures[TypeNSEC] = append(node.Signatures[TypeNSEC], s)
// DS
if ds, ok := node.RR[TypeDS]; ok {
s := new(RR_RRSIG)
s := new(RRSIG)
s.SignerName = k.Hdr.Name
s.Hdr.Ttl = k.Hdr.Ttl
s.Algorithm = k.Algorithm
@ -556,13 +556,13 @@ func (node *ZoneData) Sign(next *ZoneData, keys map[*RR_DNSKEY]PrivateKey, keyta
for k, p := range keys {
for t, rrset := range node.RR {
if k.Flags&SEP == SEP {
if _, ok := rrset[0].(*RR_DNSKEY); !ok {
if _, ok := rrset[0].(*DNSKEY); !ok {
// only sign keys with SEP keys
continue
}
}
s := new(RR_RRSIG)
s := new(RRSIG)
s.SignerName = k.Hdr.Name
s.Hdr.Ttl = k.Hdr.Ttl
s.Hdr.Class = ClassINET
@ -582,7 +582,7 @@ func (node *ZoneData) Sign(next *ZoneData, keys map[*RR_DNSKEY]PrivateKey, keyta
sort.Sort(uint16Slice(nsec.TypeBitMap))
node.RR[TypeNSEC] = []RR{nsec}
// NSEC
s := new(RR_RRSIG)
s := new(RRSIG)
s.SignerName = k.Hdr.Name
s.Hdr.Ttl = k.Hdr.Ttl
s.Algorithm = k.Algorithm

View File

@ -42,7 +42,7 @@ func TestApex(t *testing.T) {
t.Fatalf("Apex not found")
}
t.Logf("Apex found %s", apex.RR[TypeSOA][0].String())
apex.RR[TypeSOA][0].(*RR_SOA).Serial++
apex.RR[TypeSOA][0].(*SOA).Serial++
apex = z.Apex()
t.Logf("Apex found %s", z.Apex().RR[TypeSOA][0].String())
}

View File

@ -211,7 +211,7 @@ func endingToTxtSlice(c chan lex, errstr, f string) ([]string, *ParseError) {
}
func setA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_A)
rr := new(A)
rr.Hdr = h
l := <-c
@ -223,7 +223,7 @@ func setA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setAAAA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_AAAA)
rr := new(AAAA)
rr.Hdr = h
l := <-c
@ -235,7 +235,7 @@ func setAAAA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setNS(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_NS)
rr := new(NS)
rr.Hdr = h
l := <-c
@ -255,7 +255,7 @@ func setNS(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_PTR)
rr := new(PTR)
rr.Hdr = h
l := <-c
@ -275,7 +275,7 @@ func setPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setRP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_RP)
rr := new(RP)
rr.Hdr = h
l := <-c
@ -310,7 +310,7 @@ func setRP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setMR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_MR)
rr := new(MR)
rr.Hdr = h
l := <-c
@ -330,7 +330,7 @@ func setMR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setMB(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_MB)
rr := new(MB)
rr.Hdr = h
l := <-c
@ -350,7 +350,7 @@ func setMB(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setMG(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_MG)
rr := new(MG)
rr.Hdr = h
l := <-c
@ -370,7 +370,7 @@ func setMG(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setHINFO(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_HINFO)
rr := new(HINFO)
rr.Hdr = h
l := <-c
@ -383,7 +383,7 @@ func setHINFO(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setMINFO(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_MINFO)
rr := new(MINFO)
rr.Hdr = h
l := <-c
@ -416,7 +416,7 @@ func setMINFO(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setMF(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_MF)
rr := new(MF)
rr.Hdr = h
l := <-c
@ -436,7 +436,7 @@ func setMF(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setMD(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_MD)
rr := new(MD)
rr.Hdr = h
l := <-c
@ -456,7 +456,7 @@ func setMD(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setMX(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_MX)
rr := new(MX)
rr.Hdr = h
l := <-c
@ -483,7 +483,7 @@ func setMX(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setRT(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_RT)
rr := new(RT)
rr.Hdr = h
l := <-c
@ -510,7 +510,7 @@ func setRT(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setAFSDB(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_AFSDB)
rr := new(AFSDB)
rr.Hdr = h
l := <-c
@ -537,7 +537,7 @@ func setAFSDB(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setX25(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_X25)
rr := new(X25)
rr.Hdr = h
l := <-c
@ -546,7 +546,7 @@ func setX25(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setKX(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_KX)
rr := new(KX)
rr.Hdr = h
l := <-c
@ -573,7 +573,7 @@ func setKX(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setCNAME(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_CNAME)
rr := new(CNAME)
rr.Hdr = h
l := <-c
@ -593,7 +593,7 @@ func setCNAME(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setDNAME(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_DNAME)
rr := new(DNAME)
rr.Hdr = h
l := <-c
@ -613,7 +613,7 @@ func setDNAME(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setSOA(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_SOA)
rr := new(SOA)
rr.Hdr = h
l := <-c
@ -685,7 +685,7 @@ func setSOA(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setSRV(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_SRV)
rr := new(SRV)
rr.Hdr = h
l := <-c
@ -726,7 +726,7 @@ func setSRV(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setNAPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_NAPTR)
rr := new(NAPTR)
rr.Hdr = h
l := <-c
@ -817,7 +817,7 @@ func setNAPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setTALINK(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_TALINK)
rr := new(TALINK)
rr.Hdr = h
l := <-c
@ -851,7 +851,7 @@ func setTALINK(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setLOC(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_LOC)
rr := new(LOC)
rr.Hdr = h
// Non zero defaults for LOC record, see RFC 1876, Section 3.
rr.HorizPre = 165 // 10000
@ -978,7 +978,7 @@ Altitude:
}
func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_HIP)
rr := new(HIP)
rr.Hdr = h
// HitLength is not represented
@ -1028,7 +1028,7 @@ func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setCERT(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_CERT)
rr := new(CERT)
rr.Hdr = h
l := <-c
@ -1060,7 +1060,7 @@ func setCERT(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setRRSIG(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_RRSIG)
rr := new(RRSIG)
rr.Hdr = h
l := <-c
if t, ok := StringToType[strings.ToUpper(l.token)]; !ok {
@ -1133,7 +1133,7 @@ func setRRSIG(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setNSEC(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_NSEC)
rr := new(NSEC)
rr.Hdr = h
l := <-c
@ -1176,7 +1176,7 @@ func setNSEC(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setNSEC3(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_NSEC3)
rr := new(NSEC3)
rr.Hdr = h
l := <-c
@ -1238,7 +1238,7 @@ func setNSEC3(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setNSEC3PARAM(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_NSEC3PARAM)
rr := new(NSEC3PARAM)
rr.Hdr = h
l := <-c
@ -1269,7 +1269,7 @@ func setNSEC3PARAM(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setWKS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_WKS)
rr := new(WKS)
rr.Hdr = h
l := <-c
@ -1324,7 +1324,7 @@ func setWKS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setSSHFP(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_SSHFP)
rr := new(SSHFP)
rr.Hdr = h
l := <-c
@ -1347,7 +1347,7 @@ func setSSHFP(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setDNSKEY(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_DNSKEY)
rr := new(DNSKEY)
rr.Hdr = h
l := <-c
@ -1379,7 +1379,7 @@ func setDNSKEY(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setRKEY(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_RKEY)
rr := new(RKEY)
rr.Hdr = h
l := <-c
@ -1411,7 +1411,7 @@ func setRKEY(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setDS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_DS)
rr := new(DS)
rr.Hdr = h
l := <-c
if i, e := strconv.Atoi(l.token); e != nil {
@ -1446,7 +1446,7 @@ func setDS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setCDS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_CDS)
rr := new(CDS)
rr.Hdr = h
l := <-c
if i, e := strconv.Atoi(l.token); e != nil {
@ -1481,7 +1481,7 @@ func setCDS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setDLV(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_DLV)
rr := new(DLV)
rr.Hdr = h
l := <-c
if i, e := strconv.Atoi(l.token); e != nil {
@ -1516,7 +1516,7 @@ func setDLV(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setTA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_TA)
rr := new(TA)
rr.Hdr = h
l := <-c
if i, e := strconv.Atoi(l.token); e != nil {
@ -1551,7 +1551,7 @@ func setTA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setTLSA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_TLSA)
rr := new(TLSA)
rr.Hdr = h
l := <-c
if i, e := strconv.Atoi(l.token); e != nil {
@ -1582,7 +1582,7 @@ func setTLSA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setRFC3597(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_RFC3597)
rr := new(RFC3597)
rr.Hdr = h
l := <-c
if l.token != "\\#" {
@ -1607,7 +1607,7 @@ func setRFC3597(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setSPF(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_SPF)
rr := new(SPF)
rr.Hdr = h
s, e := endingToTxtSlice(c, "bad SPF Txt", f)
@ -1619,7 +1619,7 @@ func setSPF(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setTXT(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_TXT)
rr := new(TXT)
rr.Hdr = h
s, e := endingToTxtSlice(c, "bad TXT Txt", f)
@ -1632,7 +1632,7 @@ func setTXT(h RR_Header, c chan lex, f string) (RR, *ParseError) {
// identical to setTXT
func setNINFO(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_NINFO)
rr := new(NINFO)
rr.Hdr = h
s, e := endingToTxtSlice(c, "bad NINFO ZSData", f)
@ -1644,7 +1644,7 @@ func setNINFO(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setURI(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_URI)
rr := new(URI)
rr.Hdr = h
l := <-c
@ -1695,7 +1695,7 @@ func setURI(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setIPSECKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_IPSECKEY)
rr := new(IPSECKEY)
rr.Hdr = h
l := <-c
@ -1731,7 +1731,7 @@ func setIPSECKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
func setDHCID(h RR_Header, c chan lex, f string) (RR, *ParseError) {
// awesome record to parse!
rr := new(RR_DHCID)
rr := new(DHCID)
rr.Hdr = h
s, e := endingToString(c, "bad DHCID Digest", f)
@ -1743,7 +1743,7 @@ func setDHCID(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setNID(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_NID)
rr := new(NID)
rr.Hdr = h
l := <-c
@ -1763,7 +1763,7 @@ func setNID(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setL32(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_L32)
rr := new(L32)
rr.Hdr = h
l := <-c
@ -1782,7 +1782,7 @@ func setL32(h RR_Header, c chan lex, f string) (RR, *ParseError) {
}
func setLP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_LP)
rr := new(LP)
rr.Hdr = h
l := <-c
@ -1809,7 +1809,7 @@ func setLP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
func setL64(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_L64)
rr := new(L64)
rr.Hdr = h
l := <-c