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
}
func (e *EDNS0_SUBNET) String() string {
return e.Address.String() + "/" +
strconv.Itoa(int(e.SourceNetmask)) + "/" +
strconv.Itoa(int(e.SourceScope))
func (e *EDNS0_SUBNET) String() (s string) {
if e.Address.To4() != nil {
s = e.Address.String()
} else {
s = "[" + e.Address.String() + "]"
}
s += "/" + strconv.Itoa(int(e.SourceNetmask)) + "/" + strconv.Itoa(int(e.SourceScope))
return
}