[GH-ISSUE #6031] [Bug]: Wireguard link sharing functionality loses IP address information #4177

Closed
opened 2026-10-31 20:37:45 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Enr1g on GitHub (Jul 18, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6031

Describe the bug

When I set multiple allowed IPs for client of wireguard inbound only the first is exported in share link.

Having multiple comma separated addresses is allowed explicitly by caption in the panel, by the wireguard configuration format. Having multiple allowed IPs is supported by xray itself (https://xtls.github.io/en/config/outbounds/wireguard.html).

The feature is useful to have both IPv4 and IPv6 networks in your wireguard config.

How to reproduce the problem

  1. Create any wireguard inbound
  2. Add a client
  3. Edit the client's Allowed IPs on the Credential tab to 10.0.0.2/32,fded:42::2/128
  4. Copy share link for a user.

The same bug works not only in copy share link functionality but also in subscriptions. I'm not sure but it looks like the relevant code is github.com/MHSanaei/3x-ui@2f156c8eb0/frontend/src/lib/xray/inbound-link.ts (L826) for frontend and github.com/MHSanaei/3x-ui@2f156c8eb0/internal/sub/service.go (L648) for subscriptions.

Expected behavior

Share link will contain both IPs comma separated. Something like ...?address=10.0.0.2%2F32%2Cfded%3A42%3A%3A2%2F128&mtu....

Actual behavior

Share link has address query parameter with only one value ...?address=10.0.0.2%2F32&mtu....

Relevant logs


Screenshots

No response

3x-ui version

3.5.0

Xray-core version

26.7.11

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04.4 LTS

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

None

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @Enr1g on GitHub (Jul 18, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6031 ### Describe the bug When I set multiple allowed IPs for client of wireguard inbound only the first is exported in share link. Having multiple comma separated addresses is allowed explicitly by caption in the panel, by the wireguard configuration format. Having multiple allowed IPs is supported by xray itself (https://xtls.github.io/en/config/outbounds/wireguard.html). The feature is useful to have both IPv4 and IPv6 networks in your wireguard config. ### How to reproduce the problem 1. Create any wireguard inbound 2. Add a client 3. Edit the client's Allowed IPs on the Credential tab to `10.0.0.2/32,fded:42::2/128` 4. Copy share link for a user. The same bug works not only in copy share link functionality but also in subscriptions. I'm not sure but it looks like the relevant code is https://github.com/MHSanaei/3x-ui/blob/2f156c8eb04cd2ebbb0a0b9e74d6f2f83fe08eee/frontend/src/lib/xray/inbound-link.ts#L826 for frontend and https://github.com/MHSanaei/3x-ui/blob/2f156c8eb04cd2ebbb0a0b9e74d6f2f83fe08eee/internal/sub/service.go#L648 for subscriptions. ### Expected behavior Share link will contain both IPs comma separated. Something like `...?address=10.0.0.2%2F32%2Cfded%3A42%3A%3A2%2F128&mtu...`. ### Actual behavior Share link has `address` query parameter with only one value `...?address=10.0.0.2%2F32&mtu...`. ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.5.0 ### Xray-core version 26.7.11 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04.4 LTS ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:37:45 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jul 18, 2026):

Confirmed. Both locations you linked only read index [0] of a multi-value AllowedIPs/allowedIPs field, and there is a third call site with the identical defect.

Title: WireGuard share link, downloaded .conf, and raw subscription link all truncate a multi-value AllowedIPs to its first entry

Severity: Medium

Category: Correctness

Why this matters: The data model stores a client's WireGuard tunnel address as a string slice end-to-end (AllowedIPs []string, internal/database/model/model.go:807, backed by a comma-separated DB column split/joined via splitWireguardAllowedIPs, model.go:1020 and :1034), and the UI hint text explicitly documents multi-value input (internal/web/translation/en-US.json:917: "Leave empty to auto-assign; separate entries with commas"). But three of the places that render a client's config only read the first entry:

  • frontend/src/lib/xray/inbound-link.ts:825-826 — genWireguardLink, the wireguard:// share link's address query param (the panel's Copy Link button).
  • frontend/src/lib/xray/inbound-link.ts:853 — genWireguardConfig, the Address = line of the downloadable/QR .conf text, reached via genWireguardConfigs from QrCodeModal.tsx and InboundInfoModal.tsx.
  • internal/sub/service.go:647-648 — SubService.genWireguardLink, the raw subscription's address param (the second location you found).

This is inconsistent with sibling formats in the very same package, which already handle the full list and are covered by multi-address tests: internal/sub/json_service.go:564-565 assigns the whole client.AllowedIPs slice into the JSON subscription output (tested with two addresses at internal/sub/json_service_test.go:358-372), and internal/sub/clash_service.go:405 iterates all of them for Clash (tested at internal/sub/clash_service_test.go:807). That strongly suggests the raw-link/.conf path was simply missed when multi-address support was added, rather than an intentional limitation.

The actual proxying is unaffected: WireguardPeerFromClient (internal/database/model/model.go:362-363) passes the complete c.AllowedIPs slice into the real Xray peer config, so routing works correctly for clients with multiple allowed IPs. Only the exported link/config text that a user pastes into their own WireGuard client silently drops every address after the first, with no error — for a dual-stack (IPv4+IPv6) client, that means the resulting .conf/link never carries the second address.

Recommendation: In the three locations above, join all entries (comma-separated, matching the project's own convention for multi-value WireGuard fields, e.g. the ', '-joined AllowedIPs = 0.0.0.0/0, ::/0 line a few lines below in that same genWireguardConfig) instead of indexing [0], mirroring what json_service.go/clash_service.go already do. The reverse parser in the same file, wireguardConfigFromLink (inbound-link.ts:899), already treats address as an opaque string, so it should round-trip a comma-joined value with no changes needed there. A fix should also extend the existing single-address fixtures (frontend/src/test/inbound-link.test.ts:279-309, internal/sub/service_wireguard_test.go:27) with a multi-address case so the behavior stays pinned. This is a fix recommendation only — no code is changed here; implementation happens only if a maintainer or an @claude mention requests it.

Confidence: High on the root cause and all cited file/line references (verified directly against the source at the commit you linked, 2f156c8, which is also current main/dev-latest and postdates the v3.5.0 release you reported). Lower confidence only on the precise separator style (, vs , ), which is cosmetic rather than a correctness question.

@MHSanaei

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5010564949 --> @github-actions[bot] commented on GitHub (Jul 18, 2026): Confirmed. Both locations you linked only read index `[0]` of a multi-value `AllowedIPs`/`allowedIPs` field, and there is a third call site with the identical defect. **Title:** WireGuard share link, downloaded `.conf`, and raw subscription link all truncate a multi-value `AllowedIPs` to its first entry **Severity:** Medium **Category:** Correctness **Why this matters:** The data model stores a client's WireGuard tunnel address as a string slice end-to-end (`AllowedIPs []string`, `internal/database/model/model.go:807`, backed by a comma-separated DB column split/joined via `splitWireguardAllowedIPs`, `model.go:1020` and `:1034`), and the UI hint text explicitly documents multi-value input (`internal/web/translation/en-US.json:917`: "Leave empty to auto-assign; separate entries with commas"). But three of the places that render a client's config only read the first entry: - `frontend/src/lib/xray/inbound-link.ts:825-826` — `genWireguardLink`, the `wireguard://` share link's `address` query param (the panel's Copy Link button). - `frontend/src/lib/xray/inbound-link.ts:853` — `genWireguardConfig`, the `Address =` line of the downloadable/QR `.conf` text, reached via `genWireguardConfigs` from `QrCodeModal.tsx` and `InboundInfoModal.tsx`. - `internal/sub/service.go:647-648` — `SubService.genWireguardLink`, the raw subscription's `address` param (the second location you found). This is inconsistent with sibling formats in the very same package, which already handle the full list and are covered by multi-address tests: `internal/sub/json_service.go:564-565` assigns the whole `client.AllowedIPs` slice into the JSON subscription output (tested with two addresses at `internal/sub/json_service_test.go:358-372`), and `internal/sub/clash_service.go:405` iterates all of them for Clash (tested at `internal/sub/clash_service_test.go:807`). That strongly suggests the raw-link/`.conf` path was simply missed when multi-address support was added, rather than an intentional limitation. The actual proxying is unaffected: `WireguardPeerFromClient` (`internal/database/model/model.go:362-363`) passes the complete `c.AllowedIPs` slice into the real Xray peer config, so routing works correctly for clients with multiple allowed IPs. Only the exported link/config text that a user pastes into their own WireGuard client silently drops every address after the first, with no error — for a dual-stack (IPv4+IPv6) client, that means the resulting `.conf`/link never carries the second address. **Recommendation:** In the three locations above, join all entries (comma-separated, matching the project's own convention for multi-value WireGuard fields, e.g. the `', '`-joined `AllowedIPs = 0.0.0.0/0, ::/0` line a few lines below in that same `genWireguardConfig`) instead of indexing `[0]`, mirroring what `json_service.go`/`clash_service.go` already do. The reverse parser in the same file, `wireguardConfigFromLink` (`inbound-link.ts:899`), already treats `address` as an opaque string, so it should round-trip a comma-joined value with no changes needed there. A fix should also extend the existing single-address fixtures (`frontend/src/test/inbound-link.test.ts:279-309`, `internal/sub/service_wireguard_test.go:27`) with a multi-address case so the behavior stays pinned. This is a fix recommendation only — no code is changed here; implementation happens only if a maintainer or an @claude mention requests it. **Confidence:** High on the root cause and all cited file/line references (verified directly against the source at the commit you linked, `2f156c8`, which is also current `main`/`dev-latest` and postdates the `v3.5.0` release you reported). Lower confidence only on the precise separator style (`,` vs `, `), which is cosmetic rather than a correctness question. @MHSanaei *This reply was generated automatically; a maintainer may follow up.*
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#4177
No description provided.