[PR #6051] [MERGED] fix(wireguard): preserve all Allowed IPs in share link, .conf, and subscription #6064

Closed
opened 2026-11-02 04:06:07 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6051
Author: @H-TTTTT
Created: 7/20/2026
Status: ✅ Merged
Merged: 7/21/2026
Merged by: @MHSanaei

Base: main ← Head: fix/wg-multi-allowed-ips


📝 Commits (1)

  • aca4f0d fix(wireguard): preserve all Allowed IPs in share link, .conf, and subscription

📊 Changes

4 files changed (+72 additions, -5 deletions)

View changed files

📝 frontend/src/lib/xray/inbound-link.ts (+3 -3)
📝 frontend/src/test/inbound-link.test.ts (+37 -0)
📝 internal/sub/service.go (+2 -2)
📝 internal/sub/service_wireguard_test.go (+30 -0)

📄 Description

Summary

The WireGuard client tunnel address is stored end-to-end as a string slice (model.AllowedIPs []string, comma-split/joined in the DB layer), and the inbound UI hint explicitly documents comma-separated multi-value input. Three of the export paths only read index [0], silently dropping every address after the first — a dual-stack IPv4+IPv6 client never receives its second address in the exported text.

  • genWireguardLink share link address param (frontend/src/lib/xray/inbound-link.ts)
  • genWireguardConfig downloadable .conf Address = line (frontend/src/lib/xray/inbound-link.ts)
  • SubService.genWireguardLink raw subscription address param (internal/sub/service.go)

The sibling JSON and Clash subscriptions already emit the full slice (json_service.go, clash_service.go), and WireguardPeerFromClient passes the whole slice into the real Xray peer config, so only the exported text was wrong. The actual proxying is unaffected.

Changes

  • Join all AllowedIPs entries instead of indexing [0]:
    • Link params use , (no space), matching the model's strings.Join(..., \",\") and the existing multi-value link-param joins in service.go.
    • The .conf Address = line uses , (comma-space), matching the AllowedIPs = 0.0.0.0/0, ::/0 line a few lines below in the same genWireguardConfig.
  • The reverse parser (wireguardConfigFromLink) already treats address as an opaque string, so the comma-joined value round-trips unchanged.
  • Added focused multi-address tests: TestGenWireguardLinkMultiAllowedIPs (Go) and a genWireguardLink + genWireguardConfig multi allowedIPs block (frontend). Existing single-address snapshots are unchanged (joining a one-element slice is a no-op).

Fixes #6031

Verification

  • `go test ./internal/sub/` — pass (incl. new `TestGenWireguardLinkMultiAllowedIPs`).
  • `npx vitest run src/test/inbound-link.test.ts` — 49 passed, snapshots stable.
  • `npx tsc --noEmit` + `npx eslint` on the touched files — clean.

🔄 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/6051 **Author:** [@H-TTTTT](https://github.com/H-TTTTT) **Created:** 7/20/2026 **Status:** ✅ Merged **Merged:** 7/21/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/wg-multi-allowed-ips` --- ### 📝 Commits (1) - [`aca4f0d`](https://github.com/MHSanaei/3x-ui/commit/aca4f0d47ed9b396e5f0b3f3434980c22120c90b) fix(wireguard): preserve all Allowed IPs in share link, .conf, and subscription ### 📊 Changes **4 files changed** (+72 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/lib/xray/inbound-link.ts` (+3 -3) 📝 `frontend/src/test/inbound-link.test.ts` (+37 -0) 📝 `internal/sub/service.go` (+2 -2) 📝 `internal/sub/service_wireguard_test.go` (+30 -0) </details> ### 📄 Description ## Summary The WireGuard client tunnel address is stored end-to-end as a string slice (`model.AllowedIPs []string`, comma-split/joined in the DB layer), and the inbound UI hint explicitly documents comma-separated multi-value input. Three of the export paths only read index `[0]`, silently dropping every address after the first — a dual-stack IPv4+IPv6 client never receives its second address in the exported text. - `genWireguardLink` share link `address` param (`frontend/src/lib/xray/inbound-link.ts`) - `genWireguardConfig` downloadable `.conf` `Address =` line (`frontend/src/lib/xray/inbound-link.ts`) - `SubService.genWireguardLink` raw subscription `address` param (`internal/sub/service.go`) The sibling JSON and Clash subscriptions already emit the full slice (`json_service.go`, `clash_service.go`), and `WireguardPeerFromClient` passes the whole slice into the real Xray peer config, so only the exported text was wrong. The actual proxying is unaffected. ## Changes - Join all `AllowedIPs` entries instead of indexing `[0]`: - Link params use `,` (no space), matching the model's `strings.Join(..., \",\")` and the existing multi-value link-param joins in `service.go`. - The `.conf` `Address =` line uses `, ` (comma-space), matching the `AllowedIPs = 0.0.0.0/0, ::/0` line a few lines below in the same `genWireguardConfig`. - The reverse parser (`wireguardConfigFromLink`) already treats `address` as an opaque string, so the comma-joined value round-trips unchanged. - Added focused multi-address tests: `TestGenWireguardLinkMultiAllowedIPs` (Go) and a `genWireguardLink + genWireguardConfig multi allowedIPs` block (frontend). Existing single-address snapshots are unchanged (joining a one-element slice is a no-op). Fixes #6031 ## Verification - \`go test ./internal/sub/\` — pass (incl. new \`TestGenWireguardLinkMultiAllowedIPs\`). - \`npx vitest run src/test/inbound-link.test.ts\` — 49 passed, snapshots stable. - \`npx tsc --noEmit\` + \`npx eslint\` on the touched files — clean. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:07 +07:00
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#6064
No description provided.