[PR #6525] [MERGED] fix(panel): probe UDP outbounds and hide the block outbound from the mtproto egress picker #6331

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

📋 Pull Request Information

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

Base: main ← Head: fix/panel-udp-probe-and-mtproto-egress


📝 Commits (2)

  • fcaac70 fix(panel): match the probe and egress readers to what the core loads
  • a01533c fix(panel): recognise the mkcp transport alias and pin the picker's field id

📊 Changes

4 files changed (+118 additions, -10 deletions)

View changed files

📝 frontend/src/hooks/useXraySetting.ts (+13 -9)
📝 frontend/src/pages/inbounds/form/protocols/mtproto.tsx (+2 -1)
➕ frontend/src/test/mtproto-egress-picker.test.tsx (+58 -0)
📝 frontend/src/test/use-xray-setting.test.tsx (+45 -0)

📄 Description

Summary

Two remaining panel readers that read an xray template differently from the core: the outbound probe picks a TCP mode for UDP-only outbounds whose protocol id or transport name is spelled in a case the panel did not expect, and the mtproto egress picker still offers the block outbound.

Both were raised by the automated review on #6523, filed as pre-existing and non-blocking there. This PR is that follow-up.

Why

The core normalises both names before it resolves them — infra/conf/loader.go:46 lowercases the outbound protocol id, and TransportProtocol.Build (infra/conf/transport_internet.go:16-17) lowercases the transport name. Every panel reader that compares either string exactly disagrees with the core for a template that is spelled differently, and the template is user-editable JSON, so this is reachable from a paste or a hand edit.

Scenario 1 — a working outbound reported as down. An operator upgrades and their direct/warp outbound is spelled "WireGuard" (or "Hysteria", or the stream carries "network": "KCP"). The core loads it and builds the UDP handler; nothing warns. In Xray → Outbounds the operator clicks the row's Test button, or Test All Outbounds. isUdpOutbound compared o?.protocol === 'wireguard' exactly, returned false, so the outbound was queued into the TCP lane, where a dial-only probe runs against a UDP-only endpoint. The result is a red "down" row for an outbound that is passing traffic right now, and Test All Outbounds shows the same for that entry. The mode is also picked from the same helper by the single-outbound probe, so both the per-row button and the batch run land the same way.

Scenario 2 — the block outbound selectable as an mtproto egress. An inbound of protocol mtproto with Route through Xray on offers an Outbound dropdown. That dropdown called useOutboundTags() without options, so nothing was filtered: the tag of the blackhole outbound was listed next to the real proxies and could be selected. Choosing it looks like a working selection and silently discards that inbound's Telegram traffic. The two other call sites of this data — the host dialerProxy picker and the node form — already pass excludeBlackhole: true; the mtproto picker was the one that did not.

What changed

  • isUdpOutbound now matches the protocol id through the shared isOutboundProtocol helper and lowercases the transport name before comparing it, and recognises the mkcp alias the core resolves to the same mKCP transport.
  • The mtproto egress picker asks for { excludeBlackhole: true }, like its two siblings.

Scope. The remaining exact network === … comparisons in lib/xray/* (link builders, inbound tag flags, FinalMask) read values the panel writes itself from a fixed list, so this change does not touch them — they are a different surface and none of them is on the path fixed here. The two write-path readers the same review named (the outbound editor falling through to VLESS for a differently spelled id, and the Basics setters appending a second direct) are already fixed on #6522; this PR does not duplicate them.

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/, all four commands run locally:

  • npm run lint — 0 warnings, 0 errors (567 files).
  • npm run typecheck — clean.
  • npm run build — succeeds; gen:api rewrote frontend/public/openapi.json with no diff.
  • npx vitest run --project components src/test/use-xray-setting.test.tsx src/test/mtproto-egress-picker.test.tsx — 8 passed.

Both tests were confirmed red before their fix, then green with it:

  • use-xray-setting.test.tsx drives the real hook: it renders useXraySetting, calls testOutbound(0, outbound, 'tcp') and asserts the mode the probe actually posts. With the fix reverted, the "WireGuard", "HyStErIa" and "KCP" cases fail with expected 'tcp' to be 'http'; the canonical wireguard and a plain vless case pass either way.
  • mtproto-egress-picker.test.tsx renders the real MtprotoFields with a spied config response and opens the egress dropdown. With the fix reverted it fails on expected [ 'direct', 'blocked', 'warp' ] to not include 'blocked'.

The picker test addresses the field by an explicit id on that Select, the same handle the inbound form's protocol select uses (InboundFormModal.tsx:645, listSelectOptions('protocol')), and reuses listSelectOptions from test-utils instead of a private copy of the dropdown reader. An earlier revision located the field positionally, which would have stayed green while asserting about a different select the day one above it gained showSearch.

Screenshots / recordings

N/A — no visual change; the picker simply no longer lists the block tag.

Breaking changes

None. Both changes narrow behaviour to match what the core already does: a probe switches mode for outbounds the core was already loading, and one dropdown loses an entry that could only discard traffic.

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 file is touched; the Go jobs are left to CI.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed. — No endpoint, schema or documented behaviour 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/6525 **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/panel-udp-probe-and-mtproto-egress` --- ### 📝 Commits (2) - [`fcaac70`](https://github.com/MHSanaei/3x-ui/commit/fcaac702181fb498d5bb5ba79e47e2bb3ff5e04f) fix(panel): match the probe and egress readers to what the core loads - [`a01533c`](https://github.com/MHSanaei/3x-ui/commit/a01533c70015c487988ddf1042a002573d84fdea) fix(panel): recognise the mkcp transport alias and pin the picker's field id ### 📊 Changes **4 files changed** (+118 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/hooks/useXraySetting.ts` (+13 -9) 📝 `frontend/src/pages/inbounds/form/protocols/mtproto.tsx` (+2 -1) ➕ `frontend/src/test/mtproto-egress-picker.test.tsx` (+58 -0) 📝 `frontend/src/test/use-xray-setting.test.tsx` (+45 -0) </details> ### 📄 Description ## Summary Two remaining panel readers that read an xray template differently from the core: the outbound probe picks a TCP mode for UDP-only outbounds whose protocol id or transport name is spelled in a case the panel did not expect, and the mtproto egress picker still offers the block outbound. Both were raised by the automated review on #6523, filed as pre-existing and non-blocking there. This PR is that follow-up. ## Why The core normalises both names before it resolves them — `infra/conf/loader.go:46` lowercases the outbound protocol id, and `TransportProtocol.Build` (`infra/conf/transport_internet.go:16-17`) lowercases the transport name. Every panel reader that compares either string exactly disagrees with the core for a template that is spelled differently, and the template is user-editable JSON, so this is reachable from a paste or a hand edit. **Scenario 1 — a working outbound reported as down.** An operator upgrades and their `direct`/`warp` outbound is spelled `"WireGuard"` (or `"Hysteria"`, or the stream carries `"network": "KCP"`). The core loads it and builds the UDP handler; nothing warns. In *Xray → Outbounds* the operator clicks the row's Test button, or *Test All Outbounds*. `isUdpOutbound` compared `o?.protocol === 'wireguard'` exactly, returned `false`, so the outbound was queued into the TCP lane, where a dial-only probe runs against a UDP-only endpoint. The result is a red "down" row for an outbound that is passing traffic right now, and *Test All Outbounds* shows the same for that entry. The mode is also picked from the same helper by the single-outbound probe, so both the per-row button and the batch run land the same way. **Scenario 2 — the block outbound selectable as an mtproto egress.** An inbound of protocol mtproto with *Route through Xray* on offers an *Outbound* dropdown. That dropdown called `useOutboundTags()` without options, so nothing was filtered: the tag of the `blackhole` outbound was listed next to the real proxies and could be selected. Choosing it looks like a working selection and silently discards that inbound's Telegram traffic. The two other call sites of this data — the host `dialerProxy` picker and the node form — already pass `excludeBlackhole: true`; the mtproto picker was the one that did not. **What changed** - `isUdpOutbound` now matches the protocol id through the shared `isOutboundProtocol` helper and lowercases the transport name before comparing it, and recognises the `mkcp` alias the core resolves to the same mKCP transport. - The mtproto egress picker asks for `{ excludeBlackhole: true }`, like its two siblings. **Scope.** The remaining exact `network === …` comparisons in `lib/xray/*` (link builders, inbound tag flags, FinalMask) read values the panel writes itself from a fixed list, so this change does not touch them — they are a different surface and none of them is on the path fixed here. The two write-path readers the same review named (the outbound editor falling through to VLESS for a differently spelled id, and the Basics setters appending a second `direct`) are already fixed on #6522; this PR does not duplicate them. ## 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) - [ ] 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/`, all four commands run locally: - `npm run lint` — 0 warnings, 0 errors (567 files). - `npm run typecheck` — clean. - `npm run build` — succeeds; `gen:api` rewrote `frontend/public/openapi.json` with no diff. - `npx vitest run --project components src/test/use-xray-setting.test.tsx src/test/mtproto-egress-picker.test.tsx` — 8 passed. Both tests were confirmed red before their fix, then green with it: - `use-xray-setting.test.tsx` drives the real hook: it renders `useXraySetting`, calls `testOutbound(0, outbound, 'tcp')` and asserts the `mode` the probe actually posts. With the fix reverted, the `"WireGuard"`, `"HyStErIa"` and `"KCP"` cases fail with `expected 'tcp' to be 'http'`; the canonical `wireguard` and a plain `vless` case pass either way. - `mtproto-egress-picker.test.tsx` renders the real `MtprotoFields` with a spied config response and opens the egress dropdown. With the fix reverted it fails on `expected [ 'direct', 'blocked', 'warp' ] to not include 'blocked'`. The picker test addresses the field by an explicit `id` on that `Select`, the same handle the inbound form's protocol select uses (`InboundFormModal.tsx:645`, `listSelectOptions('protocol')`), and reuses `listSelectOptions` from `test-utils` instead of a private copy of the dropdown reader. An earlier revision located the field positionally, which would have stayed green while asserting about a different select the day one above it gained `showSearch`. ## Screenshots / recordings N/A — no visual change; the picker simply no longer lists the block tag. ## Breaking changes None. Both changes narrow behaviour to match what the core already does: a probe switches mode for outbounds the core was already loading, and one dropdown loses an entry that could only discard traffic. ## 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 file is touched; the Go jobs are left to CI. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. — No endpoint, schema or documented behaviour 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:08:01 +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#6331
No description provided.