DanielLavrushin:b4 Telegram 连接测试串行检查导致长时间等待

DanielLavrushin 记录,b4 Telegram 测试逐条拨号并等待观察,上游计划含二十二条路由时,全部成功也约需四十八秒,失败会更久。作者提出最多三路并发、整轮约三十秒期限、未测完单列为未测试,并保持结果顺序;这些仍是提案。

作者原文

Check connection and Direct TCP on the Telegram page call POST /api/mtproto/test-ws, which tests the routes of the upstream plan one after another (obfuscated2.go#L784-L794). Each test dials the route (up to 3 s, #L50-L53), completes the obfuscation, then holds the connection for 2 s to see that the far end does not close it (#L796-L831).

With the Cloudflare reserve on, a reported run for DC 2 had 22 routes: about 48 s when every route works, and longer as soon as some of them time out. The page shows nothing until the whole run ends (MTProtoUpstream.tsx#L162-L198). A user reported the request running past a 55 s limit on their side. b4's web server sets no write timeout, so in the web UI the button just spins.

Proposal

  • Test the routes in parallel with a small bound, the one client sessions already use when they race their routes: 3 in flight (dialrace.go#L10-L11). A 22-route run then takes about 18 s when every route works and about 24 s when every dial times out. Keeping the session bound also keeps the burst of TLS handshakes towards Cloudflare no larger than real traffic produces.
  • One deadline over the whole run, for example 30 s. A route not tested by then is reported as not tested, not as failed.
  • Results keep the order of the plan, so the list reads as it does today.

A pool where nothing works then fails in seconds rather than after a walk through every domain, which was the other half of the request.

Possible follow-up

Send each result to the page as it finishes, so a long run shows progress.