Skip to content
Discussion options

You must be logged in to vote

TL;DR:能,但别靠 UID 规则逐连接反查,更稳的是在 TUN 上用 include-uid,让内核按 UID 分流(见下面「按用户分流」)。UDP 报 could not get uid,先排除「代理不支持 UDP」,再看「双栈 socket」(每个用户自己的 mihomo 转发 UDP 用的就是这种 socket)。

看了下源码(Alpha 69c16319)。我这边没法在你的环境里验证,下面按排查顺序说。

1. 先排除:代理不支持 UDP

系统级 mihomo 里指向用户 mihomo 的那个 proxy 必须支持 UDP:socks5 要写 udp: true(默认是 false),http 类型本身不支持 UDP。否则 UID 规则就算匹配上了也会被跳过(tunnel.go#L684-L687,只打一条 debug 级别的 xxx UDP is not supported),UDP 落到后面的规则;在没打 #3324 的版本里,后面的 UID 规则就会打 could not get uid。(用户 mihomo 那边的 socks/mixed 入站默认就支持 UDP,别关掉就行。)

2. 双栈 socket(推测)

桌面 Linux 的 resolveSocketByNetlink 只发一次 INET_DIAG dump,family 跟着包的源地址走,IPv4 包就用 AF_INET(L99-L103)。内核 dump 时会跳过 sk_family 不同的 socket(udp_diag.c#L120-L121,TCP 同理:tcp_diag.c#L509…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@yueyinqiu
Comment options

@yueyinqiu
Comment options

Answer selected by yueyinqiu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants