auto-redirect: Fix nftables available check
This commit is contained in:
parent
60a8276dc4
commit
5d440412ba
1 changed files with 3 additions and 8 deletions
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/sagernet/nftables"
|
"github.com/sagernet/nftables"
|
||||||
"github.com/sagernet/sing/common"
|
"github.com/sagernet/sing/common"
|
||||||
|
|
@ -81,7 +80,8 @@ func NewAutoRedirect(options AutoRedirectOptions) (AutoRedirect, error) {
|
||||||
if r.useNFTables {
|
if r.useNFTables {
|
||||||
err = r.initializeNFTables()
|
err = r.initializeNFTables()
|
||||||
if err != nil && err != os.ErrInvalid {
|
if err != nil && err != os.ErrInvalid {
|
||||||
r.logger.Debug("device has no nftables support: ", err)
|
r.useNFTables = false
|
||||||
|
r.logger.Debug("missing nftables support: ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(r.tunOptions.Inet4Address) > 0 {
|
if len(r.tunOptions.Inet4Address) > 0 {
|
||||||
|
|
@ -131,7 +131,6 @@ func (r *autoRedirect) Start() error {
|
||||||
}
|
}
|
||||||
r.redirectServer = server
|
r.redirectServer = server
|
||||||
}
|
}
|
||||||
startAt := time.Now()
|
|
||||||
var err error
|
var err error
|
||||||
if r.useNFTables {
|
if r.useNFTables {
|
||||||
r.cleanupNFTables()
|
r.cleanupNFTables()
|
||||||
|
|
@ -140,12 +139,8 @@ func (r *autoRedirect) Start() error {
|
||||||
r.cleanupIPTables()
|
r.cleanupIPTables()
|
||||||
err = r.setupIPTables()
|
err = r.setupIPTables()
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r.logger.Debug("auto-redirect configured in ", time.Since(startAt))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *autoRedirect) Close() error {
|
func (r *autoRedirect) Close() error {
|
||||||
if r.useNFTables {
|
if r.useNFTables {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue