Skip to content

Commit 5d44041

Browse files
committed
auto-redirect: Fix nftables available check
1 parent 60a8276 commit 5d44041

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

redirect_linux.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"os"
77
"os/exec"
88
"runtime"
9-
"time"
109

1110
"github.com/sagernet/nftables"
1211
"github.com/sagernet/sing/common"
@@ -81,7 +80,8 @@ func NewAutoRedirect(options AutoRedirectOptions) (AutoRedirect, error) {
8180
if r.useNFTables {
8281
err = r.initializeNFTables()
8382
if err != nil && err != os.ErrInvalid {
84-
r.logger.Debug("device has no nftables support: ", err)
83+
r.useNFTables = false
84+
r.logger.Debug("missing nftables support: ", err)
8585
}
8686
}
8787
if len(r.tunOptions.Inet4Address) > 0 {
@@ -131,7 +131,6 @@ func (r *autoRedirect) Start() error {
131131
}
132132
r.redirectServer = server
133133
}
134-
startAt := time.Now()
135134
var err error
136135
if r.useNFTables {
137136
r.cleanupNFTables()
@@ -140,11 +139,7 @@ func (r *autoRedirect) Start() error {
140139
r.cleanupIPTables()
141140
err = r.setupIPTables()
142141
}
143-
if err != nil {
144-
return err
145-
}
146-
r.logger.Debug("auto-redirect configured in ", time.Since(startAt))
147-
return nil
142+
return err
148143
}
149144

150145
func (r *autoRedirect) Close() error {

0 commit comments

Comments
 (0)