Repository navigation
Finalmask: Fix panic when udpHop or xicmp fails; Restore udpHop's default interval - #6808
Merged
Merged
Conversation
Replaced manual connection closure with common.CloseIfExists function for better error handling.
patterniha
pushed a commit
to patterniha/Xray-core
that referenced
this pull request
Sep 24, 2026
…fault `interval` Early merge of XTLS#6808 (PR head 109c274), squashed, ahead of it landing upstream: XTLS#6808 Co-authored-by: 风扇滑翔翼 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
LjhAUMEM
approved these changes
Sep 26, 2026
LjhAUMEM
left a comment
Contributor
There was a problem hiding this comment.
我个人不是很喜欢默认值,不过加就加吧,对于 Handle Dial 的如果 err close 会 panic 的描述是对的
intervalinterval
intervalinterval
RPRX
pushed a commit
that referenced
this pull request
Sep 27, 2026
…ault `interval` (#6808) #6808 (review) --------- Co-authored-by: 风扇滑翔翼 <[email protected]>
GFW-knocker
pushed a commit
to GFW-knocker/Xray-core
that referenced
this pull request
Oct 2, 2026
…ault `interval` (XTLS#6808) XTLS#6808 (review) --------- Co-authored-by: 风扇滑翔翼 <[email protected]> (cherry picked from commit 7780db9) [GFW-knocker: hand-merged, config part only. The panic half fixes code from the transport refactor (XTLS#6754), which this fork does not take: here the finalmask managers return a plain nil and every caller closes its own raw conn. The udpHop default interval (30) and its build-time check are kept.]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#6754 之后,
FinalMask的DialTCP、DialUDP、ListenPacket在第一个掩码自己负责拨号或监听时(目前是udpHop和xicmp)不会先建立连接,conn为 nil。此时如果该掩码返回错误,错误分支会对 nil 调用conn.Close(),整个进程 panic 退出。这段代码还没有进入发布版本。用 d562d89 原版编译复现:
udpHop配置正确,但服务器地址是域名且解析失败(例如切换网络时):第一个连接进来时 panic(Hysteria 出站,finalmask.go:196)。udpHop的interval小于 5:配置检查能通过,运行时 udpHop 报invalid interval,随后 panic。udpHop不写interval:Finalmask: Make "udpHop" a new UDP mask #6327 把 udpHop 改为 finalmask 时丢了原来 30 秒的默认值,同样在运行时报错并 panic。xicmp的服务端:ListenPacket出错后 panic。修改:
conn不为 nil 时才Close,失败时正常返回错误。udpHop不写interval时恢复默认 30 秒,interval小于 5 时在加载配置时报错。这两点是恢复 Finalmask: Make "udpHop" a new UDP mask #6327 之前的行为(原 hysteria udphop 的默认值和 infra/conf 里的检查),与文档一致,错误在启动时就能看到,而不是等到拨号。DialTCP、DialUDP、ListenPacket;以及udpHop的interval默认值与下限。验证(Linux):
xray -test);修复后,解析失败的连接正常报错、进程继续运行,interval为 2-3 时加载配置报错,不写interval时使用 30 秒,xicmp 服务端报operation not permitted后正常退出。go vet没有新增告警,go test ./...通过。