mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-06 20:10:11 +02:00
hotfix(pmtud): set mss on all VPN routes
- fix behavior for OpenVPN splitting default route in multiple routes - fix behavior for Wireguard if user specifies AllowedIPs
This commit is contained in:
+15
-10
@@ -50,23 +50,28 @@ func (r *Routing) VPNLocalGatewayIP(vpnIntf string) (ip netip.Addr, err error) {
|
||||
|
||||
var ErrVPNRouteNotFound = errors.New("VPN route not found")
|
||||
|
||||
func (r *Routing) VPNRoute(vpnIntf string) (route netlink.Route, err error) {
|
||||
func (r *Routing) VPNRoutes(vpnIntf string) (routes []netlink.Route, err error) {
|
||||
vpnLink, err := r.netLinker.LinkByName(vpnIntf)
|
||||
if err != nil {
|
||||
return route, fmt.Errorf("finding link %s: %w", vpnIntf, err)
|
||||
return nil, fmt.Errorf("finding link %s: %w", vpnIntf, err)
|
||||
}
|
||||
vpnLinkIndex := vpnLink.Index
|
||||
|
||||
routes, err := r.netLinker.RouteList(netlink.FamilyAll)
|
||||
allRoutes, err := r.netLinker.RouteList(netlink.FamilyAll)
|
||||
if err != nil {
|
||||
return route, fmt.Errorf("listing routes: %w", err)
|
||||
return nil, fmt.Errorf("listing routes: %w", err)
|
||||
}
|
||||
for _, route := range routes {
|
||||
if route.LinkIndex == vpnLinkIndex &&
|
||||
!route.Dst.IsValid() {
|
||||
return route, nil
|
||||
routes = make([]netlink.Route, 0, len(allRoutes))
|
||||
for _, route := range allRoutes {
|
||||
if route.LinkIndex == vpnLinkIndex {
|
||||
routes = append(routes, route)
|
||||
}
|
||||
}
|
||||
return route, fmt.Errorf("%w: for interface %s in %d routes",
|
||||
ErrVPNRouteNotFound, vpnIntf, len(routes))
|
||||
|
||||
if len(routes) == 0 {
|
||||
return nil, fmt.Errorf("%w: for interface %s in %d routes",
|
||||
ErrVPNRouteNotFound, vpnIntf, len(allRoutes))
|
||||
}
|
||||
|
||||
return routes, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user