Show ip6 address with [ and ]

This commit is contained in:
Miek Gieben 2012-05-31 23:02:06 +02:00
parent c326309d62
commit 77709d301c
1 changed files with 8 additions and 4 deletions

12
edns.go
View File

@ -221,8 +221,12 @@ func (e *EDNS0_SUBNET) Unpack(b []byte) {
return return
} }
func (e *EDNS0_SUBNET) String() string { func (e *EDNS0_SUBNET) String() (s string) {
return e.Address.String() + "/" + if e.Address.To4() != nil {
strconv.Itoa(int(e.SourceNetmask)) + "/" + s = e.Address.String()
strconv.Itoa(int(e.SourceScope)) } else {
s = "[" + e.Address.String() + "]"
}
s += "/" + strconv.Itoa(int(e.SourceNetmask)) + "/" + strconv.Itoa(int(e.SourceScope))
return
} }