Fix IncludeInterface/ExcludeInterface priority

This commit is contained in:
wwqgtxx 2025-04-09 13:35:20 +08:00
parent 219c612399
commit d89ab3f207

View file

@ -668,7 +668,7 @@ func (t *NativeTun) rules() []*netlink.Rule {
}
}
if len(t.options.IncludeInterface) > 0 {
matchPriority := priority + 2*len(t.options.IncludeInterface) + 1
matchPriority := priority + 2
for _, includeInterface := range t.options.IncludeInterface {
if p4 {
it = netlink.NewRule()
@ -677,7 +677,6 @@ func (t *NativeTun) rules() []*netlink.Rule {
it.Goto = matchPriority
it.Family = unix.AF_INET
rules = append(rules, it)
priority++
}
if p6 {
it = netlink.NewRule()
@ -686,9 +685,14 @@ func (t *NativeTun) rules() []*netlink.Rule {
it.Goto = matchPriority
it.Family = unix.AF_INET6
rules = append(rules, it)
priority6++
}
}
if p4 {
priority++
}
if p6 {
priority6++
}
if p4 {
it = netlink.NewRule()
it.Priority = priority
@ -726,7 +730,6 @@ func (t *NativeTun) rules() []*netlink.Rule {
it.Goto = nopPriority
it.Family = unix.AF_INET
rules = append(rules, it)
priority++
}
if p6 {
it = netlink.NewRule()
@ -735,9 +738,15 @@ func (t *NativeTun) rules() []*netlink.Rule {
it.Goto = nopPriority
it.Family = unix.AF_INET6
rules = append(rules, it)
priority6++
}
}
if p4 {
priority++
}
if p6 {
priority6++
}
}
if runtime.GOOS == "android" && t.options.InterfaceMonitor.AndroidVPNEnabled() {