diff --git a/dns.go b/dns.go index 596dc4eb..e0a3ee28 100644 --- a/dns.go +++ b/dns.go @@ -105,12 +105,12 @@ func (e *Error) Error() string { // An RR represents a resource record. type RR interface { - // Header returns the header of an resource record. The header contains - // everything up to the rdata. + // Header returns the header of an resource record. The header contains + // everything up to the rdata. Header() *RR_Header - // String returns the text representation of the resource record. + // String returns the text representation of the resource record. String() string - // Len returns the length (in octects) of the uncompressed RR in wire format. + // Len returns the length (in octects) of the uncompressed RR in wire format. Len() int } @@ -149,7 +149,7 @@ func (h *RR_Header) String() string { } else { s += h.Name + "\t" } - s = s + strconv.Itoa(int(h.Ttl)) + "\t" + s = s + strconv.FormatInt(int64(h.Ttl), 10) + "\t" if _, ok := Class_str[h.Class]; ok { s += Class_str[h.Class] + "\t" diff --git a/parse_test.go b/parse_test.go index 1c965302..8dec4641 100644 --- a/parse_test.go +++ b/parse_test.go @@ -421,3 +421,11 @@ b1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D fmt.Printf("%s\n", hip.String()) } } + +// example.com. 1000 IN SOA master.example.com. admin.example.com. 1 4294967294 4294967293 4294967295 100 +func ExampleSOA() { + s := "example.com. 1000 SOA master.example.com. admin.example.com. 1 4294967294 4294967293 4294967295 100" + if soa, err := NewRR(s); err == nil { + fmt.Printf("%s\n", soa.String()) + } +} diff --git a/types.go b/types.go index 25b10865..3616cbe5 100644 --- a/types.go +++ b/types.go @@ -359,11 +359,11 @@ func (rr *RR_SOA) Header() *RR_Header { func (rr *RR_SOA) String() string { return rr.Hdr.String() + rr.Ns + " " + rr.Mbox + - " " + strconv.Itoa(int(rr.Serial)) + - " " + strconv.Itoa(int(rr.Refresh)) + - " " + strconv.Itoa(int(rr.Retry)) + - " " + strconv.Itoa(int(rr.Expire)) + - " " + strconv.Itoa(int(rr.Minttl)) + " " + strconv.FormatInt(int64(rr.Serial), 10) + + " " + strconv.FormatInt(int64(rr.Refresh), 10) + + " " + strconv.FormatInt(int64(rr.Retry), 10) + + " " + strconv.FormatInt(int64(rr.Expire), 10) + + " " + strconv.FormatInt(int64(rr.Minttl), 10) } func (rr *RR_SOA) Len() int { @@ -605,7 +605,7 @@ 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.FormatInt(int64(rr.OrigTtl), 10) + " " + timeToDate(rr.Expiration) + " " + timeToDate(rr.Inception) + " " + strconv.Itoa(int(rr.KeyTag)) +