Repository navigation
Direct/Freedom outbound: Fix blockDelay for DispatchLink() inbounds such as VLESS, Hysteria, etc. - #7238
Conversation
… (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.
e0da81a to
29fe9cb
Compare
|
改用 time.After |
|
switched to |
Meo597
left a comment
There was a problem hiding this comment.
单看黑洞效果和以前是相同的,修的其实是如果客户端静默断开了,connIdle 又没生效,保证到期后强制回收掉连接。
|
再回来看看还是觉得很抽象 |
should I drop the Interrupt call there? it doesnt do anything for these inbounds anyway |
|
No, they each have their own purpose. Keep it as it is. |
blockDelay (VLESS, Hysteria, etc.)blockDelay for DispatchLink() inbounds such as VLESS, Hysteria, etc.
|
@Meo597 Block/Blackhole 出站该并入 Direct/Freedom 出站了,无条件的 "block" 不解析/拨号,也方便用户熟悉 |
|
|
客户端静默断开会导致 buf.Copy 一直阻塞 现在把 buf.Copy 放到协程
|
|
你之前觉得 #6060 (comment) |
如果用户去配了这个特殊黑洞的 finalrules 呢 |
不过 #7238 (comment) 更重要,更大的好处是用户都会知道
走现行常规流程, 话说我依稀记得单写 "allow" 就有特殊处理,这个单写 "block" 是类似的,特殊处理一下就能取代 Block/Blackhole 出站,写吧 |
|
对了,还需要加个选项 |
|
或许开个新的出站类型,专门用来伪造各种响应之类的 finalRules 的黑洞就保持简单? |
重构的事儿再说吧,相信后 AI 的智慧 Blackhole 比较好弄,我先把这个做了 |
…y` to `firewall`; Merge Block/Blackhole outbound; Move `proxyProtocol` to "proxy-protocol" TCP finalmask (#7281) #7238 (comment) #7281 (comment) #7281 (comment) #7281 (comment) #7329 (comment) #7329 (comment) #7329 (comment) #7281 (comment) #7281 (comment) #7281 (comment) --------- Co-authored-by: Codex <[email protected]>
Regression from #6060 (958eb9e).
blackholewaits forbuf.Copy(input, buf.Discard)and relies on theblockDelaytimer callingcommon.Interrupt(input)to end it. That only works for a pipe: VLESS, Hysteria and other inbounds that useDispatchLinkpass a reader on the client connection, andInterruptdoes nothing to it. So a blocked connection stays open until the client closes it, whateverblockDelayis. In our tests it was still open after 330 s, longer thanconnIdle.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.
TestVlessBlockDelaycoversblockDelay0 and 1 through a VLESS inbound. Both cases fail on main.