3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

net: Prepend IPv6 addresses with '0' if necessary

This commit is contained in:
Daniel Oaks 2016-10-16 14:17:29 +10:00
parent a8d910e233
commit 859d0cd607

View File

@ -28,7 +28,11 @@ func AddrLookupHostname(addr net.Addr) string {
func LookupHostname(addr string) string {
names, err := net.LookupAddr(addr)
if err != nil || len(names) < 1 || !IsHostname(names[0]) {
// return original address
// return original address if no hostname found
if len(addr) > 0 && addr[0] == ':' {
// fix for IPv6 hostnames (so they don't start with a colon), same as all other IRCds
addr = "0" + addr
}
return addr
}