[GH-ISSUE #6029] Subscription: {{EMAIL}} in remark only shown on a client's first link, not every inbound/node #4174

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

Originally created by @acidmsg on GitHub (Jul 18, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6029

Description

In a multi-node setup, subscription links for node-hosted inbounds are generated without the client email in the remark, while master-hosted inbounds include it correctly.

Steps to reproduce

  1. Master panel + node panel (both v3.5.0)
  2. Remark template set to include {{EMAIL}}
  3. subEmailInRemark: true on both panels
  4. Generate subscription for a client attached to both master and node inbounds

Actual result

Master inbound link includes email in remark.
Node inbound link does NOT include email — only inbound name.

Expected result

Both master and node inbound links include email in remark.

Environment

  • 3x-ui v3.5.0
  • Master + 1 node
Originally created by @acidmsg on GitHub (Jul 18, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6029 ## Description In a multi-node setup, subscription links for node-hosted inbounds are generated without the client email in the remark, while master-hosted inbounds include it correctly. ## Steps to reproduce 1. Master panel + node panel (both v3.5.0) 2. Remark template set to include `{{EMAIL}}` 3. `subEmailInRemark: true` on both panels 4. Generate subscription for a client attached to both master and node inbounds ## Actual result Master inbound link includes email in remark. Node inbound link does NOT include email — only inbound name. ## Expected result Both master and node inbound links include email in remark. ## Environment - 3x-ui v3.5.0 - Master + 1 node
bsakaguchi 2026-10-31 20:37:44 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Jul 18, 2026):

This is expected behavior, not a defect specific to node-hosted inbounds — closing as not planned, with the reasoning below. I've also retitled the issue since the original title attributes this to node-hosting specifically, which isn't the actual cause.

Root cause

{{EMAIL}} (and {{USERNAME}}) is deliberately emitted only on a client's first link within a subscription response; it is stripped from every link generated after that for the same client, regardless of which inbound — master or node — produces it:

  • firstLinkOnlyBodyTokens in internal/sub/remark_vars.go:484-491 lists EMAIL/USERNAME alongside the usage tokens as tokens dropped "from every subscription-body link after a client's first one."
  • effectiveTemplate (internal/sub/remark_vars.go:557-567) tracks this per email via s.usageShown: the first call for a given email returns the full template; every later call for that same email returns the filtered one.
  • This only applies to the actual content a client app fetches (raw /sub/, /json/, /clash/) — see the doc comment on SubService.subscriptionBody, internal/sub/service.go:34-39: "the remark template's per-client info is emitted there (on the first link); every other context ... renders the name-only template."
  • It's covered by an explicit test, TestIdentityTokenBodyVsDisplay (internal/sub/remark_vars_test.go:377-397), which asserts that a second call for the same client (even on the same single inbound) drops {{EMAIL}}. This confirms the dedup is about link order within the subscription, not master vs. node.

Why it looked node-specific

Node-hosted inbounds are not served through a separate code path. They are ordinary rows in the master panel's own inbounds table — NodeID is just a nullable FK (internal/database/model/model.go:68) — and getInboundsBySubId (internal/sub/service.go:459-476) pulls every inbound attached to the client's subscription, master- and node-hosted alike, in one query ordered sub_sort_index ASC, id ASC. One SubService instance then generates every link for that subscription, sharing a single usageShown map. Whichever inbound sorts first for that client keeps {{EMAIL}}; every later one loses it. In your setup the master inbound apparently sorts ahead of the node inbound (lower Sub Sort Index or ID) — the same thing would happen with two ordinary inbounds on the master alone if one client were attached to both. NodeID plays no role in remark generation; it's only used to resolve the link's host address (resolveInboundAddress, internal/sub/service.go:1139-1156).

On subEmailInRemark

That exact setting name does not exist in v3.5.0. The current mechanism is the free-form remarkTemplate setting (Panel → Settings → Subscription), using the {{EMAIL}} token — which is what you're already using correctly. There is no toggle today to force {{EMAIL}} onto every link of a multi-inbound/multi-node subscription; the first-link-only rule was added specifically to stop the email repeating on every link of one subscription (see #4895), so making it unconditional again for node-hosted inbounds would reopen that complaint for setups with several node-hosted inbounds in one subscription.

Minor documentation gap

docs/content/docs/en/config/share-links.mdx:70-75 documents that usage tokens are limited to the first link in the body, but doesn't mention {{EMAIL}}/{{USERNAME}} follow the same rule. I've added the documentation label for that.

@MHSanaei flagging for awareness in case a "show identity on every link" template option is worth adding as a separate enhancement.

This reply was generated automatically by an AI agent. A maintainer may follow up.

<!-- gh-comment-id:5010515335 --> @github-actions[bot] commented on GitHub (Jul 18, 2026): This is expected behavior, not a defect specific to node-hosted inbounds — closing as not planned, with the reasoning below. I've also retitled the issue since the original title attributes this to node-hosting specifically, which isn't the actual cause. **Root cause** `{{EMAIL}}` (and `{{USERNAME}}`) is deliberately emitted only on a client's *first* link within a subscription response; it is stripped from every link generated after that for the same client, regardless of which inbound — master or node — produces it: - `firstLinkOnlyBodyTokens` in `internal/sub/remark_vars.go:484-491` lists `EMAIL`/`USERNAME` alongside the usage tokens as tokens dropped "from every subscription-body link after a client's first one." - `effectiveTemplate` (`internal/sub/remark_vars.go:557-567`) tracks this per email via `s.usageShown`: the first call for a given email returns the full template; every later call for that same email returns the filtered one. - This only applies to the actual content a client app fetches (raw `/sub/`, `/json/`, `/clash/`) — see the doc comment on `SubService.subscriptionBody`, `internal/sub/service.go:34-39`: "the remark template's per-client info is emitted there (on the first link); every other context ... renders the name-only template." - It's covered by an explicit test, `TestIdentityTokenBodyVsDisplay` (`internal/sub/remark_vars_test.go:377-397`), which asserts that a *second* call for the same client (even on the same single inbound) drops `{{EMAIL}}`. This confirms the dedup is about link order within the subscription, not master vs. node. **Why it looked node-specific** Node-hosted inbounds are not served through a separate code path. They are ordinary rows in the master panel's own `inbounds` table — `NodeID` is just a nullable FK (`internal/database/model/model.go:68`) — and `getInboundsBySubId` (`internal/sub/service.go:459-476`) pulls every inbound attached to the client's subscription, master- and node-hosted alike, in one query ordered `sub_sort_index ASC, id ASC`. One `SubService` instance then generates every link for that subscription, sharing a single `usageShown` map. Whichever inbound sorts first for that client keeps `{{EMAIL}}`; every later one loses it. In your setup the master inbound apparently sorts ahead of the node inbound (lower Sub Sort Index or ID) — the same thing would happen with two ordinary inbounds on the master alone if one client were attached to both. `NodeID` plays no role in remark generation; it's only used to resolve the link's host address (`resolveInboundAddress`, `internal/sub/service.go:1139-1156`). **On `subEmailInRemark`** That exact setting name does not exist in v3.5.0. The current mechanism is the free-form `remarkTemplate` setting (Panel → Settings → Subscription), using the `{{EMAIL}}` token — which is what you're already using correctly. There is no toggle today to force `{{EMAIL}}` onto every link of a multi-inbound/multi-node subscription; the first-link-only rule was added specifically to stop the email repeating on every link of one subscription (see #4895), so making it unconditional again for node-hosted inbounds would reopen that complaint for setups with several node-hosted inbounds in one subscription. **Minor documentation gap** `docs/content/docs/en/config/share-links.mdx:70-75` documents that usage tokens are limited to the first link in the body, but doesn't mention `{{EMAIL}}`/`{{USERNAME}}` follow the same rule. I've added the `documentation` label for that. @MHSanaei flagging for awareness in case a "show identity on every link" template option is worth adding as a separate enhancement. *This reply was generated automatically by an AI agent. A maintainer may follow up.*
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#4174
No description provided.