From 392f418a0e42bd066a24ee0bce8dce1492c5454d Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Mon, 20 Dec 2010 22:44:50 +0100 Subject: [PATCH] Fix the inception printing Still need to add serial arithmetic to the calculations --- resolver_test.go | 15 +++++++++++++++ types.go | 21 +++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/resolver_test.go b/resolver_test.go index af4f877b..1133fd54 100644 --- a/resolver_test.go +++ b/resolver_test.go @@ -3,6 +3,7 @@ package dns import ( "testing" "time" + "fmt" ) @@ -27,6 +28,20 @@ func TestResolver(t *testing.T) { t.Log("Failed to get an valid answer") 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} time.Sleep(1.0e9) } diff --git a/types.go b/types.go index 496bc797..55d568d8 100644 --- a/types.go +++ b/types.go @@ -10,6 +10,7 @@ package dns import ( "net" "strconv" + "time" ) // Packet formats @@ -379,14 +380,30 @@ type RR_RRSIG struct { func (rr *RR_RRSIG) Header() *RR_Header { 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 { return rr.Hdr.String() + " " + rr_str[rr.TypeCovered] + " " + strconv.Itoa(int(rr.Algorithm)) + " " + strconv.Itoa(int(rr.Labels)) + " " + strconv.Itoa(int(rr.OrigTtl)) + - " " + strconv.Itoa(int(rr.Expiration)) + // date calc! TODO - " " + strconv.Itoa(int(rr.Inception)) + // date calc! TODO +// " " + strconv.Itoa(int(rr.Expiration)) + // date calc! TODO + " " + intToDate(rr.Expiration) + +// " " + strconv.Itoa(int(rr.Inception)) + // date calc! TODO + " " + intToDate(rr.Inception) + " " + strconv.Itoa(int(rr.KeyTag)) + " " + rr.SignerName + " " + rr.Sig