Fix the inception printing

Still need to add serial arithmetic to the calculations
This commit is contained in:
Miek Gieben 2010-12-20 22:44:50 +01:00
parent 0ed946d772
commit 392f418a0e
2 changed files with 34 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package dns
import ( import (
"testing" "testing"
"time" "time"
"fmt"
) )
@ -27,6 +28,20 @@ func TestResolver(t *testing.T) {
t.Log("Failed to get an valid answer") t.Log("Failed to get an valid answer")
t.Fail() t.Fail()
} }
fmt.Printf("%v\n", in)
// ask something
m.Question[0] = Question{"www.nlnetlabs.nl", TypeRRSIG, ClassINET}
ch <- DnsMsg{m, nil}
in = <-ch
if in.Dns.Rcode != RcodeSuccess {
t.Log("Failed to get an valid answer")
t.Fail()
}
fmt.Printf("%v\n", in)
ch <- DnsMsg{nil, nil} ch <- DnsMsg{nil, nil}
time.Sleep(1.0e9) time.Sleep(1.0e9)
} }

View File

@ -10,6 +10,7 @@ package dns
import ( import (
"net" "net"
"strconv" "strconv"
"time"
) )
// Packet formats // Packet formats
@ -379,14 +380,30 @@ type RR_RRSIG struct {
func (rr *RR_RRSIG) Header() *RR_Header { func (rr *RR_RRSIG) Header() *RR_Header {
return &rr.Hdr return &rr.Hdr
} }
// Also, I might need more of these helper function
// where to put them if there are more
// Define a new interface??
// needs serial stuff
// starts when 1970 has been 68 years ago??
func intToDate(t uint32) string {
// als meer dan 68 jaar geleden, dan 68 jaar bij bedrag optellen
// TODO
ti := time.SecondsToUTC(int64(t))
return ti.Format("20060102030405")
}
func (rr *RR_RRSIG) String() string { func (rr *RR_RRSIG) String() string {
return rr.Hdr.String() + return rr.Hdr.String() +
" " + rr_str[rr.TypeCovered] + " " + rr_str[rr.TypeCovered] +
" " + strconv.Itoa(int(rr.Algorithm)) + " " + strconv.Itoa(int(rr.Algorithm)) +
" " + strconv.Itoa(int(rr.Labels)) + " " + strconv.Itoa(int(rr.Labels)) +
" " + strconv.Itoa(int(rr.OrigTtl)) + " " + strconv.Itoa(int(rr.OrigTtl)) +
" " + strconv.Itoa(int(rr.Expiration)) + // date calc! TODO // " " + strconv.Itoa(int(rr.Expiration)) + // date calc! TODO
" " + strconv.Itoa(int(rr.Inception)) + // date calc! TODO " " + intToDate(rr.Expiration) +
// " " + strconv.Itoa(int(rr.Inception)) + // date calc! TODO
" " + intToDate(rr.Inception) +
" " + strconv.Itoa(int(rr.KeyTag)) + " " + strconv.Itoa(int(rr.KeyTag)) +
" " + rr.SignerName + " " + rr.SignerName +
" " + rr.Sig " " + rr.Sig