Fix redirect routes

This commit is contained in:
世界 2026-07-14 10:20:18 +08:00
parent eccdcee073
commit 3a09076491
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 176 additions and 106 deletions

View file

@ -6,6 +6,7 @@ import (
"os"
"os/exec"
"runtime"
"sync"
"github.com/sagernet/nftables"
"github.com/sagernet/sing/common"
@ -43,7 +44,8 @@ type autoRedirect struct {
nfqueueHandler *nfqueueHandler
nfqueueEnabled bool
redirectRouteTableIndex int
redirectInterfaces []control.Interface
redirectRouteAccess sync.Mutex
redirectRoutesActive bool
}
func NewAutoRedirect(options AutoRedirectOptions) (AutoRedirect, error) {
@ -179,8 +181,8 @@ func (r *autoRedirect) Close() error {
r.nfqueueHandler.Close()
}
if r.useNFTables {
r.cleanupRedirectRoutes()
r.cleanupNFTables()
r.cleanupRedirectRoutes()
} else {
r.cleanupIPTables()
}