Skip to content

HTTPUpgrade client: Close the connection when the upgrade fails - #7395

Merged
RPRX merged 1 commit into
mainfrom
fix-httpupgrade-close-conn
Nov 21, 2026
Merged

RPRX merged 1 commit into
mainfrom
fix-httpupgrade-close-conn

Conversation

@patterniha

Copy link
Copy Markdown
Collaborator

When the upgrade request could not be sent, or the server did not answer with a valid "101 Switching Protocols", the dial returned the error and left the TCP connection open until the garbage collector closed it.

With "fingerprint": "unsafe", a failed TLS handshake is one of these cases. Go's TLS does the handshake at the first write, and here the first write is the upgrade request.

When the upgrade request could not be sent, or the server did not answer
with a valid "101 Switching Protocols", the dial returned the error and left
the TCP connection open until the garbage collector closed it.

With "fingerprint": "unsafe", a failed TLS handshake is one of these cases.
Go's TLS does the handshake at the first write, and here the first write is
the upgrade request.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
patterniha added a commit to patterniha/Xray-core that referenced this pull request Nov 13, 2026
HTTPUpgrade client: Close the connection when the upgrade fails

Co-authored-by: Copilot <[email protected]>
@RPRXX
RPRXX force-pushed the main branch 2 times, most recently from 9ade89d to 5d17b87 Compare November 14, 2026 15:58
@Fangliding

Copy link
Copy Markdown
Member

我记得这种问题不止一处 返回了err忘记关的 顺便都补一下吧

@RPRX
RPRX merged commit 3dee851 into main Nov 21, 2026
34 of 35 checks passed
@RPRX
RPRX deleted the fix-httpupgrade-close-conn branch November 21, 2026 20:45
Medium1992 added a commit to Medium1992/xray-proxy-ros that referenced this pull request Nov 22, 2026
XTLS/Xray-core#7395 (3dee8518) took two hunks of patches/close upstream:
conn.Close() after a failed upgrade request and read in the HTTPUpgrade
dialer. On upstream main the patch no longer applied and the alpha build
stopped at the half-close step. With --3way a hunk that is already
upstream merges as is, so the same patch serves v26.11.9 and main.

Checked by replaying every series as Dockerfile-release does and building
on v26.11.9 and on 74cbdf46.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
patterniha added a commit to patterniha/Xray-core that referenced this pull request Nov 22, 2026
Brings in XTLS/Xray-core up to 74cbdf4 (4 commits). XTLS's version is
unchanged, so the fork's core/core.go stays 26.11.22. Includes: XMC
finalmask Yggdrasil third-party login and texture verification (XTLS#7416),
outbounds avoiding circular dependencies with the built-in DNS (XTLS#7425),
the HTTPUpgrade client closing the connection when the upgrade fails
(XTLS#7395) and a README update (XTLS#7446).

No conflicts. XTLS#7395 is identical to the fork's early merge of it
(cbf3dac), so transport/internet/httpupgrade/dialer.go is unchanged.
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.

3 participants