Routing: Fix process for macOS IPv4-mapped sockets - #6557
Conversation
|
@copilot review |
process for macOS IPv4-mapped sockets
|
@yiguodev 话说你在 macOS 上实测修复了对吧,以及他那个 issue 说的问题二,我感觉 macOS 可能是必须要 root 权限的? |
|
Codex 测了,我没测。问题二不需要 root 权限。 |
|
@yiguodev 那你测一下问题二是否存在吧, |
|
Codex 的测试用例包含问题二,确实存在,也修了。 |
|
|
而且看起来这 AI 对问题二的描述也不太对,因为问题二能被他“一律”复现,且如果是上述原因的话那么是否 root 应该没差别
|
|
你划掉的疑问其实是对的,我前面的表述不准确。 这个 PR 的生产代码只修问题一:IPv4 源地址匹配时允许 保持连接时,非 root 对同用户 AF_INET socket 的查找本来正常(不代表可查看其他用户的 socket)。我刚在 macOS 上以普通用户(uid 501)重跑了原有的 我之前说“问题二也修了”是错的。准确说法是:修正复现方式后,issue 所述同用户场景的“问题二”无法复现。抱歉。 |
|
看来我和 AI 都幻觉了。 |
|
这么不负责吗全都是AI |
|
|
|
结果就是这样出了问题没一个活人说得清 用AI辅助排查写点代码没问题我也不是原始人 从排查到代码到验收全甩给agent 有问题就甩锅AI错了 大多数纯AI的pr我都是看一眼就关的 你弄的大都是我不想管的地方就一直没说啥 刚好看到上面一串忍不住了而已 |
|
|
|
@Fangliding 首先,这个 PR 已经两周了,不要苛求别人会记得所有细节。其次,我并没有甩锅 AI,我也说了我幻觉了。 |
Summary
AF_INET6socket entries marked with the IPv4ini_vflagwhen matching an IPv4 sourceRoot cause
Darwin reports IPv4 connections created by dual-stack sockets as
AF_INET6with the IPv4 bit set in
ini_vflag.FindProcessunmapped the source addressto IPv4, but then required the socket family to be
AF_INET, so these entrieswere always rejected. The existing address comparison already supports the
IPv4 bytes stored in the final four bytes of the Darwin address structure.
The non-root case described in #6533 is caused by the minimal SOCKS client
closing immediately after receiving Xray's success response. Once the socket
has lost its owning file descriptor, process lookup cannot recover its owner.
With the connection kept open, non-root AF_INET lookup works normally.
Fixes #6533.
Validation
CGO_ENABLED=0 go test ./common/net -count=1go test ./common/net ./app/router ./proxy/tun -count=1GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go test -c ./common/netgit diff --check