Skip to content

Commit 3a4d367

Browse files
committed
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
1 parent 89f3bdd commit 3a4d367

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

go/raft/raft.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,12 @@ func normalizeRaftHostnameIP(host string) (string, error) {
188188
}
189189
// resolve success!
190190
for _, ip := range ips {
191-
return ip.String(), nil
191+
addr := net.ParseIP(ip.String())
192+
if addr != nil && addr.To4() == nil {
193+
return fmt.Sprintf("[%s]", ip.String()), nil
194+
} else {
195+
return ip.String(), nil
196+
}
192197
}
193198
return host, fmt.Errorf("%+v resolved but no IP found", host)
194199
}

0 commit comments

Comments
 (0)