From 8ade7f05c1fac366cc70a35397a738d14303f06f Mon Sep 17 00:00:00 2001 From: ashuntu Date: Fri, 6 Dec 2024 13:00:04 -0600 Subject: [PATCH] Check that IPs are convertible to ipv4 If the system receives an IPv6 address, then running the agent with mocks (for example, when running integration tests) can result in panics. Co-authored-by: Carlos Nihelton --- .../internal/daemon/daemontestutils/networking_mock.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows-agent/internal/daemon/daemontestutils/networking_mock.go b/windows-agent/internal/daemon/daemontestutils/networking_mock.go index ad9a4051b..dcfc0eec3 100644 --- a/windows-agent/internal/daemon/daemontestutils/networking_mock.go +++ b/windows-agent/internal/daemon/daemontestutils/networking_mock.go @@ -144,7 +144,7 @@ func getLocalPrivateIP() net.IP { return nil } for _, addr := range addrs { - if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() && ipnet.IP.IsPrivate() { + if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() && ipnet.IP.IsPrivate() && ipnet.IP.To4() != nil { return ipnet.IP } }