Fix multi include/exclude interfaces

This commit is contained in:
世界 2026-04-20 07:40:18 +08:00
parent 5b7311ba58
commit e5d2fab035
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 13 additions and 26 deletions

View file

@ -274,10 +274,11 @@ func (r *autoRedirect) nftablesCreateExcludeRules(nft *nftables.Conn, table *nft
if len(r.tunOptions.IncludeInterface) > 0 {
if len(r.tunOptions.IncludeInterface) > 1 {
includeInterface := &nftables.Set{
Table: table,
Anonymous: true,
Constant: true,
KeyType: nftables.TypeIFName,
Table: table,
Anonymous: true,
Constant: true,
KeyType: nftables.TypeIFName,
KeyByteOrder: binaryutil.NativeEndian,
}
err := nft.AddSet(includeInterface, common.Map(r.tunOptions.IncludeInterface, func(it string) nftables.SetElement {
return nftables.SetElement{
@ -327,10 +328,11 @@ func (r *autoRedirect) nftablesCreateExcludeRules(nft *nftables.Conn, table *nft
if len(r.tunOptions.ExcludeInterface) > 0 {
if len(r.tunOptions.ExcludeInterface) > 1 {
excludeInterface := &nftables.Set{
Table: table,
Anonymous: true,
Constant: true,
KeyType: nftables.TypeIFName,
Table: table,
Anonymous: true,
Constant: true,
KeyType: nftables.TypeIFName,
KeyByteOrder: binaryutil.NativeEndian,
}
err := nft.AddSet(excludeInterface, common.Map(r.tunOptions.ExcludeInterface, func(it string) nftables.SetElement {
return nftables.SetElement{