Print unknown record type with CLASSX and TYPEX
When printing unknown records it is best to print the entire thing as unknown, instead of relying on the internal defined type. An example A record, printed as an unknown one: miek.nl. 3600 CLASS1 TYPE1 \# 4 0a000101
This commit is contained in:
parent
6bbae6c6ea
commit
a945149fab
|
@ -430,7 +430,7 @@ func TestToRFC3597(t *testing.T) {
|
|||
a, _ := NewRR("miek.nl. IN A 10.0.1.1")
|
||||
x := new(RFC3597)
|
||||
x.ToRFC3597(a)
|
||||
if x.String() != `miek.nl. 3600 IN A \# 4 0a000101` {
|
||||
if x.String() != `miek.nl. 3600 CLASS1 TYPE1 \# 4 0a000101` {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
|
14
types.go
14
types.go
|
@ -1245,11 +1245,23 @@ func (rr *RFC3597) copy() RR { return &RFC3597{*rr.Hdr.copyHeader(), r
|
|||
func (rr *RFC3597) len() int { return rr.Hdr.len() + len(rr.Rdata)/2 + 2 }
|
||||
|
||||
func (rr *RFC3597) String() string {
|
||||
s := rr.Hdr.String()
|
||||
// Let's call it a hack
|
||||
s := rfc3597Header(rr.Hdr)
|
||||
|
||||
s += "\\# " + strconv.Itoa(len(rr.Rdata)/2) + " " + rr.Rdata
|
||||
return s
|
||||
}
|
||||
|
||||
func rfc3597Header(h RR_Header) string {
|
||||
var s string
|
||||
|
||||
s += sprintName(h.Name) + "\t"
|
||||
s += strconv.FormatInt(int64(h.Ttl), 10) + "\t"
|
||||
s += "CLASS" + strconv.Itoa(int(h.Class)) + "\t"
|
||||
s += "TYPE" + strconv.Itoa(int(h.Rrtype)) + "\t"
|
||||
return s
|
||||
}
|
||||
|
||||
type URI struct {
|
||||
Hdr RR_Header
|
||||
Priority uint16
|
||||
|
|
Loading…
Reference in New Issue