mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6531] [MERGED] fix(amneziawg): read the outbound pseudo-protocol id like the core #6337
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#6337
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/6531
Author: @BlindMaster24
Created: 9/14/2026
Status: ✅ Merged
Merged: 9/15/2026
Merged by: @BlindMaster24
Base:
main← Head:fix/amneziawg-outbound-protocol-id-case📝 Commits (2)
6e91a54fix(amneziawg): read the outbound pseudo-protocol id like the core86236destyle(service): trim the amneziawg outbound test comment to two lines📊 Changes
2 files changed (+47 additions, -1 deletions)
View changed files
📝
internal/amneziawg/outbound.go(+1 -1)📝
internal/web/service/xray_amneziawg_outbound_test.go(+46 -0)📄 Description
Summary
amneziawg.IsAmneziaWGOutboundcompared the outbound protocol id exactly. It is the last reader of that id that does; the id is now read case-insensitively, like the core and like this repository's own probe lane already read it.Why
An outbound protocol id is not case-sensitive. The pinned core lowercases it before resolving the handler, and this repository already relies on that everywhere else:
internal/web/service/outbound/probe_http.go:399— the probe lane reads this same id withstrings.EqualFold(p, "amneziawg"), andTestBuildBatchTestConfigReadsTheProtocolIDLikeTheCore(merged in #6526) pins that an"AmneziaWG"entry is bridged tosocksfor the temp probe config.internal/database/db.goreads protocol ids withstrings.EqualFoldin five migrations (:1634,:1720,:1835,:2153,:2256), includinghasNonLowercaseFreedomOutbound(:2330), which exists precisely because non-lowercase protocol ids were found in real stored templates.IsAmneziaWGOutboundis the exception, and three paths depend on it:1. Config generation — Xray fails to start.
transformAmneziaWGOutbounds(xray_amneziawg_outbound.go:25) skips the entry, so the raw"AmneziaWG"pseudo-protocol is handed to the core. Verified by running the core's own validator:The core does not know
amneziawgat all — it is a panel pseudo-protocol that only works because the panel swaps it for a socks bridge before writing the config. Skipping the bridge therefore does not degrade the outbound, it makes the whole config unusable.2. The amneziawg job — silent no-op.
internal/web/job/amneziawg_job.go:82uses the same predicate, so the reconcile loop never builds anOutboundDesiredfor the entry: the outbound carries no tunnel and nothing is logged.3. The save path answered two ways for one spelling.
CheckXrayConfig(xray_setting.go:64) branches on the same predicate: the exact match goes to the panel's own validator, the case variant falls through to the core's. Same probe run, before the fix:So an operator writing
"AmneziaWG"was told the core has no such protocol, about a protocol the panel implements and whose lowercase spelling it accepts. After the fix both spellings get the panel's own message (amneziawg outbound "t1": privateKey is required), which is the actionable one.Reachability, stated honestly
The panel's save path rejects the case variant today — that is exactly why the operator sees the confusing message above rather than a stored template. So paths 1 and 2 need a template that did not come through that save: a restored backup, a direct DB edit, a scripted template, or a legacy DB. The
UppercaseFreedomFinalRulesFixseeder (and thehasNonLowercaseFreedomOutboundpredicate it is built on) is the repository's own evidence that such data exists in the wild, and it repairs it in place rather than rejecting it — the same choice this PR makes for the other pseudo-protocol.Type of change
Areas affected
How was this tested?
Red-first:
TestTransformAmneziaWGOutbounds_ReadsTheProtocolIDLikeTheCoredrives the real generation path (transformAmneziaWGOutbounds) for three spellings, and the control case ("amneziawg") passes while the two case variants fail before the fix:After the change all three are bridged with the tag preserved and the settings rewritten (
address 127.0.0.1,port 64900,user awg-hop). Revertstrings.EqualFoldback to==and the two failures return.The save-path claim above is a command result rather than a test: the three lines per spelling come from a throwaway probe that called
IsAmneziaWGOutbound,xray.ValidateOutboundConfigandCheckXrayConfigon the same outbound. The probe is not part of this PR.Local gate.
go build ./...clean,gofmt -lclean,go vetclean oninternal/amneziawg/,internal/web/service/andinternal/web/job/;go test ./internal/amneziawg/ok and theTestTransformAmneziaWGOutbounds*group green (4 tests). This machine has no C compiler, so the CGo build and the DB-backed tests ininternal/web/serviceare CI's — the full package cannot run locally (it fails identically on unmodifiedmain), which is environmental and not this change.Screenshots / recordings
N/A — backend and config generation only, no UI change.
Breaking changes
None. The canonical spelling behaves exactly as before; the change only widens which entries the panel recognizes as its own amneziawg pseudo-protocol, and the control case pins that.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.go build ./...passes here; the fullgo test ./...needs a C compiler for the SQLite driver, which CI has and this machine does not — the same caveat as my previous PRs.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.