[GH-ISSUE #5831] [Bug]: The problem is activating Final Mask in the host section #4053

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

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

Describe the bug

When we enable one of the options in the Final Mask tab on the host, for example, Fragment, this option is not included in the Final Mask box on the user's client! However, when we enable the Final Mask in the inbound settings, it is included in the user's client without any problems.

How to reproduce the problem

  1. Open the Hosts page
  2. Create a new host or edit an existing host
  3. On the Advanced tab and in the Final Mask section, enable an option, such as Fragment

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

34.2

Xray-core version

No response

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 22.04.5

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 @rasa68 on GitHub (Jul 6, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5831 ### Describe the bug When we enable one of the options in the Final Mask tab on the host, for example, Fragment, this option is not included in the Final Mask box on the user's client! However, when we enable the Final Mask in the inbound settings, it is included in the user's client without any problems. ### How to reproduce the problem 1. Open the Hosts page 2. Create a new host or edit an existing host 3. On the Advanced tab and in the Final Mask section, enable an option, such as Fragment ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 34.2 ### Xray-core version _No response_ ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 22.04.5 ### 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:36:48 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

Confirmed as a real bug in the current code (main, matching the reported panel version 3.4.2).

Root cause: a Host's Final Mask value is only merged into the JSON and Clash subscription outputs, not into the plain/raw share links (vless://, trojan://, vmess://, ss://) that a client's "Final Mask" box is populated from via the fm= parameter.

  • hostToExternalProxyMap() (internal/sub/host_sub.go:104-106) does copy the host's FinalMask onto the synthetic endpoint (ep["finalMask"]).
  • For the JSON subscription, applyHostStreamOverrides() merges that per-host mask into the per-host stream before it's rendered (internal/sub/json_service.go:203), and the same happens for Clash (internal/sub/clash_service.go:196).
  • For the raw link builders (genVlessLink, genTrojanLink, genShadowsocksLink, genVmessLink in internal/sub/service.go), the fm query param is computed exactly once from the inbound's own streamSettings.finalmask (e.g. internal/sub/service.go:786-788) before the code branches into per-host endpoints. The per-endpoint override path (buildEndpointLinks in internal/sub/endpoint.go:76-103) applies TLS, Reality SNI/fingerprint, host header/path, and allow-insecure overrides per host, but there is no equivalent step that merges ep["finalMask"] into params["fm"]. So a mask configured only at the host level never reaches the raw share link, while a mask configured on the inbound itself is picked up correctly (matching what you observed).

This explains the exact symptom: Final Mask set on the inbound works everywhere, but Final Mask set only on a Host is silently dropped from the plain subscription/share link (it does still take effect in the JSON-format subscription, if you want to confirm that as a workaround).

This is a code-level bug that needs a fix in internal/sub/service.go / internal/sub/endpoint.go (adding a per-endpoint finalmask merge to the raw-link path, mirroring applyHostStreamOverrides), not a configuration issue on your end, so no further logs are needed from you at this time.

This reply was generated automatically from the repository source; a maintainer may follow up.

<!-- gh-comment-id:4892302418 --> @github-actions[bot] commented on GitHub (Jul 6, 2026): Confirmed as a real bug in the current code (`main`, matching the reported panel version 3.4.2). **Root cause:** a Host's `Final Mask` value is only merged into the **JSON** and **Clash** subscription outputs, not into the plain/raw share links (`vless://`, `trojan://`, `vmess://`, `ss://`) that a client's "Final Mask" box is populated from via the `fm=` parameter. - `hostToExternalProxyMap()` (`internal/sub/host_sub.go:104-106`) does copy the host's `FinalMask` onto the synthetic endpoint (`ep["finalMask"]`). - For the **JSON** subscription, `applyHostStreamOverrides()` merges that per-host mask into the per-host stream before it's rendered (`internal/sub/json_service.go:203`), and the same happens for **Clash** (`internal/sub/clash_service.go:196`). - For the **raw link** builders (`genVlessLink`, `genTrojanLink`, `genShadowsocksLink`, `genVmessLink` in `internal/sub/service.go`), the `fm` query param is computed exactly once from the **inbound's own** `streamSettings.finalmask` (e.g. `internal/sub/service.go:786-788`) *before* the code branches into per-host endpoints. The per-endpoint override path (`buildEndpointLinks` in `internal/sub/endpoint.go:76-103`) applies TLS, Reality SNI/fingerprint, host header/path, and allow-insecure overrides per host, but there is no equivalent step that merges `ep["finalMask"]` into `params["fm"]`. So a mask configured only at the host level never reaches the raw share link, while a mask configured on the inbound itself is picked up correctly (matching what you observed). This explains the exact symptom: Final Mask set on the inbound works everywhere, but Final Mask set only on a Host is silently dropped from the plain subscription/share link (it does still take effect in the JSON-format subscription, if you want to confirm that as a workaround). This is a code-level bug that needs a fix in `internal/sub/service.go` / `internal/sub/endpoint.go` (adding a per-endpoint finalmask merge to the raw-link path, mirroring `applyHostStreamOverrides`), not a configuration issue on your end, so no further logs are needed from you at this time. *This reply was generated automatically from the repository source; 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#4053
No description provided.