mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6419] [CLOSED] feat(amneziawg): native kernel module acceleration with automatic userspace fallback #6261
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#6261
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/6419
Author: @rqzbeh
Created: 9/5/2026
Status: ❌ Closed
Base:
main← Head:feat/amneziawg-kernel-module-engine📝 Commits (6)
2b62cbbfeat(amneziawg): add kernel module detection and probe helperc927a45feat(amneziawg): add kernel module detection and preflight checksb3af34dfeat(amneziawg): abstract engine interface with automatic fallback in manager575e61bfeat(amneziawg): implement native kernel module engine with routing lifecycleabea642docs(amneziawg): document kernel module acceleration and docker setupa9e1384fix(amneziawg): resolve golangci-lint linter issues in kernel routing📊 Changes
11 files changed (+700 additions, -17 deletions)
View changed files
📝
docs/content/docs/en/config/amneziawg.mdx(+42 -8)📝
internal/amneziawgnet/diagnostics.go(+3 -6)➕
internal/amneziawgnet/engine.go(+15 -0)➕
internal/amneziawgnet/engine_fallback_test.go(+61 -0)➕
internal/amneziawgnet/kernel_detect.go(+64 -0)➕
internal/amneziawgnet/kernel_detect_test.go(+141 -0)➕
internal/amneziawgnet/kernel_engine.go(+137 -0)➕
internal/amneziawgnet/kernel_engine_test.go(+22 -0)➕
internal/amneziawgnet/kernel_routing_linux.go(+154 -0)➕
internal/amneziawgnet/kernel_routing_other.go(+29 -0)📝
internal/amneziawgnet/manager.go(+32 -3)📄 Description
Summary
Adds native Linux kernel module acceleration (
amneziawg-linux-kernel-module) for AmneziaWG inbounds with automatic, seamless fallback to the embeddedamneziawg-go+gVisoruserspace engine when unsupported or unprivileged.Why
While the embedded
amneziawg-goengine provides 100% portability without host kernel dependencies, high-bandwidth deployments benefit significantly from zero-copy native kernel processing. This dual-engine architecture probes for the kernel module at runtime:amneziawg.koloaded and the process hasCAP_NET_ADMIN, 3x-ui manages nativeawg<id>interfaces and routes peer traffic via policy routing / TPROXY into Xray, preserving full Xray routing rules, outbounds, sniffing, and live per-client accounting.Type of change
Areas affected
How was this tested?
DetectKernelSupportandIsKernelModuleLoaded) under mock Linux sysfs states, non-Linux OSes, and permission errors.Managerensuring failure of the kernel engine automatically boots the embedded engine.KernelEngineandEngineinterface compliance.go test ./...).Docker Setup
To enable kernel module acceleration when running 3x-ui via Docker:
amneziawgmodule is loaded on the Linux host (sudo modprobe amneziawg).--cap-add=NET_ADMINand mount the host modules directory:If
CAP_NET_ADMINor the kernel module is omitted, the container runs normally using the embedded userspace engine.Breaking changes
None. 100% backward-compatible.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.