[GH-ISSUE #6435] [Feature]: Hide an inbound from subscription output without disabling it #4355

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

Originally created by @Motokichirou on GitHub (Sep 8, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6435

Problem

Subscription output emits one link per (inbound, client) pair. In a multi-node
high-availability setup this produces duplicate, functionally identical endpoints that
clients do not need to see.

Scenario

A relay sits in front of two exit nodes. Failover happens at the relay (it rewrites its
forwarding target when an exit becomes unreachable), not in the client — because in a
whitelisted network the client has exactly one reachable entry point and cannot choose.

For that failover to be transparent, both exits must carry an identical REALITY identity:
same private/public key, same shortIds, same serverNames/target, same client UUIDs. Otherwise
switching breaks authentication instead of preserving it.

Since an inbound belongs to a single node (node_id), covering two nodes requires two inbounds
per identity. With two identities that is four REALITY inbounds, and the subscription therefore
contains four REALITY links where two would be enough — the node clones are pure duplicates from
the client's point of view.

Why the existing options don't help

  • Enable = false hides the inbound from the subscription, but also stops it serving
    traffic. Clients must stay attached to the clone for authentication to work after failover, so
    this is not usable.
  • Hosts have excludeFromSubTypes and an is_hidden column, but those govern the extra
    links a host contributes, not the inbound's own link.
  • The Inbound model has Enable, SubSortIndex, ShareAddrStrategy, ShareAddr and
    DisableFlow — there is no equivalent visibility switch.

Proposal

A per-inbound boolean, e.g. hideFromSub / excludeFromSub, that keeps the inbound fully
operational (Xray config, client auth, traffic accounting) while omitting its links from
subscription output.

This mirrors what hosts already have, and would let operators keep redundant backing inbounds
for failover without cluttering what end users see.

Workarounds considered

  • SubSortIndex only reorders links, it cannot remove them.
  • Managing the standby node's Xray config outside the panel would hide the links but gives up
    central management, node sync and traffic accounting — which is the reason to use nodes at all.

Version

Panel 3.7.0, Xray 26.7.28, SQLite backend, one master + one node.

Originally created by @Motokichirou on GitHub (Sep 8, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6435 ### Problem Subscription output emits one link per `(inbound, client)` pair. In a multi-node high-availability setup this produces duplicate, functionally identical endpoints that clients do not need to see. ### Scenario A relay sits in front of two exit nodes. Failover happens at the relay (it rewrites its forwarding target when an exit becomes unreachable), not in the client — because in a whitelisted network the client has exactly one reachable entry point and cannot choose. For that failover to be transparent, both exits must carry an **identical REALITY identity**: same private/public key, same shortIds, same serverNames/target, same client UUIDs. Otherwise switching breaks authentication instead of preserving it. Since an inbound belongs to a single node (`node_id`), covering two nodes requires two inbounds per identity. With two identities that is four REALITY inbounds, and the subscription therefore contains four REALITY links where two would be enough — the node clones are pure duplicates from the client's point of view. ### Why the existing options don't help - **`Enable = false`** hides the inbound from the subscription, but also stops it serving traffic. Clients must stay attached to the clone for authentication to work after failover, so this is not usable. - **Hosts** have `excludeFromSubTypes` and an `is_hidden` column, but those govern the extra links a host contributes, not the inbound's own link. - The `Inbound` model has `Enable`, `SubSortIndex`, `ShareAddrStrategy`, `ShareAddr` and `DisableFlow` — there is no equivalent visibility switch. ### Proposal A per-inbound boolean, e.g. `hideFromSub` / `excludeFromSub`, that keeps the inbound fully operational (Xray config, client auth, traffic accounting) while omitting its links from subscription output. This mirrors what hosts already have, and would let operators keep redundant backing inbounds for failover without cluttering what end users see. ### Workarounds considered - `SubSortIndex` only reorders links, it cannot remove them. - Managing the standby node's Xray config outside the panel would hide the links but gives up central management, node sync and traffic accounting — which is the reason to use nodes at all. ### Version Panel 3.7.0, Xray 26.7.28, SQLite backend, one master + one node.
bsakaguchi 2026-10-31 20:39:04 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Sep 8, 2026):

Your reading of the code is correct: there is no per-inbound subscription-visibility switch on the default branch, Enable is the only per-inbound gate the subscription honours, and hosts cannot substitute for one. This is a valid feature request. There is also a workaround that works today without any code change — it is at the bottom.

What the source says

1. The inbound set is chosen by exactly two conditions. getInboundsBySubId (internal/sub/service.go:577) is the only place that decides which inbounds a subscription contains:

	WHERE
		inbounds.protocol in ('vmess','vless','trojan','shadowsocks','hysteria','wireguard','amneziawg','mtproto')
		AND clients.sub_id = ? AND inbounds.enable = ?

internal/sub/service.go:585-588

Protocol, and enable. Nothing else. Your list of Inbound fields is complete — SubSortIndex (internal/database/model/model.go:54), Enable (:55), ShareAddrStrategy/ShareAddr (:71-72) and DisableFlow (:74) are all there is, and none of them removes a link.

2. Hosts genuinely cannot do it, for the reason you suspected plus one more. hostEndpoints filters on is_disabled and ExcludeFromSubTypes (internal/sub/host_sub.go:22, :34), but every caller falls back to the plain inbound link when the filtered list comes back empty:

			if len(hostEps) > 0 {
				link = s.linkFromHosts(inbound, client, hostEps)
			} else {
				link = s.GetLink(inbound, client.Email)
			}

internal/sub/service.go:411-415; same shape at internal/sub/json_service.go:97-99 and internal/sub/clash_service.go:53-55

So excluding an inbound's every host from raw, json and clash does not silence the inbound — it just makes it emit its own link instead. That fallback is deliberate and documented in the function comment at internal/sub/host_sub.go:13-18 ("preserving byte-identical output for zero-host inbounds"), so it is not a bug to be exploited.

3. Host.IsHidden is not the analogue you thought it was. The column exists (internal/database/model/model.go:1073) and is mapped in both directions (internal/web/service/host.go:39, :126), but no subscription renderer reads it — hostEndpoints filters on is_disabled only — and the host form carries it purely as a default value (frontend/src/pages/hosts/HostFormModal.tsx:50) with no control bound to it. It is stored and currently unused.

Workaround available today

Because the join is on clients.sub_id, an inbound whose clients all carry a different subId never enters the loop at all — matchingClients returns nothing and the inbound is skipped at internal/sub/service.go:398-401.

The catch you have hit is that SubID lives on the client row (ClientRecord.SubID, internal/database/model/model.go:919), and client_inbounds (:998-1005) attaches one identity to many inbounds — so attaching the same client to both the primary and the standby inbound necessarily shares one subId.

So instead of attaching the same client, give the standby clone its own client row carrying the same credential:

  1. On the standby inbound, create a new client and paste the primary's UUID into the id field. An explicitly supplied id is kept — fillProtocolDefaults only mints a fresh one when it is empty (internal/web/service/client_crud.go:387-390). Do the same for password/auth on Trojan/Shadowsocks/Hysteria.
  2. Give it a different email (that column is uniqueIndex, internal/database/model/model.go:918) and let the panel generate its subId — reusing the primary's is rejected with subId already in use (internal/web/service/client_crud.go:192-201).

The standby then keeps serving with an identical REALITY identity and the UUID your relay's failover depends on, while contributing nothing to the user's subscription.

Trade-offs, so you can judge whether it is worth it:

  • Traffic, quota and expiry are per client row, so the standby's usage accrues under the second email and is not included in the primary subscription's userinfo header (internal/sub/service.go:601-607 indexes stats by sub_id). Limits have to be maintained in two places.
  • Use "create client", not "attach existing client to inbound" — attaching reuses the one identity and its subId, which is exactly the case that produces the duplicate link.

I derived this from the query and validation code above; I cannot run the panel here, so I have not exercised it through the UI.

For the maintainer

The request is one boolean and one clause. The gate is a single WHERE at internal/sub/service.go:585-588; adding a column would also need a hand-written migration in internal/database/db.go per the repo's DB rules. Nothing about the ask conflicts with the existing host-level ExcludeFromSubTypes design — as the reporter notes, that axis governs the extra endpoints a host contributes, not whether the inbound itself is advertised. Related, not a duplicate: #4945 (disabled nodes still appearing in subscriptions) — different trigger, and it wants the inbound stopped, not kept alive.

I have labelled this enhancement. No searched issue shares this root cause, so it stays open.

Verdict: Feature request

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

<!-- gh-comment-id:5592653285 --> @github-actions[bot] commented on GitHub (Sep 8, 2026): Your reading of the code is correct: there is no per-inbound subscription-visibility switch on the default branch, `Enable` is the only per-inbound gate the subscription honours, and hosts cannot substitute for one. This is a valid feature request. There is also a workaround that works today without any code change — it is at the bottom. ## What the source says **1. The inbound set is chosen by exactly two conditions.** `getInboundsBySubId` (`internal/sub/service.go:577`) is the only place that decides which inbounds a subscription contains: ```go WHERE inbounds.protocol in ('vmess','vless','trojan','shadowsocks','hysteria','wireguard','amneziawg','mtproto') AND clients.sub_id = ? AND inbounds.enable = ? ``` <sub>`internal/sub/service.go:585-588`</sub> Protocol, and `enable`. Nothing else. Your list of `Inbound` fields is complete — `SubSortIndex` (`internal/database/model/model.go:54`), `Enable` (`:55`), `ShareAddrStrategy`/`ShareAddr` (`:71-72`) and `DisableFlow` (`:74`) are all there is, and none of them removes a link. **2. Hosts genuinely cannot do it, for the reason you suspected plus one more.** `hostEndpoints` filters on `is_disabled` and `ExcludeFromSubTypes` (`internal/sub/host_sub.go:22`, `:34`), but every caller falls back to the plain inbound link when the filtered list comes back empty: ```go if len(hostEps) > 0 { link = s.linkFromHosts(inbound, client, hostEps) } else { link = s.GetLink(inbound, client.Email) } ``` <sub>`internal/sub/service.go:411-415`; same shape at `internal/sub/json_service.go:97-99` and `internal/sub/clash_service.go:53-55`</sub> So excluding an inbound's every host from `raw`, `json` *and* `clash` does not silence the inbound — it just makes it emit its own link instead. That fallback is deliberate and documented in the function comment at `internal/sub/host_sub.go:13-18` ("preserving byte-identical output for zero-host inbounds"), so it is not a bug to be exploited. **3. `Host.IsHidden` is not the analogue you thought it was.** The column exists (`internal/database/model/model.go:1073`) and is mapped in both directions (`internal/web/service/host.go:39`, `:126`), but no subscription renderer reads it — `hostEndpoints` filters on `is_disabled` only — and the host form carries it purely as a default value (`frontend/src/pages/hosts/HostFormModal.tsx:50`) with no control bound to it. It is stored and currently unused. ## Workaround available today Because the join is on `clients.sub_id`, an inbound whose clients all carry a *different* `subId` never enters the loop at all — `matchingClients` returns nothing and the inbound is skipped at `internal/sub/service.go:398-401`. The catch you have hit is that `SubID` lives on the **client** row (`ClientRecord.SubID`, `internal/database/model/model.go:919`), and `client_inbounds` (`:998-1005`) attaches *one* identity to many inbounds — so attaching the same client to both the primary and the standby inbound necessarily shares one `subId`. So instead of attaching the same client, give the standby clone its **own client row carrying the same credential**: 1. On the standby inbound, create a new client and paste the primary's UUID into the id field. An explicitly supplied id is kept — `fillProtocolDefaults` only mints a fresh one when it is empty (`internal/web/service/client_crud.go:387-390`). Do the same for `password`/`auth` on Trojan/Shadowsocks/Hysteria. 2. Give it a different `email` (that column is `uniqueIndex`, `internal/database/model/model.go:918`) and let the panel generate its `subId` — reusing the primary's is rejected with `subId already in use` (`internal/web/service/client_crud.go:192-201`). The standby then keeps serving with an identical REALITY identity and the UUID your relay's failover depends on, while contributing nothing to the user's subscription. Trade-offs, so you can judge whether it is worth it: - Traffic, quota and expiry are per client row, so the standby's usage accrues under the second email and is **not** included in the primary subscription's userinfo header (`internal/sub/service.go:601-607` indexes stats by `sub_id`). Limits have to be maintained in two places. - Use "create client", not "attach existing client to inbound" — attaching reuses the one identity and its `subId`, which is exactly the case that produces the duplicate link. I derived this from the query and validation code above; I cannot run the panel here, so I have not exercised it through the UI. ## For the maintainer The request is one boolean and one clause. The gate is a single `WHERE` at `internal/sub/service.go:585-588`; adding a column would also need a hand-written migration in `internal/database/db.go` per the repo's DB rules. Nothing about the ask conflicts with the existing host-level `ExcludeFromSubTypes` design — as the reporter notes, that axis governs the extra endpoints a host contributes, not whether the inbound itself is advertised. Related, not a duplicate: #4945 (disabled *nodes* still appearing in subscriptions) — different trigger, and it wants the inbound stopped, not kept alive. I have labelled this `enhancement`. No searched issue shares this root cause, so it stays open. Verdict: Feature request *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#4355
No description provided.