Fix default gateway not set when --route-nopull
The "no pull" flag is already accounted for when routingPolicies is
computed (e.g. default gateway). Evaluate it properly for routes
instead.
See 31db8ebb9d
This commit is contained in:
parent
65c41c257b
commit
8ac21771e3
|
@ -117,7 +117,6 @@ extension NetworkSettingsBuilder {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
let ipv4Settings = NEIPv4Settings(addresses: [ipv4.address], subnetMasks: [ipv4.addressMask])
|
let ipv4Settings = NEIPv4Settings(addresses: [ipv4.address], subnetMasks: [ipv4.addressMask])
|
||||||
if pullRoutes {
|
|
||||||
var routes: [NEIPv4Route] = []
|
var routes: [NEIPv4Route] = []
|
||||||
|
|
||||||
// route all traffic to VPN?
|
// route all traffic to VPN?
|
||||||
|
@ -128,7 +127,9 @@ extension NetworkSettingsBuilder {
|
||||||
log.info("Routing.IPv4: Setting default gateway to \(ipv4.defaultGateway)")
|
log.info("Routing.IPv4: Setting default gateway to \(ipv4.defaultGateway)")
|
||||||
}
|
}
|
||||||
|
|
||||||
for r in ipv4.routes {
|
// FIXME: this is ineffective until #278 is fixed (localOptions.ipv4 is always nil)
|
||||||
|
let computedRoutes = (pullRoutes ? (remoteOptions.ipv4?.routes ?? localOptions.ipv4?.routes) : localOptions.ipv4?.routes) ?? []
|
||||||
|
for r in computedRoutes {
|
||||||
let ipv4Route = NEIPv4Route(destinationAddress: r.destination, subnetMask: r.mask)
|
let ipv4Route = NEIPv4Route(destinationAddress: r.destination, subnetMask: r.mask)
|
||||||
ipv4Route.gatewayAddress = r.gateway
|
ipv4Route.gatewayAddress = r.gateway
|
||||||
routes.append(ipv4Route)
|
routes.append(ipv4Route)
|
||||||
|
@ -137,7 +138,6 @@ extension NetworkSettingsBuilder {
|
||||||
|
|
||||||
ipv4Settings.includedRoutes = routes
|
ipv4Settings.includedRoutes = routes
|
||||||
ipv4Settings.excludedRoutes = []
|
ipv4Settings.excludedRoutes = []
|
||||||
}
|
|
||||||
return ipv4Settings
|
return ipv4Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,6 @@ extension NetworkSettingsBuilder {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
let ipv6Settings = NEIPv6Settings(addresses: [ipv6.address], networkPrefixLengths: [ipv6.addressPrefixLength as NSNumber])
|
let ipv6Settings = NEIPv6Settings(addresses: [ipv6.address], networkPrefixLengths: [ipv6.addressPrefixLength as NSNumber])
|
||||||
if pullRoutes {
|
|
||||||
var routes: [NEIPv6Route] = []
|
var routes: [NEIPv6Route] = []
|
||||||
|
|
||||||
// route all traffic to VPN?
|
// route all traffic to VPN?
|
||||||
|
@ -157,7 +156,9 @@ extension NetworkSettingsBuilder {
|
||||||
log.info("Routing.IPv6: Setting default gateway to \(ipv6.defaultGateway)")
|
log.info("Routing.IPv6: Setting default gateway to \(ipv6.defaultGateway)")
|
||||||
}
|
}
|
||||||
|
|
||||||
for r in ipv6.routes {
|
// FIXME: this is ineffective until #278 is fixed (localOptions.ipv6 is always nil)
|
||||||
|
let computedRoutes = (pullRoutes ? (remoteOptions.ipv6?.routes ?? localOptions.ipv6?.routes) : localOptions.ipv6?.routes) ?? []
|
||||||
|
for r in computedRoutes {
|
||||||
let ipv6Route = NEIPv6Route(destinationAddress: r.destination, networkPrefixLength: r.prefixLength as NSNumber)
|
let ipv6Route = NEIPv6Route(destinationAddress: r.destination, networkPrefixLength: r.prefixLength as NSNumber)
|
||||||
ipv6Route.gatewayAddress = r.gateway
|
ipv6Route.gatewayAddress = r.gateway
|
||||||
routes.append(ipv6Route)
|
routes.append(ipv6Route)
|
||||||
|
@ -166,7 +167,6 @@ extension NetworkSettingsBuilder {
|
||||||
|
|
||||||
ipv6Settings.includedRoutes = routes
|
ipv6Settings.includedRoutes = routes
|
||||||
ipv6Settings.excludedRoutes = []
|
ipv6Settings.excludedRoutes = []
|
||||||
}
|
|
||||||
return ipv6Settings
|
return ipv6Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue