Routing: process supports UID on Android (#5915)

Example: https://github.com/XTLS/Xray-core/pull/5915#issuecomment-4232122895

---------

Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
This commit is contained in:
Exclude0122
2026-04-13 09:17:53 -04:00
committed by GitHub
parent c93478b891
commit f27edc3172
5 changed files with 70 additions and 43 deletions
+20
View File
@@ -0,0 +1,20 @@
//go:build android
package net
import (
"github.com/xtls/xray-core/common/errors"
)
var androidProcessFinder func(network, srcIP string, srcPort uint16, destIP string, destPort uint16) (int, string, string, error)
func RegisterAndroidProcessFinder(f func(network, srcIP string, srcPort uint16, destIP string, destPort uint16) (int, string, string, error)) {
androidProcessFinder = f
}
func FindProcess(network, srcIP string, srcPort uint16, destIP string, destPort uint16) (int, string, string, error) {
if androidProcessFinder != nil {
return androidProcessFinder(network, srcIP, srcPort, destIP, destPort)
}
return 0, "", "", errors.New("android process lookup must be registered before use")
}