mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6740] [MERGED] fix(sub): append host serverDescription to hysteria links #6438
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6438
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6740
Author: @AyaseEli-Bing
Created: 10/5/2026
Status: ✅ Merged
Merged: 10/5/2026
Merged by: @MHSanaei
Base:
main← Head:fix/sub-hysteria-server-description📝 Commits (2)
4bfbcf8fix(sub): append host serverDescription to hysteria links1439d59chore(sub): trim the hysteria serverDescription regression test📊 Changes
2 files changed (+62 additions, -1 deletions)
View changed files
➕
internal/sub/hysteria_server_description_test.go(+57 -0)📝
internal/sub/service.go(+5 -1)📄 Description
Summary
hysteria://andhysteria2://subscription links now carry the host's?serverDescription=<base64>suffix, the same wayvless://,trojan://andss://already do. Closes #6738.AI assistance disclosure: this change was produced by an AI coding agent (Qoder) at the request of the account owner, who reviewed the diff and the test.
CLAUDE.mddescribes itself as an "Operational guide for AI agents working in this repo", so I assumed agent-authored PRs are welcome here — flagging it explicitly so a reviewer can treat it accordingly. The commit itself is authored by the account owner.Why
A host attached to both a VLESS and a Hysteria2 inbound showed the custom caption on the VLESS line and the client default ("Hysteria | hysteria | TLS") on the Hysteria2 line, so Happ users saw inconsistent names for the same server.
Root cause:
genHysteriaLinkfans out overexternalProxyin its own loop and builds the fragment froms.endpointRemark(...), while the URL-param protocols go throughbuildEndpointLinks, which appendsappendHappServerDescriptionwhen the endpoint carries a description (internal/sub/endpoint.go:138-141). The description itself does reach the Hysteria path —host_sub.go:113-115puts it on the endpoint map — the loop just never read it.escapeLinkFragmentwas not the problem: it already keeps a valid?serverDescription=tail intact, which is why #6575's fix did not cover this.The fix reuses
appendHappServerDescriptionand theServerDescriptionthe endpoint map is already parsed into, so no key lookup is duplicated. A host without a description emits byte-identical output (appendHappServerDescriptionreturns the remark unchanged for an empty description).Type of change
Areas affected
How was this tested?
TDD, following
CLAUDE.md(red → green → prove the test can fail):internal/sub/hysteria_server_description_test.gofirst and ran it against unmodified code — both sub-cases failed with exactly the reported symptom,hysteria2://secret@hy.example.com:443?security=tls#hy-Poland-usermissing the suffix.?serverDescription=V2ktRmk=(base64 ofWi-Fi, taken from the reporter's own subscription output) and the scheme prefix, so ahysteria://(v1) and ahysteria2://(v2) link are both covered.internal/sub/service.goand re-ran: the test goes red again with "host serverDescription missing from fragment", then restored it. The test is not a stand-in — it fails without the change.externalProxyentry with no host description must not gain aserverDescriptionparam and must keephysteria2://secret@cdn.example.com:8443.Commands run locally (go1.27.1, CGO_ENABLED=1, macOS arm64):
make lint-go→golangci-lint run→0 issues.make test-go→ full Go suite, 49 packagesok, no failures (includesinternal/sub's characterization tests, which pin existing hysteria output).CGO_ENABLED=1 go test ./internal/sub/alone: ok.Not run locally, and CI covers them: the frontend gates of
make verify(gen-check,lint-fe,typecheck) — this change adds no route, model or type, so the generated Zod/OpenAPI artifacts are unaffected; alsomake race, the Postgres job and the live master+node e2e (XUI_NODE_E2E_BINARY). I did not run a live panel with a real Happ client; the unit tests reproduce the reporter's exact link shape instead.One thing I deliberately left out
genTuicLink(internal/sub/service.go:912) has the identical gap: its ownexternalProxyloop renders the fragment throughendpointRemarkwithout appending the description, sotuic://links lose the host description the same way. I kept it out to leave this diff to the reported protocol — say the word and I will fold it into this PR or send a separate one.Breaking changes
None. Only an added URI fragment on links whose host has a Description set; clients that already parsed the suffix for VLESS parse it the same way here.
Checklist
go build ./...and the test suite pass locally. (make test-gogreen;go build ./...clean)npm run lint,npm run typecheck, andnpm run buildpass. — N/A, no frontend files touched.serverDescriptionbehavior rather than changing it; no API surface moved.fix(sub): …, conventional commit with a why-body)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.