mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #5369] [CLOSED] feat(inbounds): optional tag field with automatic routing rule sync #5864
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5864
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5369
Author: @nima1024m
Created: 6/15/2026
Status: ❌ Closed
Base:
main← Head:feat/inbound-tag-field📝 Commits (10+)
4533b1cfeat(inbounds): add optional tag field and sync routing on tag changes57e7822fix(inbounds): tag field crash and add live routing sync e2e tests677fa5dfix(inbounds): return needRestart after deferred routing tag sync6adeaf5Merge branch 'main' into feat/inbound-tag-field84a2599chore: merge origin/main into feat/inbound-tag-field32101fcchore: merge origin/main into feat/inbound-tag-fielda2164f2Merge branch 'main' into feat/inbound-tag-field5423cc9fix(i18n): use single-brace interpolation for inbound tag auto-preview2425fc2Merge branch 'MHSanaei:main' into feat/inbound-tag-field7a6335ev3.4.0📊 Changes
19 files changed (+642 additions, -22 deletions)
View changed files
📝
frontend/src/pages/inbounds/form/InboundFormModal.tsx(+61 -21)📝
frontend/src/test/inbound-form-modal.test.tsx(+41 -0)📝
internal/config/version(+1 -1)➕
internal/web/service/routing_sync_e2e_live_test.go(+299 -0)➕
internal/web/service/routing_sync_e2e_seed_test.go(+132 -0)📝
internal/web/service/xray_setting_routing_sync_test.go(+43 -0)📝
internal/web/translation/ar-EG.json(+5 -0)📝
internal/web/translation/en-US.json(+5 -0)📝
internal/web/translation/es-ES.json(+5 -0)📝
internal/web/translation/fa-IR.json(+5 -0)📝
internal/web/translation/id-ID.json(+5 -0)📝
internal/web/translation/ja-JP.json(+5 -0)📝
internal/web/translation/pt-BR.json(+5 -0)📝
internal/web/translation/ru-RU.json(+5 -0)📝
internal/web/translation/tr-TR.json(+5 -0)📝
internal/web/translation/uk-UA.json(+5 -0)📝
internal/web/translation/vi-VN.json(+5 -0)📝
internal/web/translation/zh-CN.json(+5 -0)📝
internal/web/translation/zh-TW.json(+5 -0)📄 Description
Summary
Adds an optional Tag field to the inbound create/edit modal (below Remark) and keeps Xray routing rules in sync when inbound tags change or inbounds are deleted — the same policy already used for outbound tag renames.
ReferenceErroron the first keystroke in the Tag field.PropagateInboundTagRenameandRemoveInboundTagReferencesupdate routing rules and loopback outboundsettings.inboundTagon inbound update/delete.UpdateInbounduses a namedneedRestartreturn so the post-commit routing sync correctly tells callers to restart Xray when the template changes.UpdateInboundintegration), live DB e2e tests (-tags=e2e), and manual browser verification against a running panel.Diff: 20 files, +1,240 / −26 lines
Motivation
Routing rules reference inbound tags via
inboundTag. Renaming or deleting an inbound without updating those rules leaves stale references. This PR keeps the Xray template consistent automatically, including:inboundTag+domaininboundTagWithout the
needRestartfix, routing rules inxrayTemplateConfigwould update on tag rename but Xray could keep running with stale routing because the deferred sync ran after the return value was already captured.Changes
Frontend
frontend/src/pages/inbounds/form/InboundFormModal.tsxtag: ""→ panel auto-assigns (in-{port}-tcp, etc.)Bug fix:
currentTagInputis defined before thetagIsAutouseMemo(fixes crash on first keystroke).Backend
xray_setting_routing_sync.goinbound.goUpdateInbound(rename) andDelInbound(delete cleanup); namedneedRestartreturn for deferred syncrouting_sync_e2e_live_test.go//go:build e2e)routing_sync_e2e_seed_test.go//go:build e2e)Also preserves the existing auto tag on edit when port/transport is unchanged.
i18n
New keys under
pages.inbounds.form:tag,tagHelp,tagPlaceholder,tagDuplicate,tagAutoPreview(13 locales).Routing sync behavior
inboundTag+domain)inboundTag× 2)in-{port}-tcpinboundTagstripped; domain keptTesting
Automated
Unit tests — all pass:
PropagateInboundTagRename_*RemoveInboundTagReferences_*UpdateInbound_PropagatesRoutingRuleOnTagRenameUpdateInboundupdates routing and returnsneedRestart=trueDelInbound_RemovesInboundOnlyRoutingRuleLive DB e2e (
-tags=e2e, requiresx-ui/x-ui.db):RenameAndDeleteCustomToAutoTagTemplateJSONValidFrontend: inbound form modal tests added in
inbound-form-modal.test.tsx.Manual browser E2E
Panel at
http://127.0.0.1:2053, Xray Configs → Routing Rules tab. Seeded template: api rule + inbound-only direct +example.comblocked (multi-condition) + dual-tag proxy.in-{port}-tcpon all rules including multi-conditionSeed helpers (optional, panel stopped):
Test plan (reviewer)
go test ./internal/web/service/ -run 'PropagateInboundTag|RemoveInboundTag|UpdateInbound_Propagates|DelInbound_Removes'go test ./internal/web/service/ -tags=e2e -run TestLiveRoutingSync -vCommits
4533b1cf— feat(inbounds): add optional tag field and sync routing on tag changes57e7822e— fix(inbounds): tag field crash and add live routing sync e2e tests677fa5d4— fix(inbounds): return needRestart after deferred routing tag syncFiles changed
frontend/src/pages/inbounds/form/InboundFormModal.tsxfrontend/src/test/inbound-form-modal.test.tsxinternal/web/service/inbound.gointernal/web/service/xray_setting_routing_sync.gointernal/web/service/xray_setting_routing_sync_test.gointernal/web/service/routing_sync_e2e_live_test.go(new,//go:build e2e)internal/web/service/routing_sync_e2e_seed_test.go(new,//go:build e2e)internal/web/translation/*.json(13 locales)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.