Skip to content

Commit

Permalink
ignore docker interfaces in default private IP determination
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulexus committed Jul 23, 2018
1 parent c20ac3a commit 382d9ed
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions discover/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,20 @@ func defaultPublicIPv6() (net.IP, error) {
return ip, nil
}

// nolint: gocyclo
func defaultPrivateIPv4() (net.IP, error) {
netifs, err := net.Interfaces()
if err != nil {
return nil, fmt.Errorf("failed to get list of local interfaces: %v", err)
}

for _, i := range netifs {

// Skip docker interfaces
if strings.HasPrefix(i.Name, "docker") {
continue
}

addresses, err := i.Addrs()
if err != nil {
continue // next interface
Expand Down

0 comments on commit 382d9ed

Please sign in to comment.