From 3a4d367e12497e4ad8bdffb6dde3b94de9e3d4a4 Mon Sep 17 00:00:00 2001 From: Sergey Chernomorets Date: Tue, 20 Aug 2024 19:18:14 +0300 Subject: [PATCH] distinguish v6 IP addresses in RaftAdvertise host Avoid error when RaftAdvertise is IPv6 address: ERROR failed to open raft store: address fcff:0:675:2::bf87:10008: too many colons in address --- go/raft/raft.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/go/raft/raft.go b/go/raft/raft.go index dcb8cca2d..6c30b9539 100644 --- a/go/raft/raft.go +++ b/go/raft/raft.go @@ -188,7 +188,12 @@ func normalizeRaftHostnameIP(host string) (string, error) { } // resolve success! for _, ip := range ips { - return ip.String(), nil + addr := net.ParseIP(ip.String()) + if addr != nil && addr.To4() == nil { + return fmt.Sprintf("[%s]", ip.String()), nil + } else { + return ip.String(), nil + } } return host, fmt.Errorf("%+v resolved but no IP found", host) }