mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5305] [Bug]: IPv6 address in generated share links is not wrapped in square brackets #3715
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#3715
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 @Bryanrios-a on GitHub (Jun 14, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5305
Describe the bug
When the server address is an IPv6 literal, the generated share link cannot be parsed correctly.
Current generated link format is similar to:
vless://uuid@2001:db8::1:443?...This is invalid because an IPv6 address used in a URI host field must be wrapped in square brackets when a port is included.
The expected format should be:
vless://uuid@[2001:db8::1]:443?...Because the IPv6 address is not enclosed in
[], client applications fail to import or parse the share link correctly.The panel should automatically detect IPv6 addresses and wrap them in square brackets when generating share links or QR codes.
How to reproduce the problem
Inboundspage.2001:db8::1.Expected behavior
If the share link host is an IPv6 address, it should be generated as:
[IPv6-address]:portExample:
vless://uuid@[2001:db8::1]:443?...IPv4 addresses and domain names should remain unchanged.
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.3.1
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
ubuntu24.04
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 (Jun 14, 2026):
The bug is confirmed in the source. Both the Go subscription backend and the TypeScript frontend concatenate bare IPv6 addresses into URI authority strings without RFC 3986-required bracket wrapping, producing invalid links like
vless://uuid@2001:db8::1:443?...instead ofvless://uuid@[2001:db8::1]:443?....Go backend —
internal/sub/service.goAll non-VMess protocol generators (VLESS, Trojan, Shadowsocks, Hysteria2) call
resolveInboundAddress(), which returns a plain string, then pass it directly intofmt.Sprintf:The external-proxy variants on lines 550, 601, 666, and 779 have the same problem with their
destparameter.VMess is not affected because the address is encoded into a base64 JSON blob rather than placed directly in the URI authority.
TypeScript frontend —
frontend/src/lib/xray/inbound-link.tsThe frontend link generators (
genVlessLink,genTrojanLink,genShadowsocksLink,genHysteriaLink) construct template literals like:where
addressis a bare IPv6 string returned bynormalizeShareHost(). This produces a malformed URL that the browser'sURLconstructor will misparse.Root cause
Neither
resolveInboundAddress()in Go nornormalizeShareHost()in TypeScript applies any IPv6 bracket logic before the address is interpolated into the URI string.Suggested fix (for maintainers)
Go — replace
%s:%dwith a helper that usesnet.JoinHostPort, which correctly brackets IPv6 addresses:TypeScript — either set
url.hostname(theURLAPI handles brackets automatically when the hostname contains:) or wrap the address before interpolation:Both paths need the fix applied to the external-proxy closures as well as the main link builder.
This reply was generated automatically; a maintainer may follow up.