[agent-go] [status] network interface analyze to cidr
This commit is contained in:
@@ -39,7 +39,7 @@ func GetNetworkInfo() (*NetworkInfo, error) {
|
||||
allAddrs = append(allAddrs, addr.Addr)
|
||||
}
|
||||
ipv4List, ipv6List := GetInternelIpAddrs(allAddrs)
|
||||
log.DebugF("ipv4 list are => %v, ipv4 list are => %v", ipv4List, ipv6List)
|
||||
log.DebugF("ipv4 list are => %v, ipv6 list are => %v", ipv4List, ipv6List)
|
||||
|
||||
counters, err := net.IOCounters(true)
|
||||
if err != nil {
|
||||
@@ -103,7 +103,11 @@ func GetInternelIpAddrs(addresses []string) ([]string, []string) {
|
||||
var ipv4 []string
|
||||
var ipv6 []string
|
||||
for _, addr := range addresses {
|
||||
ip := net2.ParseIP(addr)
|
||||
// it parse (0.0.0.0) not cidr
|
||||
ip, _, err := net2.ParseCIDR(addr)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if ip.To4() != nil {
|
||||
ipv4 = append(ipv4, addr)
|
||||
} else if ip.To16() != nil {
|
||||
|
||||
Reference in New Issue
Block a user