chore(routing): remove unused VPNDestinationIP
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user