[GH-ISSUE #6373] [Bug]: Error in parsing the Custom share address, clash, ipv6 node #4326

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

Originally created by @oopb on GitHub (Aug 31, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6373

Describe the bug

The node custom share address is ipv6 of the VPS. When sharing the subscription link to clash verge, the ipv6 node does not work. Because 3xui will auto add [] on both sides of ipv6 address(can not remove []). And in clash yaml file it will be like: "[ipv6]", which can not be parsed normally.

Image Image

If remove the [] manually, then ipv6 node works normally.

Image

How to reproduce the problem

new inbound
Share address strategy: custom
Custom share address: ipv6 address of VPS
share subscription to clash verge
the node exits parsing error

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.7.0

Xray-core version

No response

How did you install 3x-ui?

install.sh script

Operating system

Debian 12

Which parts of the panel are affected?

Subscription (share links / Clash / JSON)

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

No response

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 @oopb on GitHub (Aug 31, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6373 ### Describe the bug The node custom share address is ipv6 of the VPS. When sharing the subscription link to clash verge, the ipv6 node does not work. Because 3xui will auto add [] on both sides of ipv6 address(can not remove []). And in clash yaml file it will be like: "[ipv6]", which can not be parsed normally. <img width="1140" height="1236" alt="Image" src="https://github.com/user-attachments/assets/9e5cdcb7-7105-4d16-85f0-37bcbffcb404" /> <img width="408" height="48" alt="Image" src="https://github.com/user-attachments/assets/6d1ab033-a604-48e2-8976-73594a4c766c" /> If remove the [] manually, then ipv6 node works normally. <img width="396" height="39" alt="Image" src="https://github.com/user-attachments/assets/b95934d0-3fa1-4cc4-8162-e83725472361" /> ### How to reproduce the problem new inbound Share address strategy: custom Custom share address: ipv6 address of VPS share subscription to clash verge the node exits parsing error ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.7.0 ### Xray-core version _No response_ ### How did you install 3x-ui? install.sh script ### Operating system Debian 12 ### Which parts of the panel are affected? Subscription (share links / Clash / JSON) ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? _No response_ ### 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:38:50 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Aug 31, 2026):

Confirmed — this is a real bug and it is still present on the default branch (f727d04f, v3.7.0). The Clash renderer copies the resolved share address into the proxy's server: field verbatim, and for Share address strategy: Custom the panel deliberately stores that address with brackets, so mihomo/Clash Verge receives server: "[2001:db8::1]" instead of server: 2001:db8::1. (I can't open images attached to an issue, so I did not read your screenshots — but the two behaviours you describe in text are exactly what the code does, so nothing further is needed from you.)

The chain

  1. Saving the inbound normalizes the custom share address and adds the brackets. That is intentional and pinned by a test, which is why you cannot remove them from the UI — every save puts them back:
// internal/web/service/inbound.go:107
return "[" + ip.String() + "]", nil
// internal/web/service/inbound_update_tag_test.go:176
{name: "bare ipv6", addr: "2001:db8::1", want: "[2001:db8::1]"},
  1. The subscription resolver returns that stored value unchanged for the custom strategy:
// internal/sub/service.go:1315
candidates = []string{strings.TrimSpace(inbound.ShareAddr), nodeAddr, listenAddr}
  1. The Clash renderer takes it as the proxy dest and writes it straight into server::
// internal/sub/clash_service.go:187
workingInbound.Listen, _ = extPrxy["dest"].(string)

// internal/sub/clash_service.go:240
"server": inbound.Listen,

The same inbound.Listen is used at clash_service.go:315 (hysteria / hysteria2) and clash_service.go:397 (wireguard), so every protocol is affected.

Raw share links are not affected, because they go through joinHostPort, which strips any stored brackets and re-adds exactly one (internal/sub/service.go:1050-1052) — that helper exists because of the opposite complaint in #5305.

A Clash server: value is a bare host, not a URI authority, so it must not be bracketed — and the panel's other paths already treat it that way, which is why only the custom share address hits this:

  • external subscription links: host := strings.Trim(endpoint[:i], "[]") (internal/sub/clash_external.go:235)
  • Host rows: stored bare via parseHostAndPort (internal/web/service/host.go:117), pinned by TestParseHostAndPort_IPv6EdgeCases (internal/web/service/host_test.go:278: {"[2001:db8::1]", 8443, "2001:db8::1", 8443})
  • node addresses: netsafe.NormalizeHost strips the brackets and returns ip.String() (internal/util/netsafe/netsafe.go:116-120), used at internal/web/service/node.go:407

Workaround until this is fixed

Set the inbound's Share address strategy back to Node/Listen and put the IPv6 address on a Host row instead (Hosts page → Add Host → Address). A Host address is stored bare, so the Clash proxy gets server: 2001:db8::1, while the raw/share link still comes out correctly bracketed via joinHostPort. Editing the YAML by hand, as you did, works too but is undone on every subscription refresh.

Verdict: Confirmed bug
Severity: Medium
Confidence: High
Root cause: internal/sub/clash_service.go:187 assigns workingInbound.Listen from the resolved dest and clash_service.go:240 (also :315, :397) emits it as the Clash server: without stripping brackets. Triggered whenever resolveInboundAddress (internal/sub/service.go:1298-1326) returns a bracketed host, which today is only the custom share-address strategy with an IPv6 literal, because normalizeInboundShareHost stores it as "[" + ip.String() + "]" (internal/web/service/inbound.go:97,107). Introduced with the strategy itself in 2a7342ba feat: add inbound share address strategy (#5162).
Already fixed: Still present on the default branch (f727d04f, v3.7.0 — the reporter's version is the tip).
Duplicate of: None. Related: #5305 (URI share links needed the brackets; the fix for it, joinHostPort, is what keeps the raw format correct here).
Evidence: internal/web/service/inbound.go:107 return "[" + ip.String() + "]", nil; internal/web/service/inbound_update_tag_test.go:176-177 pins the bracketed storage as intended; internal/sub/service.go:1315 candidates = []string{strings.TrimSpace(inbound.ShareAddr), nodeAddr, listenAddr}; internal/sub/clash_service.go:187, :240, :315, :397; internal/sub/service.go:1050-1052 host = strings.Trim(host, "[]") (why raw links are fine); internal/sub/clash_external.go:235, internal/web/service/host.go:117, internal/util/netsafe/netsafe.go:116-120 (three places that already emit a bare host).
Not determined: I could not run mihomo here, so mihomo's exact failure mode on a bracketed server: is taken from your report rather than verified. The JSON subscription emits the same bracketed value as "address" (internal/sub/json_service.go:706, :732, :813); whether xray-core accepts that is untested here — fetching the JSON subscription for the same inbound and importing it would settle it.

Suggested fix: strip the brackets once where the Clash renderer takes the dest (internal/sub/clash_service.go:187), since all three proxy builders read inbound.Listen from there. Changing the stored form instead would be wider than the bug and would break internal/sub/service.go:781 (fmt.Fprintf(&b, "Endpoint = %s:%d", host, port)), which relies on the brackets already being present.

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

<!-- gh-comment-id:5475765892 --> @github-actions[bot] commented on GitHub (Aug 31, 2026): Confirmed — this is a real bug and it is still present on the default branch (`f727d04f`, v3.7.0). The Clash renderer copies the resolved share address into the proxy's `server:` field verbatim, and for `Share address strategy: Custom` the panel deliberately stores that address **with** brackets, so mihomo/Clash Verge receives `server: "[2001:db8::1]"` instead of `server: 2001:db8::1`. (I can't open images attached to an issue, so I did not read your screenshots — but the two behaviours you describe in text are exactly what the code does, so nothing further is needed from you.) ### The chain 1. Saving the inbound normalizes the custom share address and *adds* the brackets. That is intentional and pinned by a test, which is why you cannot remove them from the UI — every save puts them back: ```go // internal/web/service/inbound.go:107 return "[" + ip.String() + "]", nil ``` ```go // internal/web/service/inbound_update_tag_test.go:176 {name: "bare ipv6", addr: "2001:db8::1", want: "[2001:db8::1]"}, ``` 2. The subscription resolver returns that stored value unchanged for the `custom` strategy: ```go // internal/sub/service.go:1315 candidates = []string{strings.TrimSpace(inbound.ShareAddr), nodeAddr, listenAddr} ``` 3. The Clash renderer takes it as the proxy `dest` and writes it straight into `server:`: ```go // internal/sub/clash_service.go:187 workingInbound.Listen, _ = extPrxy["dest"].(string) // internal/sub/clash_service.go:240 "server": inbound.Listen, ``` The same `inbound.Listen` is used at `clash_service.go:315` (hysteria / hysteria2) and `clash_service.go:397` (wireguard), so every protocol is affected. Raw share links are **not** affected, because they go through `joinHostPort`, which strips any stored brackets and re-adds exactly one (`internal/sub/service.go:1050-1052`) — that helper exists because of the opposite complaint in #5305. A Clash `server:` value is a bare host, not a URI authority, so it must not be bracketed — and the panel's other paths already treat it that way, which is why only the custom share address hits this: - external subscription links: `host := strings.Trim(endpoint[:i], "[]")` (`internal/sub/clash_external.go:235`) - Host rows: stored bare via `parseHostAndPort` (`internal/web/service/host.go:117`), pinned by `TestParseHostAndPort_IPv6EdgeCases` (`internal/web/service/host_test.go:278`: `{"[2001:db8::1]", 8443, "2001:db8::1", 8443}`) - node addresses: `netsafe.NormalizeHost` strips the brackets and returns `ip.String()` (`internal/util/netsafe/netsafe.go:116-120`), used at `internal/web/service/node.go:407` ### Workaround until this is fixed Set the inbound's **Share address strategy** back to `Node`/`Listen` and put the IPv6 address on a **Host** row instead (Hosts page → *Add Host* → *Address*). A Host address is stored bare, so the Clash proxy gets `server: 2001:db8::1`, while the raw/share link still comes out correctly bracketed via `joinHostPort`. Editing the YAML by hand, as you did, works too but is undone on every subscription refresh. Verdict: Confirmed bug Severity: Medium Confidence: High Root cause: `internal/sub/clash_service.go:187` assigns `workingInbound.Listen` from the resolved `dest` and `clash_service.go:240` (also `:315`, `:397`) emits it as the Clash `server:` without stripping brackets. Triggered whenever `resolveInboundAddress` (`internal/sub/service.go:1298-1326`) returns a bracketed host, which today is only the `custom` share-address strategy with an IPv6 literal, because `normalizeInboundShareHost` stores it as `"[" + ip.String() + "]"` (`internal/web/service/inbound.go:97,107`). Introduced with the strategy itself in `2a7342ba feat: add inbound share address strategy (#5162)`. Already fixed: Still present on the default branch (`f727d04f`, v3.7.0 — the reporter's version is the tip). Duplicate of: None. Related: #5305 (URI share links needed the brackets; the fix for it, `joinHostPort`, is what keeps the raw format correct here). Evidence: `internal/web/service/inbound.go:107` `return "[" + ip.String() + "]", nil`; `internal/web/service/inbound_update_tag_test.go:176-177` pins the bracketed storage as intended; `internal/sub/service.go:1315` `candidates = []string{strings.TrimSpace(inbound.ShareAddr), nodeAddr, listenAddr}`; `internal/sub/clash_service.go:187`, `:240`, `:315`, `:397`; `internal/sub/service.go:1050-1052` `host = strings.Trim(host, "[]")` (why raw links are fine); `internal/sub/clash_external.go:235`, `internal/web/service/host.go:117`, `internal/util/netsafe/netsafe.go:116-120` (three places that already emit a bare host). Not determined: I could not run mihomo here, so mihomo's exact failure mode on a bracketed `server:` is taken from your report rather than verified. The JSON subscription emits the same bracketed value as `"address"` (`internal/sub/json_service.go:706`, `:732`, `:813`); whether xray-core accepts that is untested here — fetching the JSON subscription for the same inbound and importing it would settle it. Suggested fix: strip the brackets once where the Clash renderer takes the dest (`internal/sub/clash_service.go:187`), since all three proxy builders read `inbound.Listen` from there. Changing the stored form instead would be wider than the bug and would break `internal/sub/service.go:781` (`fmt.Fprintf(&b, "Endpoint = %s:%d", host, port)`), which relies on the brackets already being present. *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
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#4326
No description provided.