chore(routing): unexport IPIsPrivate as ipIsPrivate

This commit is contained in:
Quentin McGaw
2023-06-08 09:13:55 +00:00
parent 40cdb4f662
commit cade2b99bf
3 changed files with 4 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ import (
"github.com/qdm12/gluetun/internal/netlink" "github.com/qdm12/gluetun/internal/netlink"
) )
func IPIsPrivate(ip netip.Addr) bool { func ipIsPrivate(ip netip.Addr) bool {
return ip.IsPrivate() || ip.IsLoopback() || return ip.IsPrivate() || ip.IsLoopback() ||
ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast() ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast()
} }

View File

@@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func Test_IPIsPrivate(t *testing.T) { func Test_ipIsPrivate(t *testing.T) {
t.Parallel() t.Parallel()
testCases := map[string]struct { testCases := map[string]struct {
@@ -90,7 +90,7 @@ func Test_IPIsPrivate(t *testing.T) {
ip, err := netip.ParseAddr(testCase.ipString) ip, err := netip.ParseAddr(testCase.ipString)
require.NoError(t, err) require.NoError(t, err)
isPrivate := IPIsPrivate(ip) isPrivate := ipIsPrivate(ip)
assert.Equal(t, testCase.isPrivate, isPrivate) assert.Equal(t, testCase.isPrivate, isPrivate)
}) })

View File

@@ -33,7 +33,7 @@ func (r *Routing) VPNDestinationIP() (ip netip.Addr, err error) {
for _, route := range routes { for _, route := range routes {
if route.LinkIndex == defaultLinkIndex && if route.LinkIndex == defaultLinkIndex &&
route.Dst.IsValid() && route.Dst.IsValid() &&
!IPIsPrivate(route.Dst.Addr()) && !ipIsPrivate(route.Dst.Addr()) &&
route.Dst.IsSingleIP() { route.Dst.IsSingleIP() {
return route.Dst.Addr(), nil return route.Dst.Addr(), nil
} }