Add rrset check function

This commit is contained in:
Miek Gieben 2011-01-16 20:07:17 +01:00
parent 79f61af370
commit d086722c36
4 changed files with 19 additions and 10 deletions

4
TODO
View File

@ -2,6 +2,9 @@ Todo:
* NSEC3 - need base32 for Nsec3
* Cleanup the code
* Tsig testing
* Private key file parsing, exponent 65536 does not work
Longer term:
* Parsing from strings, going with goyacc and own lexer
Issues:
@ -17,4 +20,5 @@ Issues:
- printing??
* query-time, server in string ouput of resolver.Msg
- resolver.Msg when doing resolver querying, extend msg...?
- also for the server?
* Fix remaining records: LOC, NAPTR, ..., ...

16
dns.go
View File

@ -59,6 +59,19 @@ func (r RRset) Len() int { return len(r) }
func (r RRset) Less(i, j int) bool { return r[i].Header().Name < r[j].Header().Name }
func (r RRset) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
// Check if the RRset is 2181 compliant
func (r RRset) Ok() bool {
ttl := r[0].Header().Ttl
name := r[0].Header().Name
class := r[0].Header().Class
for _, rr := range r[1:] {
if rr.Header().Ttl != ttl { return false }
if rr.Header().Name != name { return false }
if rr.Header().Class != class { return false }
}
return true
}
// DNS resource records.
// There are many types of messages,
// but they all share the same header.
@ -93,8 +106,7 @@ func (h *RR_Header) String() string {
return s
}
// Return number of labels in a domain name
// Make it fqdn?
// Return the number of labels in a domain name
func LabelCount(a string) (c uint8) {
for _, v := range a {
if v == '.' {

View File

@ -395,6 +395,7 @@ func (s *RR_RRSIG) Verify(k *RR_DNSKEY, rrset RRset) bool {
return err == nil
}
// Beter name for this function
// Using RFC1982 calculate if a signature period is valid
func (s *RR_RRSIG) PeriodOK() bool {
utc := time.UTC().Seconds()

View File

@ -71,11 +71,3 @@ func SecondsToString(val uint32) (str string) {
}
return
}
// Read a string and convert it to the correct
// Resource Record.
func SetString(s string) RR {
k := new(RR_DNSKEY)
return k
}