This commit is contained in:
世界 2024-06-01 11:05:57 +08:00
parent 13f4b57997
commit 8ccc8bb1d7
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4

View File

@ -61,26 +61,20 @@ func newAutoRedirect(t *Tun) (*tunAutoRedirect, error) {
suPath string suPath string
err error err error
) )
if t.platformInterface != nil { for _, suPath = range []string{
suPaths := []string{ "su",
"/bin/su", "/system/bin/su",
"/system/bin/su", } {
suPath, err = exec.LookPath(suPath)
if err == nil {
break
} }
for _, path := range suPaths {
suPath, err = exec.LookPath(path)
if err == nil {
break
}
}
} else {
suPath, err = exec.LookPath("su")
} }
if err == nil { if err != nil {
s.androidSu = true
s.suPath = suPath
} else {
return nil, E.Extend(E.Cause(err, "root permission is required for auto redirect"), os.Getenv("PATH")) return nil, E.Extend(E.Cause(err, "root permission is required for auto redirect"), os.Getenv("PATH"))
} }
s.androidSu = true
s.suPath = suPath
} }
} else { } else {
err := s.initializeNfTables() err := s.initializeNfTables()