[PR #6523] [MERGED] fix(panel): read outbound protocol ids case-insensitively everywhere #6330

Closed
opened 2026-11-02 04:07:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6523
Author: @BlindMaster24
Created: 9/14/2026
Status: ✅ Merged
Merged: 9/14/2026
Merged by: @MHSanaei

Base: main ← Head: fix/outbound-protocol-case-filters


📝 Commits (1)

  • 3dfb208 fix(panel): read outbound protocol ids case-insensitively everywhere

📊 Changes

8 files changed (+123 additions, -8 deletions)

View changed files

📝 frontend/src/api/queries/useOutboundTags.ts (+3 -2)
📝 frontend/src/hooks/useXraySetting.ts (+9 -3)
📝 frontend/src/pages/index/GeodataSection.tsx (+2 -1)
📝 frontend/src/pages/settings/GeneralTab.tsx (+2 -1)
📝 frontend/src/pages/xray/outbounds/OutboundsTab.tsx (+2 -1)
📝 frontend/src/schemas/primitives/outbound-protocol.ts (+10 -0)
➕ frontend/src/test/outbound-protocol-case.test.ts (+28 -0)
➕ frontend/src/test/use-outbound-tags.test.tsx (+67 -0)

📄 Description

Summary

Six more places read an outbound's protocol id by exact string match, while xray-core lowercases that id before it resolves the handler. An outbound spelled Blackhole therefore passed every excludeBlackhole filter, and one spelled Freedom was queued by Test All Outbounds. They all now share one isOutboundProtocol helper.

Why

infra/conf/loader.go in the pinned core lowercases the id in LoadWithID, and infra/conf/xray.go:329 hands it c.Protocol for every outbound, so the spelling never decides which handler runs. The panel's readers still disagreed with that:

  • api/queries/useOutboundTags.ts (useOutboundTags, useOutboundTagGroups) — the tag lists that offer an egress for an mtproto inbound and for a dialerProxy, both requested with excludeBlackhole.
  • pages/xray/outbounds/OutboundsTab.tsx — the dialerProxy picker in the outbound editor.
  • pages/index/GeodataSection.tsx and pages/settings/GeneralTab.tsx — the geodata download egress pickers.
  • hooks/useXraySetting.ts — the skip list for Test All Outbounds, which exists so direct/DNS/block outbounds are not probed.

User story: a config pasted into Xray Settings → JSON with "protocol": "Blackhole" for the block outbound runs exactly like blackhole — the core accepts it silently. The block outbound then appears in the mtproto egress dropdown, in the dialerProxy list and in the geodata download picker; choosing it looks like a working selection and discards the traffic, with nothing in the UI or the logs to say why. The mirror image on the same template: a direct outbound spelled Freedom is queued by Test All Outbounds, which probes it as if it were a proxy.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  • frontend/src/test/use-outbound-tags.test.tsx drives the real hook over a mocked panel response whose outbounds are direct/freedom, blocked/Blackhole, warp/wireguard: with excludeBlackhole both pickers must return ['direct', 'warp'], and without it all three tags are offered. Reverting the two call sites to the exact match reddens the first two tests (expected [ 'direct', 'blocked', 'warp' ] to deeply equal [ 'direct', 'warp' ]).
  • frontend/src/test/outbound-protocol-case.test.ts pins the shared rule itself — freedom/Freedom/FREEDOM/fReEdOm match, another protocol or its spelling does not, and a missing, empty, non-string, null or undefined protocol never matches.
  • npm run typecheck, npm run lint, oxfmt --check pass on the touched files, and the existing geodata-section, general-tab and use-xray-setting suites still pass.

Honest note on coverage: the two picker components (GeodataSection, GeneralTab) and OutboundsTab are one-line conversions to the same helper and I did not add per-component cases for them, so their exclusion behaviour is pinned by the helper test rather than by a test that renders those pages.

Screenshots / recordings

N/A — the difference needs a template that spells a protocol id differently.

Breaking changes

None. Nothing is rewritten on save; the readers simply accept the spellings the core accepts.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally. (no Go change in this PR)
  • For frontend changes: npm run lint and npm run typecheck pass, and the Vite build succeeds.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 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/6523 **Author:** [@BlindMaster24](https://github.com/BlindMaster24) **Created:** 9/14/2026 **Status:** ✅ Merged **Merged:** 9/14/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/outbound-protocol-case-filters` --- ### 📝 Commits (1) - [`3dfb208`](https://github.com/MHSanaei/3x-ui/commit/3dfb208dc9f3071b2bca31717690e105e2cdd5d0) fix(panel): read outbound protocol ids case-insensitively everywhere ### 📊 Changes **8 files changed** (+123 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/api/queries/useOutboundTags.ts` (+3 -2) 📝 `frontend/src/hooks/useXraySetting.ts` (+9 -3) 📝 `frontend/src/pages/index/GeodataSection.tsx` (+2 -1) 📝 `frontend/src/pages/settings/GeneralTab.tsx` (+2 -1) 📝 `frontend/src/pages/xray/outbounds/OutboundsTab.tsx` (+2 -1) 📝 `frontend/src/schemas/primitives/outbound-protocol.ts` (+10 -0) ➕ `frontend/src/test/outbound-protocol-case.test.ts` (+28 -0) ➕ `frontend/src/test/use-outbound-tags.test.tsx` (+67 -0) </details> ### 📄 Description ## Summary Six more places read an outbound's protocol id by exact string match, while xray-core lowercases that id before it resolves the handler. An outbound spelled `Blackhole` therefore passed every `excludeBlackhole` filter, and one spelled `Freedom` was queued by *Test All Outbounds*. They all now share one `isOutboundProtocol` helper. ## Why `infra/conf/loader.go` in the pinned core lowercases the id in `LoadWithID`, and `infra/conf/xray.go:329` hands it `c.Protocol` for every outbound, so the spelling never decides which handler runs. The panel's readers still disagreed with that: - `api/queries/useOutboundTags.ts` (`useOutboundTags`, `useOutboundTagGroups`) — the tag lists that offer an egress for an **mtproto inbound** and for a `dialerProxy`, both requested with `excludeBlackhole`. - `pages/xray/outbounds/OutboundsTab.tsx` — the `dialerProxy` picker in the outbound editor. - `pages/index/GeodataSection.tsx` and `pages/settings/GeneralTab.tsx` — the **geodata download egress** pickers. - `hooks/useXraySetting.ts` — the skip list for *Test All Outbounds*, which exists so direct/DNS/block outbounds are not probed. User story: a config pasted into **Xray Settings → JSON** with `"protocol": "Blackhole"` for the block outbound runs exactly like `blackhole` — the core accepts it silently. The block outbound then appears in the mtproto egress dropdown, in the `dialerProxy` list and in the geodata download picker; choosing it looks like a working selection and discards the traffic, with nothing in the UI or the logs to say why. The mirror image on the same template: a direct outbound spelled `Freedom` is queued by *Test All Outbounds*, which probes it as if it were a proxy. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [x] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? - `frontend/src/test/use-outbound-tags.test.tsx` drives the real hook over a mocked panel response whose outbounds are `direct`/`freedom`, `blocked`/`Blackhole`, `warp`/`wireguard`: with `excludeBlackhole` both pickers must return `['direct', 'warp']`, and without it all three tags are offered. Reverting the two call sites to the exact match reddens the first two tests (`expected [ 'direct', 'blocked', 'warp' ] to deeply equal [ 'direct', 'warp' ]`). - `frontend/src/test/outbound-protocol-case.test.ts` pins the shared rule itself — `freedom`/`Freedom`/`FREEDOM`/`fReEdOm` match, another protocol or its spelling does not, and a missing, empty, non-string, `null` or `undefined` protocol never matches. - `npm run typecheck`, `npm run lint`, `oxfmt --check` pass on the touched files, and the existing `geodata-section`, `general-tab` and `use-xray-setting` suites still pass. Honest note on coverage: the two picker components (`GeodataSection`, `GeneralTab`) and `OutboundsTab` are one-line conversions to the same helper and I did not add per-component cases for them, so their exclusion behaviour is pinned by the helper test rather than by a test that renders those pages. ## Screenshots / recordings N/A — the difference needs a template that spells a protocol id differently. ## Breaking changes None. Nothing is rewritten on save; the readers simply accept the spellings the core accepts. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [ ] `go build ./...` and the test suite pass locally. (no Go change in this PR) - [x] For frontend changes: `npm run lint` and `npm run typecheck` pass, and the Vite build succeeds. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:07:59 +07:00
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#6330
No description provided.