judge if interface is up

pull/256/head
wuxingzhong 5 years ago
parent d2274d9b06
commit 8b1e2ba0fa
  1. 8
      pkg/net/ip/ip.go

@ -48,6 +48,9 @@ func InternalIP() string {
return ""
}
for _, inter := range inters {
if !isUp(inter.Flags) {
continue
}
if !strings.HasPrefix(inter.Name, "lo") {
addrs, err := inter.Addrs()
if err != nil {
@ -64,3 +67,8 @@ func InternalIP() string {
}
return ""
}
// isUp Interface is up
func isUp(v net.Flags) bool {
return v&net.FlagUp == net.FlagUp
}

Loading…
Cancel
Save