fix getting server IP

This commit is contained in:
Hossin Asaadi
2022-11-05 10:19:18 -04:00
parent 44ca9cc841
commit 675c211dcd

View File

@@ -277,9 +277,8 @@ func LocalIP() ([]string, error) {
ip = v.IP
}
if isPrivateIP(ip) {
ips = append(ips,ip.String())
}
ips = append(ips,ip.String())
}
}
logger.Debug("System IPs : ",ips)
@@ -287,29 +286,6 @@ func LocalIP() ([]string, error) {
return ips, nil
}
func isPrivateIP(ip net.IP) bool {
var privateIPBlocks []*net.IPNet
for _, cidr := range []string{
// don't check loopback ips
//"127.0.0.0/8", // IPv4 loopback
//"::1/128", // IPv6 loopback
//"fe80::/10", // IPv6 link-local
"10.0.0.0/8", // RFC1918
"172.16.0.0/12", // RFC1918
"192.168.0.0/16", // RFC1918
} {
_, block, _ := net.ParseCIDR(cidr)
privateIPBlocks = append(privateIPBlocks, block)
}
for _, block := range privateIPBlocks {
if block.Contains(ip) {
return true
}
}
return false
}
func IPsToRegex(ips []string) (string){