Fix Android package name lookup

This commit is contained in:
世界
2026-10-23 19:57:05 +08:00
parent 42f487bd0d
commit 79d2e8084e
3 changed files with 15 additions and 9 deletions
+9 -3
View File
@@ -14,6 +14,7 @@ import (
"unicode"
"github.com/sagernet/sing-box/adapter"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing-tun"
"github.com/sagernet/sing/common"
@@ -87,7 +88,7 @@ func (s *linuxSearcher) FindProcessInfo(ctx context.Context, network string, sou
processPath, err := s.findProcessPath(inode, uid)
if err != nil {
s.logger.DebugContext(ctx, "find process path: ", err)
} else {
} else if !C.IsAndroid || !strings.HasPrefix(processPath, "/system/bin/app_process") {
processInfo.ProcessPath = processPath
}
if s.packageManager != nil {
@@ -129,9 +130,14 @@ func (s *linuxSearcher) resolveSocketByNetlink(network string, source netip.Addr
// The socket keeps the uid it was created with, while /proc reflects the
// current uid of the process, so a socket created before a privilege drop
// only appears under a scan of all users.
// only appears under a scan of all users. On Android, netd chowns the DNS
// sockets it opens on behalf of an app to the app's uid.
func (s *linuxSearcher) findProcessPath(targetInode, uid uint32) (string, error) {
for _, scanUID := range []uint32{uid, processPathsAllUsers} {
scanUIDs := []uint32{uid}
if !C.IsAndroid {
scanUIDs = append(scanUIDs, processPathsAllUsers)
}
for _, scanUID := range scanUIDs {
if cached, ok := s.processPathCache.Get(scanUID); ok {
if processPath, found := cached.entries[targetInode]; found {
return processPath, nil
+2 -2
View File
@@ -45,7 +45,7 @@ require (
github.com/sagernet/netlink v0.0.0-20260814022025-64455d367bbf
github.com/sagernet/nftables v0.3.0-mod.4
github.com/sagernet/quic-go v0.61.0-sing-box-mod.11
github.com/sagernet/sing v0.9.7-0.20261023115459-237e23f25bb1
github.com/sagernet/sing v0.9.7-0.20261023115459-9faf3c29ae9c
github.com/sagernet/sing-cloudflared v0.1.4-0.20261021152903-2d40d788fcf6
github.com/sagernet/sing-mux v0.3.10-0.20260929204512-caf09fe32475
github.com/sagernet/sing-openconnect v0.1.1-0.20260929151225-cbd68c45de58
@@ -55,7 +55,7 @@ require (
github.com/sagernet/sing-shadowsocks2 v0.2.2-0.20260929152114-a69d1086332b
github.com/sagernet/sing-shadowtls v0.2.2-0.20260928201441-a9c0127d5c99
github.com/sagernet/sing-snell v0.0.0-20260904135315-bc5a12ac736f
github.com/sagernet/sing-tun v0.9.7-0.20261023115432-fe26f6ab43d4
github.com/sagernet/sing-tun v0.9.7-0.20261023115432-26d819476877
github.com/sagernet/sing-usbip v0.0.0-20260817040617-28bd42667eca
github.com/sagernet/sing-vmess v0.2.9-0.20260929152519-9b95ab8c9478
github.com/sagernet/smux v1.5.50-sing-box-mod.1
+4 -4
View File
@@ -318,8 +318,8 @@ github.com/sagernet/nftables v0.3.0-mod.4 h1:vnOtcDYeSXv2e5RoRuGH0lrpttQFJ8iC4IC
github.com/sagernet/nftables v0.3.0-mod.4/go.mod h1:8kslHG4VvYNihcco+i6uxIX7qbT8A56T0y5q7U44ZaQ=
github.com/sagernet/quic-go v0.61.0-sing-box-mod.11 h1:bMNTBqE56x+7JMpKD2C5ARR5HopHL2WPqavKP3yyPd0=
github.com/sagernet/quic-go v0.61.0-sing-box-mod.11/go.mod h1:hmLC8GJPp+BrpBgrgJnacvI4fZGIhasuy1ROJJ8GR4E=
github.com/sagernet/sing v0.9.7-0.20261023115459-237e23f25bb1 h1:ozxyEXanA1pcsfNjypYMTFiKRSZzNXNOvp9SctRt1eM=
github.com/sagernet/sing v0.9.7-0.20261023115459-237e23f25bb1/go.mod h1:K3Owt3xPhHugvlnlPPxZJ/exXdaJfEPOTNorGk4AXjo=
github.com/sagernet/sing v0.9.7-0.20261023115459-9faf3c29ae9c h1:wMpRBuv/lzJw/uVFucTMF7VWmHfV+m32fHILPWkzPoo=
github.com/sagernet/sing v0.9.7-0.20261023115459-9faf3c29ae9c/go.mod h1:K3Owt3xPhHugvlnlPPxZJ/exXdaJfEPOTNorGk4AXjo=
github.com/sagernet/sing-cloudflared v0.1.4-0.20261021152903-2d40d788fcf6 h1:cedQ/AnIVZXNS0RbV5E6xXbLan7Qu8rOj7+B1kvb7fs=
github.com/sagernet/sing-cloudflared v0.1.4-0.20261021152903-2d40d788fcf6/go.mod h1:XEqEDYRCAYLaoPjZ1ifVWJg5iWAJHL2gOAXe/PM28Cg=
github.com/sagernet/sing-mux v0.3.10-0.20260929204512-caf09fe32475 h1:aG0DqHEOjax7DyfE1GTAXZotOg3QGVCz3/8rCSua2kg=
@@ -338,8 +338,8 @@ github.com/sagernet/sing-shadowtls v0.2.2-0.20260928201441-a9c0127d5c99 h1:l/tdZ
github.com/sagernet/sing-shadowtls v0.2.2-0.20260928201441-a9c0127d5c99/go.mod h1:sWqKnGlMipCHaGsw1sTTlimyUpgzP4WP3pjhCsYt9oA=
github.com/sagernet/sing-snell v0.0.0-20260904135315-bc5a12ac736f h1:tbTCI+iis5sTmua7a6Q7vebcSRURok/LGgnEafnQAsc=
github.com/sagernet/sing-snell v0.0.0-20260904135315-bc5a12ac736f/go.mod h1:et8Lws4f5QbOrY65DmjevHGup3mijJkhswkto6cwciM=
github.com/sagernet/sing-tun v0.9.7-0.20261023115432-fe26f6ab43d4 h1:5Kj3OAfbl+BNBauz8k0Ji9WzAIybs3eyo7xbCRClCdY=
github.com/sagernet/sing-tun v0.9.7-0.20261023115432-fe26f6ab43d4/go.mod h1:3EgPst7agntRO7D6GOsiZ1l9FoqdLeuWmKT5TnWkmf0=
github.com/sagernet/sing-tun v0.9.7-0.20261023115432-26d819476877 h1:lc2Xp4Gw6K4PIIQ+GW6CxpkgiQMa0eiPvYcp0FmuQ5Y=
github.com/sagernet/sing-tun v0.9.7-0.20261023115432-26d819476877/go.mod h1:3EgPst7agntRO7D6GOsiZ1l9FoqdLeuWmKT5TnWkmf0=
github.com/sagernet/sing-usbip v0.0.0-20260817040617-28bd42667eca h1:5wA+IE0Fq1CGVLOgSpm0gKKZ03HzugcJ2JyhmDqeX6A=
github.com/sagernet/sing-usbip v0.0.0-20260817040617-28bd42667eca/go.mod h1:ADAZZU85MnM91XNhd2TdZRTaIbA7RjTZuQ1KCHcUbNg=
github.com/sagernet/sing-vmess v0.2.9-0.20260929152519-9b95ab8c9478 h1:q2eQn4nq8oWGxRm9zXesXSlPr9GEgPrOGzf4iPtzG9A=