mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #7097] feat: import AmneziaWG vpn:// links and subscriptions as outbounds #6649
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#6649
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/7097
Author: @NikanZeyaei
Created: 11/7/2026
Status: 🔄 Open
Base:
main← Head:feat/amneziawg-link-import📝 Commits (8)
fd4974dfeat(link): parse AmneziaWG vpn:// links into amneziawg outbounds736b64bfeat(outbound-sub): run AmneziaWG outbounds from subscriptionsc7f57f0feat(frontend): import AmneziaWG vpn:// links in the outbound form2b0a866docs(outbounds): list vpn:// among importable link schemes0254ea7fix(frontend): keep absent S3/S4 at 0 when importing a vpn:// link9695b3fperf(outbound-sub): read subscribed AmneziaWG outbounds quietly per job tickfa73ca8fix(link): bound vpn:// inflation per subscription and keep client identity7f07e3afix(frontend): cap inflated AmneziaVPN keys and keep ranged keepalive📊 Changes
14 files changed (+782 additions, -43 deletions)
View changed files
📝
docs/content/docs/en/operations/outbounds-routing.mdx(+2 -1)📝
docs/content/docs/fa/operations/outbounds-routing.mdx(+1 -1)📝
docs/content/docs/ru/operations/outbounds-routing.mdx(+1 -1)📝
docs/content/docs/zh/operations/outbounds-routing.mdx(+1 -1)📝
frontend/src/lib/xray/outbound-link-parser.ts(+143 -3)📝
frontend/src/pages/xray/outbounds/OutboundFormModal.tsx(+3 -3)📝
frontend/src/test/outbound-link-parser.test.ts(+150 -15)➕
internal/util/link/amneziawg_test.go(+153 -0)📝
internal/util/link/outbound.go(+173 -3)📝
internal/web/job/amneziawg_job.go(+16 -13)➕
internal/web/job/amneziawg_job_test.go(+56 -0)📝
internal/web/service/outbound_subscription.go(+37 -2)📝
internal/web/service/outbound_subscription_test.go(+43 -0)📝
internal/web/service/xray.go(+3 -0)📄 Description
Summary
Import AmneziaWG
vpn://links asamneziawgoutbounds, both pasted into the outbound form and pulled from outbound subscriptions. Both payload formats are accepted: 3x-ui's base64url.conftext and the AmneziaVPN app's compressed JSON key.Why
Closes #7056
The panel serves AmneziaWG as
vpn://links and has anamneziawgoutbound, but could not import those links. Parsing alone was not enough for subscriptions, because three things dropped or broke a subscribed AmneziaWG outbound:amneziawgprotocol, so it was always dropped;GetXrayConfigbridgedamneziawgoutbounds to socks before the subscription merge, so a subscribed one would have reached the core raw;AmneziaWGJobonly started tunnel devices for template outbounds.Commits:
feat(link): Govpn://parser ininternal/util/link. Only known.confkeys are copied, soPostUpand other wg-quick hooks never get through. Inflated keys are capped at 1 MiB.feat(outbound-sub): subscription outbounds are validated withValidateAmneziaWGOutbound, bridged after the merge, and get their tunnel device.feat(frontend): the same parser inoutbound-link-parser.ts.parseOutboundLinkis now async because the browser's only built-in zlib inflater (DecompressionStream) is async. This avoids a new dependency. The key's JSON is validated with Zod.docs(outbounds): listvpnamong the importable schemes (en/fa/ru/zh).Type of change
Areas affected
How was this tested?
New tests. Each one fails when its fix is reverted.
internal/util/link/amneziawg_test.go: a 3x-ui plain-text link, an AmneziaVPN qCompress key, a key without a remark (the tag comes fromdescription), aPostUpline that must not appear in the output, and rejections for a key with no AmneziaWG container and a config with no endpoint.TestOutboundSubscriptionAmneziaWGLinkReachesConfigAsBridge: anhttptestsubscription serving avpn://line. The outbound survives refresh and is emitted assocksinGetXrayConfig.TestDesiredOutboundInstancesIncludesSubscribedAmneziaWG: a subscribed outbound gets its tunnel instance.outbound-link-parser.test.ts: the same cases on the frontend.Checks run:
make lint,make format-check,make typecheck,make test-fe,make build,make build-storybook,make docs-openapi-checkand the Go tests pass. One Storybook iframe timed out once (FormField.stories.tsx) and passed on rerun.FuzzParseLinkran for 20s.Manual check: built the panel with Xray v26.10.31 and pasted both link formats under Xray Settings → Outbounds → Add outbound → link import. Both filled the amneziawg form (tags
test-awgandamnezia-key).Cross-panel check: created an AmneziaWG inbound with a client on a separate 3x-ui panel, then added that client's subscription URL as an outbound subscription on the local panel built from this branch. The
vpn://link was imported as anamneziawgoutbound and emitted as its socks bridge in the generated Xray config.Not tested: a real key exported by the AmneziaVPN app. The fixture follows the format described in amnezia-client#1407.
Screenshots / recordings
N/A. The existing link-import box and amneziawg form are unchanged; they now accept
vpn://.Breaking changes
None.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.