Add android package rules support in tun routing

This commit is contained in:
世界
2022-08-15 11:40:49 +08:00
parent 3157593b6b
commit cd5e7055d2
16 changed files with 100 additions and 188 deletions

View File

@@ -81,8 +81,10 @@ func NewTun(ctx context.Context, router adapter.Router, logger log.ContextLogger
Inet6Address: options.Inet6Address.Build(),
AutoRoute: options.AutoRoute,
IncludeUID: includeUID,
IncludeAndroidUser: options.IncludeAndroidUser,
ExcludeUID: excludeUID,
IncludeAndroidUser: options.IncludeAndroidUser,
IncludePackage: options.IncludePackage,
ExcludePackage: options.ExcludePackage,
},
endpointIndependentNat: options.EndpointIndependentNat,
udpTimeout: udpTimeout,
@@ -131,6 +133,9 @@ func (t *Tun) Tag() string {
}
func (t *Tun) Start() error {
if C.IsAndroid {
t.tunOptions.BuildAndroidRules(t.router.PackageManager(), t)
}
tunIf, err := tun.Open(t.tunOptions)
if err != nil {
return E.Cause(err, "configure tun interface")