[GH-ISSUE #6433] [Bug]: The value in hosts does not work in the api output. #4356

Closed
opened 2026-10-31 20:39:04 +07:00 by bsakaguchi · 1 comment
Owner

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 hosts value is set in the panel, the configuration link correctly includes the specified hosts and related settings.

However, when retrieving the configuration via the /panel/api/clients/links/ endpoint, the response does not include or apply the configured hosts and 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

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
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 `hosts` value is set in the panel, the configuration link correctly includes the specified `hosts` and related settings. However, when retrieving the configuration via the `/panel/api/clients/links/` endpoint, the response does not include or apply the configured `hosts` and 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 ```shell ``` ### 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 - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:39:04 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@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) reaches LinkProvider.LinksForClient, which builds the link straight from the inbound:

// internal/sub/links.go:38-42
func (p *LinkProvider) LinksForClient(host string, inbound *model.Inbound, email string) []string {
	svc := p.build(host)
	svc.projectThroughFallbackMaster(inbound)
	return splitLinkLines(svc.GetLink(inbound, email))
}

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's streamSettings; Hosts are applied by cloning the inbound and injecting them into externalProxy (internal/sub/host_sub.go:216-234), which is a step this path skips.

Compare the subscription path, which does it correctly:

// internal/sub/service.go:320-333 (getSubs)
s.projectThroughFallbackMaster(inbound)
// Host overrides apply AFTER fallback projection so a host's
// address/TLS wins over the projected master stream.
hostEps := s.hostEndpoints(inbound, "raw")
for _, client := range clients {
	...
	if len(hostEps) > 0 {
		link = s.linkFromHosts(inbound, client, hostEps)
	} else {
		link = s.GetLink(inbound, client.Email)
	}

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). Only LinksForClient was 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 through getSubs and therefore applies Hosts.

Workaround until this is fixed

Both of these already render Hosts, so either can replace your current call:

# per client, by subId (same output the panel's QR modal shows)
curl -b cookie.txt "https://<panel>/<path>/panel/api/clients/subLinks/<subId>"

# every inbound, every client
curl -b cookie.txt "https://<panel>/<path>/panel/api/inbounds/allLinks"

Verdict: Confirmed bug
Severity: High
Confidence: High
Root cause: LinkProvider.LinksForClient in internal/sub/links.go:38-42 calls svc.GetLink(inbound, email) without the hostEndpoints/linkFromHosts branch that every other renderer uses, so managed Hosts are dropped for GET /panel/api/clients/links/:email. Triggered whenever the inbound has at least one enabled Host not excluded from the raw sub type (internal/sub/host_sub.go:19-39). Introduced by 709b332d ("feat(hosts): managed Hosts for per-host subscription link overrides (#5409)"), which wired Hosts into getSubs/JSON/Clash but left links.go on the plain GetLink path — git show 709b332d:internal/sub/links.go shows LinksForClient unchanged in that commit.
Already fixed: Still present on the default branch (HEAD a5e68f41, 2026-09-07); git log -- internal/sub/links.go shows no change since 439245d4 (2026-06-27).
Duplicate of: None
Evidence: internal/web/controller/client.go:54 g.GET("/links/:email", a.getClientLinks) → internal/web/service/inbound_sublink.go:59 registeredSubLinkProvider.LinksForClient(host, inbound, email) → internal/sub/links.go:41 return 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-234 linkFromHosts → injectExternalProxy. Panel-side contrast: frontend/src/pages/clients/ClientQrModal.tsx:130-131. No test covers LinksForClient (grep -rn "LinksForClient" --include=*_test.go returns nothing), so nothing pinned the omitted behaviour.
Not determined: Which protocol/transport you use — the gap is protocol-independent (it is missing before GetLink dispatches), 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 LinksForClient the same hostEndpoints(inbound, "raw") / linkFromHosts branch getSubs and inboundLinks already use, resolving the model.Client for email first. That keeps the zero-host fallback byte-identical, since linkFromHosts returns "" for empty endpoints by design.

@MHSanaei

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5574613085 --> @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`) reaches `LinkProvider.LinksForClient`, which builds the link straight from the inbound: ```go // internal/sub/links.go:38-42 func (p *LinkProvider) LinksForClient(host string, inbound *model.Inbound, email string) []string { svc := p.build(host) svc.projectThroughFallbackMaster(inbound) return splitLinkLines(svc.GetLink(inbound, email)) } ``` 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's `streamSettings`; Hosts are applied by cloning the inbound and injecting them into `externalProxy` (`internal/sub/host_sub.go:216-234`), which is a step this path skips. Compare the subscription path, which does it correctly: ```go // internal/sub/service.go:320-333 (getSubs) s.projectThroughFallbackMaster(inbound) // Host overrides apply AFTER fallback projection so a host's // address/TLS wins over the projected master stream. hostEps := s.hostEndpoints(inbound, "raw") for _, client := range clients { ... if len(hostEps) > 0 { link = s.linkFromHosts(inbound, client, hostEps) } else { link = s.GetLink(inbound, client.Email) } ``` 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`). Only `LinksForClient` was 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 through `getSubs` and therefore applies Hosts. ### Workaround until this is fixed Both of these already render Hosts, so either can replace your current call: ```bash # per client, by subId (same output the panel's QR modal shows) curl -b cookie.txt "https://<panel>/<path>/panel/api/clients/subLinks/<subId>" # every inbound, every client curl -b cookie.txt "https://<panel>/<path>/panel/api/inbounds/allLinks" ``` Verdict: Confirmed bug Severity: High Confidence: High Root cause: `LinkProvider.LinksForClient` in `internal/sub/links.go:38-42` calls `svc.GetLink(inbound, email)` without the `hostEndpoints`/`linkFromHosts` branch that every other renderer uses, so managed Hosts are dropped for `GET /panel/api/clients/links/:email`. Triggered whenever the inbound has at least one enabled Host not excluded from the `raw` sub type (`internal/sub/host_sub.go:19-39`). Introduced by `709b332d` ("feat(hosts): managed Hosts for per-host subscription link overrides (#5409)"), which wired Hosts into `getSubs`/JSON/Clash but left `links.go` on the plain `GetLink` path — `git show 709b332d:internal/sub/links.go` shows `LinksForClient` unchanged in that commit. Already fixed: Still present on the default branch (HEAD `a5e68f41`, 2026-09-07); `git log -- internal/sub/links.go` shows no change since `439245d4` (2026-06-27). Duplicate of: None Evidence: `internal/web/controller/client.go:54` `g.GET("/links/:email", a.getClientLinks)` → `internal/web/service/inbound_sublink.go:59` `registeredSubLinkProvider.LinksForClient(host, inbound, email)` → `internal/sub/links.go:41` `return 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-234` `linkFromHosts` → `injectExternalProxy`. Panel-side contrast: `frontend/src/pages/clients/ClientQrModal.tsx:130-131`. No test covers `LinksForClient` (`grep -rn "LinksForClient" --include=*_test.go` returns nothing), so nothing pinned the omitted behaviour. Not determined: Which protocol/transport you use — the gap is protocol-independent (it is missing before `GetLink` dispatches), 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 `LinksForClient` the same `hostEndpoints(inbound, "raw")` / `linkFromHosts` branch `getSubs` and `inboundLinks` already use, resolving the `model.Client` for `email` first. That keeps the zero-host fallback byte-identical, since `linkFromHosts` returns `""` for empty endpoints by design. @MHSanaei *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4356
No description provided.