[PR #7046] feat(sub): support inbound-level traffic quota variables in remark template #6617

Open
opened 2026-11-07 14:34:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/7046
Author: @DoctorGuidance
Created: 11/1/2026
Status: 🔄 Open

Base: main ← Head: feat/sub-inbound-traffic-variables


📝 Commits (2)

  • 09f32b8 feat(sub): support inbound-level traffic quota variables in remark template (#6720)
  • c325d75 fix(sub): keep inbound tokens on each link and preserve under info node

📊 Changes

17 files changed (+336 additions, -33 deletions)

View changed files

📝 frontend/src/lib/remark/remarkVariables.ts (+8 -0)
📝 internal/sub/remark_vars.go (+92 -18)
📝 internal/sub/remark_vars_test.go (+110 -1)
📝 internal/web/translation/ar-EG.json (+9 -1)
📝 internal/web/translation/en-US.json (+9 -1)
📝 internal/web/translation/es-ES.json (+9 -1)
📝 internal/web/translation/fa-IR.json (+9 -1)
📝 internal/web/translation/id-ID.json (+9 -1)
📝 internal/web/translation/ja-JP.json (+9 -1)
📝 internal/web/translation/pt-BR.json (+9 -1)
📝 internal/web/translation/ru-RU.json (+9 -1)
📝 internal/web/translation/sk-SK.json (+9 -1)
📝 internal/web/translation/tr-TR.json (+9 -1)
📝 internal/web/translation/uk-UA.json (+9 -1)
📝 internal/web/translation/vi-VN.json (+9 -1)
📝 internal/web/translation/zh-CN.json (+9 -1)
📝 internal/web/translation/zh-TW.json (+9 -1)

📄 Description

Summary

This PR introduces support for Inbound-level aggregated traffic quota variables in the subscription remark template and frontend Remark Variable Picker, addressing #6720.

Problem

In multi-user shared setups (e.g. family, office, or small team VPS deployments sharing an inbound with a monthly bandwidth allowance), administrators often set the traffic limit on the Inbound itself rather than configuring rigid per-client quotas (clients remain unlimited with totalGB = 0).

Previously, subscription remark template variables ({{TRAFFIC_TOTAL}}, {{TRAFFIC_LEFT}}, {{TRAFFIC_USED}}) only reflected individual client-level statistics. Because client quotas were unset, subscription clients consistently showed "Unlimited" traffic even when the underlying Inbound had a strict quota pool, preventing users from seeing shared inbound usage and remaining allowance.

Solution

  1. New Inbound Traffic Variables:
    • {{INBOUND_TRAFFIC_USED}}: Human-readable used traffic on the Inbound (Up + Down).
    • {{INBOUND_TRAFFIC_LEFT}}: Remaining traffic on the Inbound before reaching Inbound.Total (renders ∞ and cleanly drops in pipe-separated segments if the Inbound has no quota).
    • {{INBOUND_TRAFFIC_TOTAL}}: Inbound total quota limit (renders ∞ if unlimited).
    • {{INBOUND_TRAFFIC_USED_BYTES}}, {{INBOUND_TRAFFIC_LEFT_BYTES}}, {{INBOUND_TRAFFIC_TOTAL_BYTES}}: Raw integer byte representations.
    • {{INBOUND_UP}}, {{INBOUND_DOWN}}: Inbound upload and download traffic.
  2. Single-Bracket UI Token Mapping:
    • Added single-bracket equivalents in uiTokenMap (e.g. {INBOUND_TRAFFIC_LEFT} -> {{INBOUND_TRAFFIC_LEFT}}).
  3. Frontend Remark Variable Picker:
    • Exposed all 8 inbound tokens in REMARK_VARIABLES under the traffic category in frontend/src/lib/remark/remarkVariables.ts.
  4. Localization (14 Locales):
    • Added token descriptions under pages.hosts.remarkVars across all 14 embedded locale JSON files.

Testing

  • Added unit tests for all inbound traffic tokens in internal/sub/remark_vars_test.go (TestExpandRemarkVars and edge cases in TestExpandRemarkVars_EdgeCases).
  • Validated all 14 translation JSON files parse cleanly without syntax errors.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/7046 **Author:** [@DoctorGuidance](https://github.com/DoctorGuidance) **Created:** 11/1/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/sub-inbound-traffic-variables` --- ### 📝 Commits (2) - [`09f32b8`](https://github.com/MHSanaei/3x-ui/commit/09f32b8cfd2bcac160da5fb18a9472ed2abf3c46) feat(sub): support inbound-level traffic quota variables in remark template (#6720) - [`c325d75`](https://github.com/MHSanaei/3x-ui/commit/c325d75dfc89492dd08483a4525952f0f2e34396) fix(sub): keep inbound tokens on each link and preserve under info node ### 📊 Changes **17 files changed** (+336 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/lib/remark/remarkVariables.ts` (+8 -0) 📝 `internal/sub/remark_vars.go` (+92 -18) 📝 `internal/sub/remark_vars_test.go` (+110 -1) 📝 `internal/web/translation/ar-EG.json` (+9 -1) 📝 `internal/web/translation/en-US.json` (+9 -1) 📝 `internal/web/translation/es-ES.json` (+9 -1) 📝 `internal/web/translation/fa-IR.json` (+9 -1) 📝 `internal/web/translation/id-ID.json` (+9 -1) 📝 `internal/web/translation/ja-JP.json` (+9 -1) 📝 `internal/web/translation/pt-BR.json` (+9 -1) 📝 `internal/web/translation/ru-RU.json` (+9 -1) 📝 `internal/web/translation/sk-SK.json` (+9 -1) 📝 `internal/web/translation/tr-TR.json` (+9 -1) 📝 `internal/web/translation/uk-UA.json` (+9 -1) 📝 `internal/web/translation/vi-VN.json` (+9 -1) 📝 `internal/web/translation/zh-CN.json` (+9 -1) 📝 `internal/web/translation/zh-TW.json` (+9 -1) </details> ### 📄 Description ### Summary This PR introduces support for Inbound-level aggregated traffic quota variables in the subscription remark template and frontend Remark Variable Picker, addressing #6720. ### Problem In multi-user shared setups (e.g. family, office, or small team VPS deployments sharing an inbound with a monthly bandwidth allowance), administrators often set the traffic limit on the Inbound itself rather than configuring rigid per-client quotas (clients remain unlimited with `totalGB = 0`). Previously, subscription remark template variables (`{{TRAFFIC_TOTAL}}`, `{{TRAFFIC_LEFT}}`, `{{TRAFFIC_USED}}`) only reflected individual client-level statistics. Because client quotas were unset, subscription clients consistently showed "Unlimited" traffic even when the underlying Inbound had a strict quota pool, preventing users from seeing shared inbound usage and remaining allowance. ### Solution 1. **New Inbound Traffic Variables**: - `{{INBOUND_TRAFFIC_USED}}`: Human-readable used traffic on the Inbound (`Up + Down`). - `{{INBOUND_TRAFFIC_LEFT}}`: Remaining traffic on the Inbound before reaching `Inbound.Total` (renders `∞` and cleanly drops in pipe-separated segments if the Inbound has no quota). - `{{INBOUND_TRAFFIC_TOTAL}}`: Inbound total quota limit (renders `∞` if unlimited). - `{{INBOUND_TRAFFIC_USED_BYTES}}`, `{{INBOUND_TRAFFIC_LEFT_BYTES}}`, `{{INBOUND_TRAFFIC_TOTAL_BYTES}}`: Raw integer byte representations. - `{{INBOUND_UP}}`, `{{INBOUND_DOWN}}`: Inbound upload and download traffic. 2. **Single-Bracket UI Token Mapping**: - Added single-bracket equivalents in `uiTokenMap` (e.g. `{INBOUND_TRAFFIC_LEFT}` -> `{{INBOUND_TRAFFIC_LEFT}}`). 3. **Frontend Remark Variable Picker**: - Exposed all 8 inbound tokens in `REMARK_VARIABLES` under the `traffic` category in `frontend/src/lib/remark/remarkVariables.ts`. 4. **Localization (14 Locales)**: - Added token descriptions under `pages.hosts.remarkVars` across all 14 embedded locale JSON files. ### Related Issues - Resolves #6720 ### Testing - Added unit tests for all inbound traffic tokens in `internal/sub/remark_vars_test.go` (`TestExpandRemarkVars` and edge cases in `TestExpandRemarkVars_EdgeCases`). - Validated all 14 translation JSON files parse cleanly without syntax errors. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#6617
No description provided.