(t *testing.T, ipv4 bool)
| 390 | } |
| 391 | |
| 392 | func getLocalIPs(t *testing.T, ipv4 bool) []netip.Addr { |
| 393 | interfaces, err := net.Interfaces() |
| 394 | require.NoError(t, err) |
| 395 | localIPs := []netip.Addr{} |
| 396 | for _, i := range interfaces { |
| 397 | // Skip TUN devices, and Docker Networks |
| 398 | if strings.Contains(i.Name, "tun") || strings.Contains(i.Name, "docker") || strings.HasPrefix(i.Name, "br-") { |
| 399 | continue |
| 400 | } |
| 401 | addrs, err := i.Addrs() |
| 402 | require.NoError(t, err) |
| 403 | for _, addr := range addrs { |
| 404 | if ipnet, ok := addr.(*net.IPNet); ok && (ipnet.IP.IsPrivate() || ipnet.IP.IsLoopback()) { |
| 405 | // TODO DEVTOOLS-12514: We only run the IPv6 against the loopback interface due to issues on the CI runners. |
| 406 | if (ipv4 && ipnet.IP.To4() != nil) || (!ipv4 && ipnet.IP.To4() == nil && ipnet.IP.IsLoopback()) { |
| 407 | localIPs = append(localIPs, netip.MustParseAddr(ipnet.IP.String())) |
| 408 | } |
| 409 | } |
| 410 | } |
| 411 | } |
| 412 | return localIPs |
| 413 | } |
no test coverage detected