[SERVER-9612] Mongos not parsing correctly IPV6 address Created: 07/May/13  Updated: 06/May/16  Resolved: 06/May/16

Status: Closed
Project: Core Server
Component/s: Networking
Affects Version/s: 2.4.3
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Lahoucine BENLAHMR Assignee: Waley Chen
Resolution: Done Votes: 0
Labels: pull-request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-11664 Fix IPv6 address parsing Closed
is related to SERVER-5436 IPv6 address ambiguity in HostPort sy... Closed
Operating System: ALL
Steps To Reproduce:

./mongos --ipv6 --configdb 2001:0db8:0000:85a3:0000:0000:ac1f:8001:5000

Sprint: Platforms 14 (05/13/16)
Participants:

 Description   

When you start the mongos instance and specify the adresse of a config server, and this address is an IPV6, mongos can't resolve it because it parse it as a normal IP or hostname.

https://github.com/mongodb/mongo/blob/master/src/mongo/s/config.cpp#L984
to resolve this issue we can remplace:

 if ( name.find( ":" ) != string::npos ) {
            if ( withPort )
                return name;
            return name.substr( 0 , name.find( ":" ) );
        }

by:

 if ( name.find( ":" ) != string::npos ) {
            if ( withPort )
                return name;
            return name.substr( 0 , name.find_last_of( ":" ) );
        }


Example:

2001:0db8:0000:85a3:0000:0000:ac1f:8001:port

mongos will try to resolve "2001" as the host part of the adresse intead of 2001:0db8:0000:85a3:0000:0000:ac1f:8001



 Comments   
Comment by Justin Cohler [ 06/May/16 ]

This parsing issue has gone away. Please see the expected functionality below for the reproducing steps:

$ ./mongos --ipv6 --configdb 2001:0db8:0000:85a3:0000:0000:ac1f:8001:5000
FailedToParse: More than one ':' detected. If this is an ipv6 address, it needs to be surrounded by '[' and ']'; 2001:0db8:0000:85a3:0000:0000:ac1f:8001:5000
try './mongos --help' for more information

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