[PR #6958] feat(amneziawg): add opt-in IPv4 echo relay with client policies #6543

Open
opened 2026-11-02 04:09:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6958
Author: @Vaso73
Created: 10/26/2026
Status: 🔄 Open

Base: main ← Head: amneziawg-ipv4-echo


📝 Commits (4)

  • 4d99f93 feat(amneziawg): add per-client IPv4 echo forwarding
  • 91ac7f1 docs(api): sync AWG IPv4 echo reference
  • bf6c6c2 fix(amneziawg): preserve offline node account edits
  • 04da9a8 Merge upstream main and preserve AWG tunnel health checks

📊 Changes

63 files changed (+3152 additions, -17 deletions)

View changed files

📝 docs/content/docs/en/config/amneziawg.mdx (+66 -0)
📝 docs/content/docs/en/reference/api/clients.mdx (+9 -0)
📝 docs/content/docs/en/reference/api/inbounds.mdx (+12 -1)
📝 docs/public/openapi.json (+86 -1)
📝 frontend/public/openapi.json (+86 -1)
➕ frontend/src/api/queries/useAmneziawgPingReadiness.ts (+18 -0)
📝 frontend/src/generated/examples.ts (+11 -0)
📝 frontend/src/generated/schemas.ts (+48 -0)
📝 frontend/src/generated/types.ts (+8 -0)
📝 frontend/src/generated/zod.ts (+9 -0)
📝 frontend/src/pages/api-docs/endpoints.ts (+8 -1)
📝 frontend/src/pages/clients/ClientFormModal.tsx (+75 -0)
📝 frontend/src/schemas/client.ts (+2 -0)
➕ frontend/src/schemas/primitives/awg-ping.ts (+28 -0)
📝 frontend/src/schemas/protocols/inbound/amneziawg.ts (+2 -0)
➕ frontend/src/test/awg-ping-ui.test.tsx (+80 -0)
➕ frontend/src/test/awg-ping.test.ts (+48 -0)
📝 go.mod (+1 -1)
📝 internal/amneziawgnet/device.go (+2 -1)
➕ internal/amneziawgnet/echo.go (+421 -0)

...and 43 more files

📄 Description

feat(amneziawg): add opt-in IPv4 echo relay with client policies

Embedded AmneziaWG forwards TCP/UDP through Xray but cannot relay a client's IPv4 ping to a remote destination. Add a disabled-by-default Echo relay with per-client allow/deny CIDRs, fresh account and quota checks in both directions, and native durable traffic accounting. Only a matching real target reply is returned; generated client profiles remain unchanged.

Preserve existing tunnel-health checks: Echo to an exact configured server tunnel address is still answered by gVisor independently of the remote forwarding grant. Other unfragmented IPv4 ICMP messages continue to reach the stack. Remote Echo is intercepted before gVisor, so an unreachable remote destination cannot receive a fabricated local success. Fragmented remote ICMP, IPv6 Echo, traceroute and ICMP over VLESS/Hysteria are outside this feature.

This revision merges current main, preserving its peer-attribution, flow teardown, forwarded-port omission and shared-client lifecycle fixes. Both OpenAPI copies and the API reference are regenerated from the merged models and endpoint descriptions.

Policy and lifecycle:

  • The canonical client record is authoritative; omission preserves the stored policy and explicit empty lists clear it. Deny wins and empty allow grants nothing.
  • Requests and replies are checked against enabled state, expiry, quota and policy revision before durable native accounting. Pending replies cannot survive revocation or client identity reuse.
  • Nodes negotiate awg-ping4 support before new or changed enabled grants. Unchanged account edits can be saved while a node is offline and queued for reconciliation. Kernel mode is not supported by this relay.
  • Raw ICMP must already be permitted on the server. The panel does not change privileges, firewall rules or system settings. The readiness indicator probes only the local panel host; node support is negotiated separately.

Validation on this revision:

  • Complete Go suite and complete shuffled race suite: 53 packages passed in isolated networks, including encrypted AWG/raw ICMP and real Xray TCP/UDP tests.
  • New local-health and ICMP-error regressions fail before the compatibility fix and pass afterward. Same-subnet remote addresses and fragmented Echo cannot bypass the remote policy.
  • SQLite migration/reopen, isolated PostgreSQL migration, exact request/reply accounting, denial/revocation/error cases and offline-node account edits passed.
  • Real master/node panel synchronization and the global traffic heartbeat chain passed with temporary databases and local endpoints.
  • 2,051 frontend/component/Storybook tests, typecheck, lint, format, panel and Storybook builds passed. Documentation: 112 tests, typecheck, lint, format and production build passed.
  • Go build and golangci-lint passed; a 10-second Echo parser fuzz run completed 77,683 inputs. Regenerating 20 API/type/reference files is byte-stable and both OpenAPI copies match.

Test-environment notes: the host timezone database disagrees with the toolchain's about Havana in November 2026. TestNextWeeklyRenewal_RepeatedMidnight fails identically on unmodified main with host tzdata; the full successful Go/race runs explicitly use the timezone database bundled with Go 1.27.3. An earlier concurrent race run had an intermittent MTProto no-op-process test failure; the final full race run passed, as did ten repetitions of that test with a private PID namespace. No renewal or MTProto source was changed.

All validation above uses synthetic data and local test processes. This revision has not been deployed to a production server and makes no new external-client acceptance claim.


🔄 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/6958 **Author:** [@Vaso73](https://github.com/Vaso73) **Created:** 10/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `amneziawg-ipv4-echo` --- ### 📝 Commits (4) - [`4d99f93`](https://github.com/MHSanaei/3x-ui/commit/4d99f93237bbb12bf5b7d7ac53378fc4f801013a) feat(amneziawg): add per-client IPv4 echo forwarding - [`91ac7f1`](https://github.com/MHSanaei/3x-ui/commit/91ac7f1b783458283fc7d73c8a8748171c8569c7) docs(api): sync AWG IPv4 echo reference - [`bf6c6c2`](https://github.com/MHSanaei/3x-ui/commit/bf6c6c23a64dee7de2e912965f184d172f2a14b2) fix(amneziawg): preserve offline node account edits - [`04da9a8`](https://github.com/MHSanaei/3x-ui/commit/04da9a8e2b1585a563d947c80709a86de48a3e87) Merge upstream main and preserve AWG tunnel health checks ### 📊 Changes **63 files changed** (+3152 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/config/amneziawg.mdx` (+66 -0) 📝 `docs/content/docs/en/reference/api/clients.mdx` (+9 -0) 📝 `docs/content/docs/en/reference/api/inbounds.mdx` (+12 -1) 📝 `docs/public/openapi.json` (+86 -1) 📝 `frontend/public/openapi.json` (+86 -1) ➕ `frontend/src/api/queries/useAmneziawgPingReadiness.ts` (+18 -0) 📝 `frontend/src/generated/examples.ts` (+11 -0) 📝 `frontend/src/generated/schemas.ts` (+48 -0) 📝 `frontend/src/generated/types.ts` (+8 -0) 📝 `frontend/src/generated/zod.ts` (+9 -0) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+8 -1) 📝 `frontend/src/pages/clients/ClientFormModal.tsx` (+75 -0) 📝 `frontend/src/schemas/client.ts` (+2 -0) ➕ `frontend/src/schemas/primitives/awg-ping.ts` (+28 -0) 📝 `frontend/src/schemas/protocols/inbound/amneziawg.ts` (+2 -0) ➕ `frontend/src/test/awg-ping-ui.test.tsx` (+80 -0) ➕ `frontend/src/test/awg-ping.test.ts` (+48 -0) 📝 `go.mod` (+1 -1) 📝 `internal/amneziawgnet/device.go` (+2 -1) ➕ `internal/amneziawgnet/echo.go` (+421 -0) _...and 43 more files_ </details> ### 📄 Description # feat(amneziawg): add opt-in IPv4 echo relay with client policies Embedded AmneziaWG forwards TCP/UDP through Xray but cannot relay a client's IPv4 ping to a remote destination. Add a disabled-by-default Echo relay with per-client allow/deny CIDRs, fresh account and quota checks in both directions, and native durable traffic accounting. Only a matching real target reply is returned; generated client profiles remain unchanged. Preserve existing tunnel-health checks: Echo to an exact configured server tunnel address is still answered by gVisor independently of the remote forwarding grant. Other unfragmented IPv4 ICMP messages continue to reach the stack. Remote Echo is intercepted before gVisor, so an unreachable remote destination cannot receive a fabricated local success. Fragmented remote ICMP, IPv6 Echo, traceroute and ICMP over VLESS/Hysteria are outside this feature. This revision merges current main, preserving its peer-attribution, flow teardown, forwarded-port omission and shared-client lifecycle fixes. Both OpenAPI copies and the API reference are regenerated from the merged models and endpoint descriptions. Policy and lifecycle: - The canonical client record is authoritative; omission preserves the stored policy and explicit empty lists clear it. Deny wins and empty allow grants nothing. - Requests and replies are checked against enabled state, expiry, quota and policy revision before durable native accounting. Pending replies cannot survive revocation or client identity reuse. - Nodes negotiate `awg-ping4` support before new or changed enabled grants. Unchanged account edits can be saved while a node is offline and queued for reconciliation. Kernel mode is not supported by this relay. - Raw ICMP must already be permitted on the server. The panel does not change privileges, firewall rules or system settings. The readiness indicator probes only the local panel host; node support is negotiated separately. Validation on this revision: - Complete Go suite and complete shuffled race suite: 53 packages passed in isolated networks, including encrypted AWG/raw ICMP and real Xray TCP/UDP tests. - New local-health and ICMP-error regressions fail before the compatibility fix and pass afterward. Same-subnet remote addresses and fragmented Echo cannot bypass the remote policy. - SQLite migration/reopen, isolated PostgreSQL migration, exact request/reply accounting, denial/revocation/error cases and offline-node account edits passed. - Real master/node panel synchronization and the global traffic heartbeat chain passed with temporary databases and local endpoints. - 2,051 frontend/component/Storybook tests, typecheck, lint, format, panel and Storybook builds passed. Documentation: 112 tests, typecheck, lint, format and production build passed. - Go build and golangci-lint passed; a 10-second Echo parser fuzz run completed 77,683 inputs. Regenerating 20 API/type/reference files is byte-stable and both OpenAPI copies match. Test-environment notes: the host timezone database disagrees with the toolchain's about Havana in November 2026. `TestNextWeeklyRenewal_RepeatedMidnight` fails identically on unmodified main with host tzdata; the full successful Go/race runs explicitly use the timezone database bundled with Go 1.27.3. An earlier concurrent race run had an intermittent MTProto no-op-process test failure; the final full race run passed, as did ten repetitions of that test with a private PID namespace. No renewal or MTProto source was changed. All validation above uses synthetic data and local test processes. This revision has not been deployed to a production server and makes no new external-client acceptance claim. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#6543
No description provided.