LabelCount() made public and various other tweaks

This commit is contained in:
Miek Gieben 2011-01-14 18:55:18 +01:00
parent 79b926d862
commit 15bf984f3f
4 changed files with 4 additions and 6 deletions

5
dns.go
View File

@ -93,8 +93,9 @@ func (h *RR_Header) String() string {
return s
}
// Return number of labels in a dname
func labelCount(a string) (c int) {
// Return number of labels in a domain name
// Make it fqdn?
func LabelCount(a string) (c uint8) {
for _, v := range a {
if v == '.' {
c++

View File

@ -2,7 +2,6 @@ package dns
import (
"testing"
"fmt"
)
@ -16,7 +15,6 @@ func TestKeyGen(t *testing.T) {
key.Protocol = 3
key.Algorithm = AlgRSASHA256
key.Generate(512)
fmt.Printf("Generated key: %v\n", key)
}

View File

@ -170,7 +170,7 @@ func (s *RR_RRSIG) Sign(k PrivateKey, rrset RRset) bool {
s.SignerName = k.Hdr.Name
s.Algorithm = ??
*/
s.Labels = uint8(labelCount(rrset[0].Header().Name))
s.Labels = LabelCount(rrset[0].Header().Name)
s.TypeCovered = rrset[0].Header().Rrtype
sigwire := new(rrsigWireFmt)

View File

@ -23,7 +23,6 @@ func TestSecure(t *testing.T) {
sig.TypeCovered = TypeSOA
sig.Algorithm = AlgRSASHA256
sig.Labels = 2
// UTC LUL!
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"
sig.OrigTtl = 14400