Fix "Fix darwin routes"

This commit is contained in:
世界 2024-05-31 18:57:38 +08:00
parent 5d9bd04495
commit 1c6d2891ab
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -109,9 +109,11 @@ func (o *Options) BuildAutoRouteRanges(underNetworkExtension bool) ([]netip.Pref
var inet4Ranges []netip.Prefix
if len(o.Inet4RouteAddress) > 0 {
inet4Ranges = o.Inet4RouteAddress
if runtime.GOOS == "darwin" {
for _, address := range o.Inet4Address {
if address.Bits() < 32 {
inet4Ranges = append(inet4Ranges, netipx.RangeOfPrefix(address).Prefixes()...)
inet4Ranges = append(inet4Ranges, address.Masked())
}
}
}
} else if autoRouteUseSubRanges && !underNetworkExtension {
@ -149,9 +151,11 @@ func (o *Options) BuildAutoRouteRanges(underNetworkExtension bool) ([]netip.Pref
var inet6Ranges []netip.Prefix
if len(o.Inet6RouteAddress) > 0 {
inet6Ranges = o.Inet6RouteAddress
if runtime.GOOS == "darwin" {
for _, address := range o.Inet6Address {
if address.Bits() < 32 {
inet6Ranges = append(inet6Ranges, netipx.RangeOfPrefix(address).Prefixes()...)
inet6Ranges = append(inet6Ranges, address.Masked())
}
}
}
} else if autoRouteUseSubRanges && !underNetworkExtension {