diff --git a/internal/routing/vpn.go b/internal/routing/vpn.go index 537166ac..40f35674 100644 --- a/internal/routing/vpn.go +++ b/internal/routing/vpn.go @@ -9,38 +9,9 @@ import ( ) var ( - ErrVPNDestinationIPNotFound = errors.New("VPN destination IP address not found") ErrVPNLocalGatewayIPNotFound = errors.New("VPN local gateway IP address not found") ) -func (r *Routing) VPNDestinationIP() (ip netip.Addr, err error) { - routes, err := r.netLinker.RouteList(netlink.FamilyAll) - if err != nil { - return ip, fmt.Errorf("listing routes: %w", err) - } - - defaultLinkIndex := -1 - for _, route := range routes { - if !route.Dst.IsValid() { - defaultLinkIndex = route.LinkIndex - break - } - } - if defaultLinkIndex == -1 { - return ip, fmt.Errorf("%w: in %d route(s)", ErrLinkDefaultNotFound, len(routes)) - } - - for _, route := range routes { - if route.LinkIndex == defaultLinkIndex && - route.Dst.IsValid() && - !ipIsPrivate(route.Dst.Addr()) && - route.Dst.IsSingleIP() { - return route.Dst.Addr(), nil - } - } - return ip, fmt.Errorf("%w: in %d routes", ErrVPNDestinationIPNotFound, len(routes)) -} - func (r *Routing) VPNLocalGatewayIP(vpnIntf string) (ip netip.Addr, err error) { routes, err := r.netLinker.RouteList(netlink.FamilyAll) if err != nil {