mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6031] [Bug]: Wireguard link sharing functionality loses IP address information #4177
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#4177
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?
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
10.0.0.2/32,fded:42::2/128The 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 andgithub.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
addressquery 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
@github-actions[bot] commented on GitHub (Jul 18, 2026):
Confirmed. Both locations you linked only read index
[0]of a multi-valueAllowedIPs/allowedIPsfield, 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-valueAllowedIPsto its first entrySeverity: 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 viasplitWireguardAllowedIPs,model.go:1020and: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, thewireguard://share link'saddressquery param (the panel's Copy Link button).frontend/src/lib/xray/inbound-link.ts:853—genWireguardConfig, theAddress =line of the downloadable/QR.conftext, reached viagenWireguardConfigsfromQrCodeModal.tsxandInboundInfoModal.tsx.internal/sub/service.go:647-648—SubService.genWireguardLink, the raw subscription'saddressparam (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-565assigns the wholeclient.AllowedIPsslice into the JSON subscription output (tested with two addresses atinternal/sub/json_service_test.go:358-372), andinternal/sub/clash_service.go:405iterates all of them for Clash (tested atinternal/sub/clash_service_test.go:807). That strongly suggests the raw-link/.confpath 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 completec.AllowedIPsslice 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
', '-joinedAllowedIPs = 0.0.0.0/0, ::/0line a few lines below in that samegenWireguardConfig) instead of indexing[0], mirroring whatjson_service.go/clash_service.goalready do. The reverse parser in the same file,wireguardConfigFromLink(inbound-link.ts:899), already treatsaddressas 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 currentmain/dev-latestand postdates thev3.5.0release 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.