mirror of
https://github.com/ergochat/ergo.git
synced 2025-01-03 16:42:38 +01:00
net: Prepend IPv6 addresses with '0' if necessary
This commit is contained in:
parent
a8d910e233
commit
859d0cd607
@ -28,7 +28,11 @@ func AddrLookupHostname(addr net.Addr) string {
|
|||||||
func LookupHostname(addr string) string {
|
func LookupHostname(addr string) string {
|
||||||
names, err := net.LookupAddr(addr)
|
names, err := net.LookupAddr(addr)
|
||||||
if err != nil || len(names) < 1 || !IsHostname(names[0]) {
|
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
|
return addr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user