mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-25 11:53:11 +03:00
Add exclude route support for tun
This commit is contained in:
@@ -115,7 +115,11 @@ func (w *platformInterfaceWrapper) OpenTun(options *tun.Options, platformOptions
|
||||
if len(options.IncludeAndroidUser) > 0 {
|
||||
return nil, E.New("android: unsupported android_user option")
|
||||
}
|
||||
tunFd, err := w.iif.OpenTun(&tunOptions{options, platformOptions})
|
||||
routeRanges, err := options.BuildAutoRouteRanges()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tunFd, err := w.iif.OpenTun(&tunOptions{options, routeRanges, platformOptions})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -60,15 +60,20 @@ var _ TunOptions = (*tunOptions)(nil)
|
||||
|
||||
type tunOptions struct {
|
||||
*tun.Options
|
||||
routeRanges []netip.Prefix
|
||||
option.TunPlatformOptions
|
||||
}
|
||||
|
||||
func (o *tunOptions) GetInet4Address() RoutePrefixIterator {
|
||||
return mapRoutePrefix(o.Inet4Address)
|
||||
return mapRoutePrefix(common.Filter(o.Inet4Address, func(it netip.Prefix) bool {
|
||||
return it.Addr().Is4()
|
||||
}))
|
||||
}
|
||||
|
||||
func (o *tunOptions) GetInet6Address() RoutePrefixIterator {
|
||||
return mapRoutePrefix(o.Inet6Address)
|
||||
return mapRoutePrefix(common.Filter(o.Inet4Address, func(it netip.Prefix) bool {
|
||||
return it.Addr().Is6()
|
||||
}))
|
||||
}
|
||||
|
||||
func (o *tunOptions) GetDNSServerAddress() (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user