fix ipv6 addr parsing and using

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2019-07-17 10:38:50 +03:00
parent d4fefc4b76
commit e688ab0a45
8 changed files with 104 additions and 68 deletions

View File

@@ -30,7 +30,7 @@ func isPrivateIP(ipAddr string) bool {
// Extract returns a real ip
func Extract(addr string) (string, error) {
// if addr specified then its returned
if len(addr) > 0 && (addr != "0.0.0.0" && addr != "[::]") {
if len(addr) > 0 && (addr != "0.0.0.0" && addr != "[::]" && addr != "::") {
return addr, nil
}
@@ -113,10 +113,13 @@ func IPs() []string {
continue
}
ip = ip.To4()
if ip == nil {
continue
}
// dont skip ipv6 addrs
/*
ip = ip.To4()
if ip == nil {
continue
}
*/
ipAddrs = append(ipAddrs, ip.String())
}