[PR #6976] [MERGED] fix(link): keep IPv6 brackets in imported wireguard endpoints #6558

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6976
Author: @jayhemnani9910
Created: 10/27/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @MHSanaei

Base: main ← Head: fix/wireguard-ipv6-endpoint


📝 Commits (2)

  • e3c04e7 fix(link): keep IPv6 brackets in imported wireguard endpoints
  • 65abcdd Merge remote-tracking branch 'origin/main' into pr/6976

📊 Changes

2 files changed (+24 additions, -1 deletions)

View changed files

📝 internal/util/link/outbound.go (+2 -1)
📝 internal/util/link/outbound_helpers_test.go (+22 -0)

📄 Description

Summary

A wireguard link with an IPv6 server now imports with a usable endpoint, [2001:db8::1]:51820 instead of 2001:db8::1:51820.

Why

parseWireguard in internal/util/link/outbound.go built the peer endpoint as u.Hostname() + ":" + port. Hostname() drops the brackets, so wireguard://key@[2001:db8::1]:51820?... became 2001:db8::1:51820. Xray reads the endpoint with net.ParseDestination("udp:" + endpoint), which fails on that:

address 2001:db8::1:51820: too many colons in address

So an IPv6 wireguard server imported from a link or an outbound subscription could not connect. The panel's own link import (parseWireguardLink, which uses the JS URL.hostname) keeps the brackets.

The endpoint is now built with net.JoinHostPort, as the outbound address list in internal/web/service/outbound/outbound.go already does. IPv4 and hostname endpoints are unchanged. The identity string of an IPv6 wireguard outbound includes the endpoint, so it changes once for those entries.

Type of change

  • Bug fix

Areas affected

  • Subscription (share links / Clash / JSON)

How was this tested?

  • New test TestParseWireguard_Endpoint in internal/util/link/outbound_helpers_test.go covers a hostname, IPv4, IPv6 and a link without a port. The IPv6 case fails on main and passes with the change.
  • Xray's own net.ParseDestination accepts the new endpoint udp:[2001:db8::1]:51820 and rejects the old one.
  • go test -shuffle=on -count=1 ./... passes (52 packages). golangci-lint run ./internal/util/link/ reports 0 issues.

Breaking changes

None.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 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/6976 **Author:** [@jayhemnani9910](https://github.com/jayhemnani9910) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 11/3/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/wireguard-ipv6-endpoint` --- ### 📝 Commits (2) - [`e3c04e7`](https://github.com/MHSanaei/3x-ui/commit/e3c04e73b805a4bc461d20aae0a07f606a6f034a) fix(link): keep IPv6 brackets in imported wireguard endpoints - [`65abcdd`](https://github.com/MHSanaei/3x-ui/commit/65abcdd263e327663bbd1105f146e874736f4096) Merge remote-tracking branch 'origin/main' into pr/6976 ### 📊 Changes **2 files changed** (+24 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `internal/util/link/outbound.go` (+2 -1) 📝 `internal/util/link/outbound_helpers_test.go` (+22 -0) </details> ### 📄 Description ## Summary A wireguard link with an IPv6 server now imports with a usable endpoint, `[2001:db8::1]:51820` instead of `2001:db8::1:51820`. ## Why `parseWireguard` in `internal/util/link/outbound.go` built the peer endpoint as `u.Hostname() + ":" + port`. `Hostname()` drops the brackets, so `wireguard://key@[2001:db8::1]:51820?...` became `2001:db8::1:51820`. Xray reads the endpoint with `net.ParseDestination("udp:" + endpoint)`, which fails on that: ``` address 2001:db8::1:51820: too many colons in address ``` So an IPv6 wireguard server imported from a link or an outbound subscription could not connect. The panel's own link import (`parseWireguardLink`, which uses the JS `URL.hostname`) keeps the brackets. The endpoint is now built with `net.JoinHostPort`, as the outbound address list in `internal/web/service/outbound/outbound.go` already does. IPv4 and hostname endpoints are unchanged. The identity string of an IPv6 wireguard outbound includes the endpoint, so it changes once for those entries. ## Type of change - [x] Bug fix ## Areas affected - [x] Subscription (share links / Clash / JSON) ## How was this tested? - New test `TestParseWireguard_Endpoint` in `internal/util/link/outbound_helpers_test.go` covers a hostname, IPv4, IPv6 and a link without a port. The IPv6 case fails on main and passes with the change. - Xray's own `net.ParseDestination` accepts the new endpoint `udp:[2001:db8::1]:51820` and rejects the old one. - `go test -shuffle=on -count=1 ./...` passes (52 packages). `golangci-lint run ./internal/util/link/` reports 0 issues. ## Breaking changes None. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi changed title from [PR #6976] fix(link): keep IPv6 brackets in imported wireguard endpoints to [PR #6976] [MERGED] fix(link): keep IPv6 brackets in imported wireguard endpoints 2026-11-07 14:33:58 +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#6558
No description provided.