Fix very large SOA/TTL values

This commit is contained in:
Miek Gieben 2012-02-19 18:36:59 +01:00
parent 3f5f2ed026
commit 9c5c2ee96f
3 changed files with 19 additions and 11 deletions

10
dns.go
View File

@ -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"

View File

@ -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())
}
}

View File

@ -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)) +