镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Direct/Freedom outbound: Close blocked connections after blockDelay (VLESS, Hysteria, etc.) - #7238

Open
solodecode wants to merge 2 commits into
XTLS:mainfrom
solodecode:freedom-block-delay
Open

solodecode wants to merge 2 commits into
XTLS:mainfrom
solodecode:freedom-block-delay

Conversation

@solodecode

Copy link
Copy Markdown

Regression from #6060 (958eb9e). blackhole waits for buf.Copy(input, buf.Discard) and relies on the blockDelay timer calling common.Interrupt(input) to end it. That only works for a pipe: VLESS, Hysteria and other inbounds that use DispatchLink pass a reader on the client connection, and Interrupt does nothing to it. So a blocked connection stays open until the client closes it, whatever blockDelay is. In our tests it was still open after 330 s, longer than connIdle.

Drain the input in a goroutine and return once the delay has passed or the input has ended. The inbound then closes the connection, as it does after the blackhole outbound.

TestVlessBlockDelay covers blockDelay 0 and 1 through a VLESS inbound. Both cases fail on main.

… (VLESS, Hysteria, etc.)

blackhole waited for buf.Copy(input, buf.Discard) and relied on the
blockDelay timer calling common.Interrupt(input) to end it. Inbounds that
call DispatchLink (VLESS, Hysteria, SOCKS, HTTP CONNECT, dokodemo-door,
TUN, WireGuard, MASQUE) pass a reader on the client connection, which
Interrupt does not stop, so a blocked connection stayed open until the
client closed it.

Drain the input in a goroutine and return once the delay has passed or
the input has ended. The inbound then closes the client connection.
@Meo597

Meo597 commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

改用 time.After

@solodecode

solodecode commented Oct 23, 2026 •

Copy link
Copy Markdown
Author

switched to time.After

@Meo597 Meo597 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

单看黑洞效果和以前是相同的,修的其实是如果客户端静默断开了,connIdle 又没生效,保证到期后强制回收掉连接。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants