mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6388] [Bug]: QR-code for AWG inbound (config type, not native Amnezia WG vpn://) cannot be scanned\invalid #4334
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#4334
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?
Originally created by @1nn0 on GitHub (Sep 2, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6388
Describe the bug
When I try to scan AWG 3.1 QR-code (config type) in, for example, WG Tunnel app (Android). The result is error or not scannig at all. Tested on a bunch of Android phones with WG Tunnel app (v5.6.0).
3x UI [latest, docker]
WG Tunnel APP [5.6.0]
How to reproduce the problem
Expected behavior
Successfully add tunnel via QR-Code
Actual behavior
Error or no result
Relevant logs
Screenshots
No response
3x-ui version
3.7.0
Xray-core version
26.7.28
How did you install 3x-ui?
Docker / Docker Compose
Operating system
Debian 13
Which parts of the panel are affected?
Other
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
Yes — Nginx
Before submitting
@github-actions[bot] commented on GitHub (Sep 2, 2026):
The QR code itself is fine — the panel puts the exact plain-text
.confinto it, unmodified and untruncated. What almost certainly fails is the import on the WG Tunnel side: the config the panel generates by default carries AmneziaWG 3.1-only keys, and a client build that doesn't implement 3.1 rejects the whole config as invalid when it parses it.Why I think that's what you're hitting
QrPanelhands the value straight to Ant Design's<QRCode>with no transform (frontend/src/pages/inbounds/qr/QrPanel.tsx:139-147), and the value is the.conftext built bygenAmneziaWGConfig(frontend/src/lib/xray/inbound-link.ts:958-1028), whose shape is pinned to wg-quick(8) field order byamneziawg-conf-parity.test.ts:83-94.With the panel's generated obfuscation set, that text always includes these lines (
inbound-link.ts:994-1012):They are always present because the generator fills them unconditionally —
i1: '<r …>',headerProtectionKey,randomTrailers: true,disableCookies: true(frontend/src/lib/xray/amneziawg-obfuscation.ts:110-123). The panel's own field hint says it plainly:"randomTrailersHint": "Appends random bytes to every packet. Both ends need AmneziaWG 3.1+."(internal/web/translation/en-US.json:1960), and the docs carry the same warning — "The 3.1 parameters need a 3.1-capable client… blanking the 3.1 fields renders a config older clients still understand" (docs/content/docs/en/config/amneziawg.mdx:64-70).Supporting point on the "too dense to scan" theory: the
vpn://variant is nothing but base64url of that same.conf, with no compression (inbound-link.ts:932-937and:948-951), so it is ~33% more data than the config QR — and both render through the same<QRCode>component, at 220 px in the popovers (ConfigBlock.tsx:56,SubPage.tsx:568-575). A strictly larger payload scanning while the smaller one doesn't points at the parser, not at the encoding. (This rests on the assumption, from your title, that thevpn://QR does scan for you — say so if that's wrong.)The one check that settles it
Both failure modes look the same from the camera, so please bypass the camera entirely:
QrPanel.tsx:117-126— it savespeer-N.conf/<email>.conf; byte-for-byte what the QR encodes).Workaround if the file import also fails
Edit the AmneziaWG inbound and clear the 3.1 fields, then regenerate the client configs. All of these are plain text inputs / switches (
frontend/src/pages/inbounds/form/protocols/amneziawg.tsx:133-213), so they can be emptied:I1–I5,HeaderProtectionKey,ContentPaddingAddition,RekeyAfterTime,RekeyTimeout,RejectAfterTime,KeepaliveTimeout,MaxHandshakeAttemptsS3 = 0andS4 = 0(a zero drops the line —inbound-link.ts:988-989)RandomTrailersandDisableCookiesThat leaves only
Jc/Jmin/Jmax/S1/S2/H1-H4, which pre-3.1 clients understand. It also shrinks the payload noticeably, which helps scanning as a side effect.⚠️ These values are part of the wire protocol, so changing them breaks every already-deployed client of that inbound — everyone has to re-import.
I could not read WG Tunnel's parser from here, so I can't tell you which exact key it chokes on; the error text WG Tunnel shows (as text, not a screenshot) would name it.
Verdict: Not a bug (user configuration)
Severity: N/A
Confidence: Medium
Root cause: No panel-side defect found. The QR payload is the unmodified
.conf(frontend/src/pages/inbounds/qr/QrPanel.tsx:139-147), and that.conflegitimately contains AmneziaWG 3.1 keys emitted unconditionally bygenAmneziaWGConfig(frontend/src/lib/xray/inbound-link.ts:994-1012) fromgenerateAwgObfuscation()'s defaults (frontend/src/lib/xray/amneziawg-obfuscation.ts:110-123). A client that does not implement 3.1 rejects the config on import — documented atdocs/content/docs/en/config/amneziawg.mdx:64-70.Already fixed: Not applicable — AmneziaWG landed in
effcccce("feat(amneziawg): add native AmneziaWG protocol support (#6105)"), whichgit tag --containsputs in v3.7.0, the reporter's version; nothing in these files has changed since.Duplicate of: None
Evidence:
QrPanel.tsx:141value={value}— no transform between the.confand the QR.inbound-link.ts:1011-1012if (server.randomTrailers) txt += 'RandomTrailers = on\n'/if (server.disableCookies) txt += 'DisableCookies = on\n'.amneziawg-obfuscation.ts:122-123randomTrailers: true, disableCookies: true.internal/web/translation/en-US.json:1960"Both ends need AmneziaWG 3.1+."docs/content/docs/en/config/amneziawg.mdx:64-70warn callout.inbound-link.ts:932-937+:948-951—vpn://is uncompressed base64url of the same text, i.e. a strictly larger QR payload.amneziawg-conf-parity.test.ts:83-94pins the emitted.confto wg-quick field order with no trailing newline. Size:sed -n '133,164p' docs/content/docs/en/config/amneziawg.mdx | wc -c→ 663 bytes for the documented example; a real one is roughly 50-120 bytes larger once the placeholder keys become 44-char base64 keys and theMTU/PresharedKeylines appear.Not determined: Whether WG Tunnel decoded the QR and rejected the config, or failed to decode it at all — I cannot run the panel or a scanner, and I could not read WG Tunnel's source from here. Step 2 above (importing the downloaded
.conffile, same bytes, no camera) settles it in one try.Leaving this open with clarification needed until that result comes back.
This reply was generated automatically; a maintainer may follow up.
@1nn0 commented on GitHub (Sep 2, 2026):
Import from .conf file works fine.
I tried to save QR-Code image to my pc, then opened it in viewer and zoomed in. Same result when I try to scan it.
But when I Disable "DisableCookies" parameter (only this one) - QR-Code scans just fine.
A assume, that somehow this setting is breaking QR-Code generation.
@github-actions[bot] commented on GitHub (Sep 2, 2026):
Thanks — that A/B test settles it, and it points at us, not at WG Tunnel. Confirmed bug. Your
.conffile importing fine rules out my earlier theory (a 3.1 key the client rejects); the content is valid, so what fails is the QR image itself.DisableCookiesisn't special — dropping that one line just shortens the payload by 20 bytes, and the panel renders every QR into a fixed pixel box regardless of how much data is in it, so an AmneziaWG.confsits right on the edge of what a camera can decode and 20 bytes tips it over.What the code does
QrPanelpasses the payload straight to antd's<QRCode>with a hardcoded pixel size and no error-correction override (frontend/src/pages/inbounds/qr/QrPanel.tsx:139-147):Nothing between the
.conftext and thatsizelooks at the payload length. Compare the one place the codebase does tune a QR — the 2FA code atfrontend/src/pages/settings/TwoFactorModal.tsx:133explicitly setserrorLevel="L";QrPanelnever does, so the share-link/config QR runs at antd's default (higher error correction ⇒ more modules for the same data).The AmneziaWG
.confis by far the largest thing the panel puts in a QR, becausegenAmneziaWGConfigemits the whole 3.1 parameter set unconditionally (frontend/src/lib/xray/inbound-link.ts:994-1012), fed bygenerateAwgObfuscation()'s defaults (amneziawg-obfuscation.ts:110-123). Adding up those lines by hand for a typical inbound (44-char keys, two DNS servers, PSK, a hostname endpoint) comes out around 780 bytes — the exact number depends on your key/DNS/endpoint values, so treat it as an estimate, not a measured figure. A payload that size needs a symbol on the order of 105–110 modules per side at the default error-correction level (QR capacity/version figures are ISO/IEC 18004, not something in this repo — that part is inference). Rendered into a 360 px box that is roughly 3.3 px per module, which is about where phone decoders start failing. Each QR version step adds 4 modules and re-lays the entire symbol, which is exactly why removing one 20-byte line flips it from "no result" to "scans fine".Why saving the image and zooming didn't help
That is the same defect, and it's the clearest source-level confirmation. The image export rasterises the vector QR at exactly the same fixed
size(QrPanel.tsx:26-37, called withsizeat:93):So the PNG you saved is 360×360 px no matter how many modules are in it, and it's drawn edge-to-edge with no margin added. Zooming in a viewer just enlarges those ~3.3 px blocks and their anti-aliasing — it cannot add detail.
Workarounds until this is addressed
max-width: 360pxin CSS pixels (frontend/src/pages/inbounds/qr/QrPanel.css:35-39), so browser page zoom (Ctrl/Cmd ++) renders it physically larger and still crisp, unlike the downloaded PNG. Try 200%..confdownload — you've already confirmed it works, and it's byte-for-byte the same config.ConfigBlock.tsx:56,ClientInfoModal.tsx:764), which are ~40% smaller for the same data.I'd avoid the "blank the 3.1 fields" workaround I mentioned earlier purely to shrink the QR — those values are part of the wire protocol and changing them forces every already-deployed client of that inbound to re-import.
Verdict: Confirmed bug
Severity: High
Confidence: Medium
Root cause:
QrPanel(frontend/src/pages/inbounds/qr/QrPanel.tsx:139-147) renders the QR at a fixedsize(360 default at:62, 220 atConfigBlock.tsx:56/ClientInfoModal.tsx:764) and never setserrorLevel, so module density scales with payload length while pixel size does not.svgToPngBlob(QrPanel.tsx:18-47, invoked at:81and:93) rasterises the export at that same fixedsize, so downloading and zooming cannot recover the lost resolution. Triggered by any payload large enough to need a high-version symbol — in practice the AmneziaWG.conf, whose 3.1 linesgenAmneziaWGConfigemits unconditionally (frontend/src/lib/xray/inbound-link.ts:994-1012) fromgenerateAwgObfuscation()'s always-on defaults (amneziawg-obfuscation.ts:110-123,randomTrailers: true, disableCookies: true).Already fixed: Still present on the default branch.
git log -- frontend/src/pages/inbounds/qr/QrPanel.tsxshows nothing since AmneziaWG landed that touches sizing (latest:b9eda09d,92fb94d8,71aca201,d1882c7f— dependency/lint/a11y/tree-reorg work).Duplicate of: None. Related:
5d0081a3"fix(qr): hide QR for post-quantum links on client QR page" (Closes #4656) — same underlying gap ("the encoded URL exceeds the antd QRCode capacity"), but it was solved with a payload-content heuristic,isPostQuantumLink()(inbound-link.ts:1580-1585), which matchespqv=/mlkem768/mldsa65/ML-KEM-768and therefore never fires for a.conf.Evidence:
QrPanel.tsx:142size={size}withsize = 360at:62— no dependence onvalue.lengthanywhere in the file.QrPanel.tsx:27-28,36-37canvas.width = size/ctx.drawImage(img, 0, 0, size, size)— export resolution is fixed and the symbol fills the canvas.TwoFactorModal.tsx:133errorLevel="L"— the prop exists and is used deliberately elsewhere, but not inQrPanel.QrPanel.css:35-39width: 100%; height: auto; max-width: 360px.inbound-link.ts:1011-1012if (server.randomTrailers) txt += 'RandomTrailers = on\n'/if (server.disableCookies) txt += 'DisableCookies = on\n'— the 20 bytes the reporter removed. Reporter's own A/B: file import of the identical bytes succeeds, only the QR fails, and a 20-byte payload reduction fixes the QR.Not determined: I cannot run a decoder or the panel here, so the precise decode failure mode (module density vs. quiet zone vs. raster anti-aliasing) is inferred, not measured. The single check that would settle it: render the same
.confatsize={720}(or witherrorLevel="L") and scan it — if it decodes, it is purely density.Suggested fix: derive the QR pixel size (and the
svgToPngBlobraster size) fromvalue.lengthinQrPanel, so a ~800-byte.confgets a proportionally larger symbol instead of the same 360 px box. Dropping toerrorLevel="L"for large payloads, asTwoFactorModal.tsx:133already does, cuts the module count for the same data and is the cheaper half of the change. The 220 px popover call sites (ConfigBlock.tsx:56,ClientInfoModal.tsx:764) need the same treatment or they will stay unscannable regardless.@MHSanaei
I've removed the clarification needed label — the reply gave everything needed.
This reply was generated automatically; a maintainer may follow up.
@dawNotPoi commented on GitHub (Sep 3, 2026):
I'd like to take this issue.
The reporter's file-import and single-line A/B results isolate the problem to QR readability rather than the generated AWG configuration. I reproduced the same QR version boundary with a representative full AWG 3.1 config: the current default correction level and zero quiet zone produce a 109-module symbol, while the 20-byte reduction falls to 105 modules.
I plan to keep the change focused in the shared QR panel: use the lower correction level already used by the project's 2FA QR and add the standard four-module quiet zone. I will add a regression test using a real generated AWG config to pin both the resulting grid size and quiet zone, without changing the config contents or introducing payload-length heuristics.