Skip to content
Snippets Groups Projects
Commit 2cfdce38 authored by Ian Luo's avatar Ian Luo
Browse files

introduce isValidNetworkInterface

parent af24895a
No related branches found
No related tags found
No related merge requests found
......@@ -47,17 +47,7 @@ func GetLocalIP() (string, error) {
var addr net.IP
for _, face := range faces {
if face.Flags&net.FlagUp == 0 {
// interface down
continue
}
if face.Flags&net.FlagLoopback != 0 {
// loopback interface
continue
}
if strings.Contains(strings.ToLower(face.Name), "docker") {
if !isValidNetworkInterface(face) {
continue
}
......@@ -115,3 +105,21 @@ func getValidIPv4(addrs []net.Addr) (net.IP, bool) {
}
return nil, false
}
func isValidNetworkInterface(face net.Interface) bool {
if face.Flags&net.FlagUp == 0 {
// interface down
return false
}
if face.Flags&net.FlagLoopback != 0 {
// loopback interface
return false
}
if strings.Contains(strings.ToLower(face.Name), "docker") {
return false
}
return true
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment