SagerNet / SagerNet/sing-box

`set_system_proxy` via `rish` never works on SFA

Open
#4,513 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
38.1k
Forks
4.6k
Avg merge
19d 15h
Merged PRs (30d)
1

Description

set_system_proxy via rish never works on SFA

Env: SFA + Shizuku, config
inbounds: [{type:"mixed", listen:"127.0.0.1", listen_port:7777, set_system_proxy:true}], no tun.

Expected: NewSystemProxy finds exported rish + rish_shizuku.dex
and runs settings put global http_proxy with shell privilege (no VPN slot).

Actual: always root or system (adb) permission is required for set system proxy,
no matter where the files are placed (files/, cache/, external files/,
sing-box/ subdirs, correct uid/gid/context/perms).

Root cause (core):

  1. common/settings/proxy_android.go:23 relies on C.FindPath("rish").
  2. constant/path.go:30 + constant/path_unix.go:9 only search
    [".", "/etc", "/usr/share", "/usr/local/etc", "/usr/local/share"]
    (plus HOME-based entries if HOME is set).
  3. On GOOS=android (Unix branch, Go os/file.go:531),
    UserCacheDir/UserConfigDir require XDG_*/HOME.

Trigger (SFA app, SagerNet/sing-box-for-android):
Application.kt:57-108 passes basePath/filesDir, workingPath/externalFiles,
tempPath/cacheDir to libbox Setup, but never sets HOME/XDG_* nor
chdirs (libbox/setup.go has no Chdir; sWorkingPath ≠ process cwd,
usually /). Hence FindPath can never hit any app directory.

Suggest (either side fixes it):

  • core: resolve rish via filemanager.BasePath/sWorkingPath,
    or add a rish_path option / absolute-path support;
  • app: setenv("HOME", basePath) (or cwdworkingPath) on startup.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with common/settings/proxy_android.go and constant/path.go plus constant/path_unix.go to trace how FindPath locates rish. Compare those assumptions with Application.kt:57-108 and libbox/setup.go, then reproduce the supplied SFA configuration. Done means set_system_proxy discovers the exported rish files and applies the global proxy without requiring root, system/ADB permission, or a VPN slot.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kotlin
Domain
mobile-dev, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.