[SERVER-5436] IPv6 address ambiguity in HostPort syntax Created: 29/Mar/12  Updated: 27/Oct/15  Resolved: 18/Jul/14

Status: Closed
Project: Core Server
Component/s: Networking
Affects Version/s: 2.1.0
Fix Version/s: 2.7.4

Type: Bug Priority: Major - P3
Reporter: Andrew Miller Assignee: Matt Dannenberg
Resolution: Done Votes: 0
Labels: HostPort, ambiguity, cap-ticket-needed, parsing
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by DOCS-1947 Document: IPv6 address ambiguity in H... Closed
Duplicate
is duplicated by SERVER-11664 Fix IPv6 address parsing Closed
Related
related to SERVER-15835 Ipv6 address parsing still accepts am... Closed
related to SERVER-9612 Mongos not parsing correctly IPV6 add... Closed
Tested
Operating System: ALL
Participants:

 Description   

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"



 Comments   
Comment by Githook User [ 18/Jul/14 ]

Author:

{u'username': u'dannenberg', u'name': u'matt dannenberg', u'email': u'matt.dannenberg@10gen.com'}

Message: SERVER-5436 improve ipv6 parsing in HostAndPort
Branch: master
https://github.com/mongodb/mongo/commit/f6cc85d06aaa39cea2baaf8771932bb8c5672cf7

Comment by Githook User [ 18/Jul/14 ]

Author:

{u'username': u'dannenberg', u'name': u'matt dannenberg', u'email': u'matt.dannenberg@10gen.com'}

Message: SERVER-5436 improve ipv6 parsing in HostAndPort
Branch: legacy
https://github.com/mongodb/mongo-cxx-driver/commit/5a1d0568b1318967ab1b76c7cadee668e4dc53d6

Generated at Thu Feb 08 03:08:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.