-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.1.0
-
Component/s: Networking
-
ALL
The syntax used for representing HostPorts (as parsed here: https://github.com/mongodb/mongo/blob/master/src/mongo/util/net/hostandport.h#L209) is ambiguous with respect to IPv6 addresses.
For example, ::1:1234 could either mean host ::1:1234, port unspecified, or host ::1, port 1234. The code in hostport.h will serialise both of these forms into the same syntax, but will always parse using the latter interpretation.
This creates problems for drivers, which need to be able to correctly parse things like the hosts in the ismaster response, which are representing using this serialised form.
Proposal: IPv6 addresses must be wrapped in square brackets in HostAndPort strings that do have a terminal :port part, and maybe at other times. HostAndPort::host will return the string without the square brackets, but when serializing HostAndPort to a string, the square brackets will be placed around the address portion. So,
HostAndPort("[::1234]:56").host() == "::1234" HostAndPort("[::1234]:56").toString() == "[::1234]:56"
- is duplicated by
-
SERVER-11664 Fix IPv6 address parsing
- Closed
- related to
-
SERVER-15835 Ipv6 address parsing still accepts ambiguous strings
- Closed
-
SERVER-9612 Mongos not parsing correctly IPV6 address
- Closed