Skip to content

Comments

XHTTP transport: Fix "auto" mode with REALITY#5638

Merged
RPRX merged 3 commits intoXTLS:mainfrom
paqx:fix/xhttp-with-reality
Feb 2, 2026
Merged

XHTTP transport: Fix "auto" mode with REALITY#5638
RPRX merged 3 commits intoXTLS:mainfrom
paqx:fix/xhttp-with-reality

Conversation

@paqx
Copy link
Contributor

@paqx paqx commented Feb 1, 2026

Fix for issue #5635

Cause

The cause is described in detail in the above issue.

Fix

I rewrote the logic that defines when a session ID should be added to the request based on the XHTTP mode and security settings.

@Fangliding
Copy link
Member

你可以解释一下为什么解析auto的逻辑就在下面几行你还要在上面重新再写一遍吗

@lyd123qw2008
Copy link

这个 PR 修复了 REALITY + XHTTP 的 auto 场景,但现在 sessionId 的生成逻辑依赖 streamSettings.SecurityType,会引入新的回归:

  1. auto + TLS(非 REALITY)
    SecurityType 非空 → 不生成 sessionId,
    但 auto 解析仍是 packet-up(因为 realityConfig==nil),packet‑up 必须有 sessionId,可能直接失败。
  2. auto + REALITY + downloadSettings
    auto 在现实中会解析为 stream-up,但这里仍强制 sessionId=false,stream-up 也需要 sessionId。

建议:先解析最终 mode,再决定是否生成 sessionId(mode==stream-one 才不生成),或至少使用 realityConfig != nil + downloadSettings 来判断,而不是 SecurityType。
@paqx 你参考一下

@Fangliding
Copy link
Member

。。。

@lyd123qw2008
Copy link

lyd123qw2008 commented Feb 1, 2026

这个 PR 修复了 REALITY + XHTTP 的 auto 场景,但现在 sessionId 的生成逻辑依赖 streamSettings.SecurityType,会引入新的回归:

  1. auto + TLS(非 REALITY)
    SecurityType 非空 → 不生成 sessionId,
    但 auto 解析仍是 packet-up(因为 realityConfig==nil),packet‑up 必须有 sessionId,可能直接失败。
  2. auto + REALITY + downloadSettings
    auto 在现实中会解析为 stream-up,但这里仍强制 sessionId=false,stream-up 也需要 sessionId。

建议:先解析最终 mode,再决定是否生成 sessionId(mode==stream-one 才不生成),或至少使用 realityConfig != nil + downloadSettings 来判断,而不是 SecurityType。 @paqx 你参考一下

我建议把 sessionId 的生成逻辑改为 基于“最终解析后的 mode”,而不是基于 SecurityType。
当前 PR 的逻辑在 auto + TLS 和 auto + REALITY + downloadSettings 场景会产生回归(sessionId 不生成但最终 mode 需要它)。

建议修改(核心思路):

  1. 先解析 mode(auto → stream-one / stream-up / packet-up)
  2. 再决定 sessionId(只有 stream-one 不生成)

示意代码(仅示意):

  mode := transportConfiguration.Mode
  if mode == "" || mode == "auto" {
      mode = "packet-up"
      if realityConfig != nil {
          mode = "stream-one"
          if transportConfiguration.DownloadSettings != nil {
              mode = "stream-up"
          }
      }
  }

  sessionId := ""
  if mode != "stream-one" {
      sessionId = uuid.New().String()
  }

这样可以同时修复:

  • auto + REALITY(你当前修复目标)
  • auto + TLS(避免新回归)
  • auto + REALITY + downloadSettings(避免新回归)

@paqx

@paqx paqx force-pushed the fix/xhttp-with-reality branch from 0376ced to 575c910 Compare February 1, 2026 16:23
@paqx
Copy link
Contributor Author

paqx commented Feb 1, 2026

@lyd123qw2008

Thanks a lot for your suggestions and help. I updated the commit. Tested your approach on different configurations of XHTTP and XHTTP+REALITY (haven't tested other options like TLS). Works correctly.

@Fangliding
Copy link
Member

#5634 也放这里头吧

@paqx
Copy link
Contributor Author

paqx commented Feb 1, 2026

Done.

@RPRX RPRX changed the title Fix: XHTTP with REALITY XHTTP transport: Fix "auto" mode with REALITY Feb 2, 2026
@RPRX RPRX merged commit a6ec3b6 into XTLS:main Feb 2, 2026
42 of 43 checks passed
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.

4 participants