Skip to content

Support IPv6 node URLs in the cluster session#170

Merged
HTHou merged 1 commit into
apache:mainfrom
PDGGK:fix/ipv6-node-url
Jul 24, 2026
Merged

Support IPv6 node URLs in the cluster session#170
HTHou merged 1 commit into
apache:mainfrom
PDGGK:fix/ipv6-node-url

Conversation

@PDGGK

@PDGGK PDGGK commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Problem

The cluster session parses node URLs with strings.Split(url, ":"), reading [0] as host and [1] as port. This mis-parses an IPv6 endpoint: [::1]:6667 resolves to host [ and an empty port instead of host ::1 / port 6667. The client's own output path already brackets IPv6 via net.JoinHostPort, so the input and output paths are inconsistent.

Fix

Parse node URLs with net.SplitHostPort via a new parseNodeURL helper, which accepts the bracketed [ipv6]:port form (consistent with apache/iotdb#18162) in addition to IPv4 and hostnames, and rejects malformed URLs with an error instead of silently mis-parsing them. A bare (unbracketed) IPv6 address with a port is ambiguous and rejected; the [ipv6]:port form must be used.

Wildcard-address filtering (the other half of #18162) is not applicable to the Go client: it does not connect to server-provided redirect endpoints - it treats RedirectionRecommend as success and keeps its current connection - unlike the Java/Python/C++ node-discovery and redirection paths.

Tests

TestParseNodeURL covers IPv4, hostname, and bracketed IPv6 ([::1]:6667, [2001:db8::1]:6667), plus malformed inputs (bare IPv6, missing port, unbalanced bracket, empty host/port). Parsing is unit-tested including the [::1] loopback address; a live IPv6-loopback connection test (as in #18162) would need an IPv6-capable test server, which I'm happy to add as a follow-up if the client CI supports it. go build ./... and go test ./client/ pass.

Follows the dev@ "[DISCUSS] Improve IPv6 endpoint support" thread; one focused PR per client as @HTHou suggested.

Cluster node URLs were split with strings.Split(url, ":"), which mis-parses
an IPv6 endpoint: "[::1]:6667" resolves to host "[" and an empty port instead
of host "::1" / port "6667", while the client's own output path already
brackets IPv6 via net.JoinHostPort.

Parse node URLs with net.SplitHostPort via a new parseNodeURL helper, which
accepts the bracketed [ipv6]:port form (consistent with apache/iotdb#18162)
in addition to IPv4 and hostnames, and rejects malformed URLs with an error
instead of silently mis-parsing them. Add unit tests covering IPv4, hostname,
and bracketed IPv6, plus malformed inputs.

Signed-off-by: Zihan Dai <99155080+PDGGK@users.noreply.github.com>

@HTHou HTHou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HTHou
HTHou merged commit d8b1027 into apache:main Jul 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants