Skip to content

Commit 76e050b

Browse files
smithdhamadio
authored andcommitted
[Cl] Also recognise IPv4 mapped addresses
1 parent c958645 commit 76e050b

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/XrdCl/XrdClURL.cc

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "XrdCl/XrdClOptimizers.hh"
2727

2828
#include <cstdlib>
29+
#include <cctype>
2930
#include <vector>
3031
#include <sstream>
3132
#include <algorithm>
@@ -238,13 +239,23 @@ namespace XrdCl
238239
// Check if we're IPv6 encoded IPv4
239240
//----------------------------------------------------------------------
240241
pos = pHostName.find( "." );
241-
size_t pos2 = pHostName.find( "[::ffff" );
242-
size_t pos3 = pHostName.find( "[::" );
243-
if( pos != std::string::npos && pos3 != std::string::npos &&
244-
pos2 == std::string::npos )
242+
const size_t pos2 = pHostName.find( "[::" );
243+
if( pos != std::string::npos && pos2 != std::string::npos )
245244
{
246-
pHostName.erase( 0, 3 );
247-
pHostName.erase( pHostName.length()-1, 1 );
245+
std::string hl = pHostName;
246+
std::transform(hl.begin(), hl.end(), hl.begin(),
247+
[](unsigned char c){ return std::tolower(c); });
248+
const size_t pos3 = hl.find( "[::ffff:" );
249+
if ( pos3 != std::string::npos )
250+
{
251+
pHostName.erase( 0, 8 );
252+
pHostName.erase( pHostName.length()-1, 1 );
253+
}
254+
else
255+
{
256+
pHostName.erase( 0, 3 );
257+
pHostName.erase( pHostName.length()-1, 1 );
258+
}
248259
}
249260
}
250261
}

0 commit comments

Comments
 (0)