Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-5436

IPv6 address ambiguity in HostPort syntax

    XMLWordPrintable

    Details

    • Operating System:
      ALL

      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"
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              matt.dannenberg Matt Dannenberg
              Reporter:
              a1kmm Andrew Miller
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: