From cade2b99bf01edf3f88a1994446793f09098bc68 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Thu, 8 Jun 2023 09:13:55 +0000 Subject: [PATCH] chore(routing): unexport `IPIsPrivate` as `ipIsPrivate` --- internal/routing/ip.go | 2 +- internal/routing/ip_test.go | 4 ++-- internal/routing/vpn.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/routing/ip.go b/internal/routing/ip.go index 9f9d7429..99da450e 100644 --- a/internal/routing/ip.go +++ b/internal/routing/ip.go @@ -9,7 +9,7 @@ import ( "github.com/qdm12/gluetun/internal/netlink" ) -func IPIsPrivate(ip netip.Addr) bool { +func ipIsPrivate(ip netip.Addr) bool { return ip.IsPrivate() || ip.IsLoopback() || ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast() } diff --git a/internal/routing/ip_test.go b/internal/routing/ip_test.go index 1e34d895..b25d1b3a 100644 --- a/internal/routing/ip_test.go +++ b/internal/routing/ip_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" ) -func Test_IPIsPrivate(t *testing.T) { +func Test_ipIsPrivate(t *testing.T) { t.Parallel() testCases := map[string]struct { @@ -90,7 +90,7 @@ func Test_IPIsPrivate(t *testing.T) { ip, err := netip.ParseAddr(testCase.ipString) require.NoError(t, err) - isPrivate := IPIsPrivate(ip) + isPrivate := ipIsPrivate(ip) assert.Equal(t, testCase.isPrivate, isPrivate) }) diff --git a/internal/routing/vpn.go b/internal/routing/vpn.go index 8432c852..537166ac 100644 --- a/internal/routing/vpn.go +++ b/internal/routing/vpn.go @@ -33,7 +33,7 @@ func (r *Routing) VPNDestinationIP() (ip netip.Addr, err error) { for _, route := range routes { if route.LinkIndex == defaultLinkIndex && route.Dst.IsValid() && - !IPIsPrivate(route.Dst.Addr()) && + !ipIsPrivate(route.Dst.Addr()) && route.Dst.IsSingleIP() { return route.Dst.Addr(), nil }