mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6433] [Bug]: The value in hosts does not work in the api output. #4356
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#4356
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?
Originally created by @koloner on GitHub (Sep 7, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6433
Describe the bug
When the
hostsvalue is set in the panel, the configuration link correctly includes the specifiedhostsand related settings.However, when retrieving the configuration via the
/panel/api/clients/links/endpoint, the response does not include or apply the configuredhostsand related settings. The returned configuration appears to use the default values instead.The configuration returned by
/panel/api/clients/links/should be consistent with the configuration link generated by the panel.How to reproduce the problem
curl to /panel/api/clients/links/email
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.7.0
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
ubuntu 24
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Sep 7, 2026):
Confirmed — this is a real bug, and it is still present on the default branch.
/panel/api/clients/links/{email}is the one link-producing path in the panel that never consults managed Hosts; every other one does, which is why the panel UI shows the correct host-based links and this endpoint does not.Where it goes wrong
GET /panel/api/clients/links/:email(internal/web/controller/client.go:54) reachesLinkProvider.LinksForClient, which builds the link straight from the inbound:There is no
hostEndpoints(...)/linkFromHosts(...)call anywhere in that function, so the inbound's own address, port, SNI, host header and path are used — the "default values" you saw.GetLink(internal/sub/service.go:629) only reads the inbound'sstreamSettings; Hosts are applied by cloning the inbound and injecting them intoexternalProxy(internal/sub/host_sub.go:216-234), which is a step this path skips.Compare the subscription path, which does it correctly:
The same branch exists in
inboundLinks(internal/sub/service.go:380-394, backing/panel/api/inbounds/allLinks), in the JSON renderer (internal/sub/json_service.go:96) and in the Clash renderer (internal/sub/clash_service.go:51). OnlyLinksForClientwas left out.That also explains the asymmetry you describe with the panel: the client QR/links modal does not call this endpoint — it calls
/panel/api/clients/subLinks/{subId}(frontend/src/pages/clients/ClientQrModal.tsx:130-131), which goes throughgetSubsand therefore applies Hosts.Workaround until this is fixed
Both of these already render Hosts, so either can replace your current call:
Verdict: Confirmed bug
Severity: High
Confidence: High
Root cause:
LinkProvider.LinksForClientininternal/sub/links.go:38-42callssvc.GetLink(inbound, email)without thehostEndpoints/linkFromHostsbranch that every other renderer uses, so managed Hosts are dropped forGET /panel/api/clients/links/:email. Triggered whenever the inbound has at least one enabled Host not excluded from therawsub type (internal/sub/host_sub.go:19-39). Introduced by709b332d("feat(hosts): managed Hosts for per-host subscription link overrides (#5409)"), which wired Hosts intogetSubs/JSON/Clash but leftlinks.goon the plainGetLinkpath —git show 709b332d:internal/sub/links.goshowsLinksForClientunchanged in that commit.Already fixed: Still present on the default branch (HEAD
a5e68f41, 2026-09-07);git log -- internal/sub/links.goshows no change since439245d4(2026-06-27).Duplicate of: None
Evidence:
internal/web/controller/client.go:54g.GET("/links/:email", a.getClientLinks)→internal/web/service/inbound_sublink.go:59registeredSubLinkProvider.LinksForClient(host, inbound, email)→internal/sub/links.go:41return splitLinkLines(svc.GetLink(inbound, email))(no host lookup). Working counterparts:internal/sub/service.go:323+:330,internal/sub/service.go:380+:391,internal/sub/json_service.go:96,internal/sub/clash_service.go:51. Host injection helper:internal/sub/host_sub.go:216-234linkFromHosts→injectExternalProxy. Panel-side contrast:frontend/src/pages/clients/ClientQrModal.tsx:130-131. No test coversLinksForClient(grep -rn "LinksForClient" --include=*_test.goreturns nothing), so nothing pinned the omitted behaviour.Not determined: Which protocol/transport you use — the gap is protocol-independent (it is missing before
GetLinkdispatches), so this does not change the verdict. If your Hosts are all marked "exclude from raw" (ExcludeFromSubTypes,internal/sub/host_sub.go:34) they would be skipped on the subscription path too, but you report the panel link is correct, which rules that out.Suggested fix: give
LinksForClientthe samehostEndpoints(inbound, "raw")/linkFromHostsbranchgetSubsandinboundLinksalready use, resolving themodel.Clientforemailfirst. That keeps the zero-host fallback byte-identical, sincelinkFromHostsreturns""for empty endpoints by design.@MHSanaei
This reply was generated automatically; a maintainer may follow up.