diff --git a/src/clientrpc.cpp b/src/clientrpc.cpp index 9ba7060a1d..61f8307805 100644 --- a/src/clientrpc.cpp +++ b/src/clientrpc.cpp @@ -190,7 +190,7 @@ CClientRpc::CClientRpc ( CClient* pClient, CClientSettings* pSettings, CRpcServe CHostAddress haDirectoryAddress; // Allow IPv4 only for communicating with Directories - if ( NetworkUtil::ParseNetworkAddress ( jsonDirectoryIp.toString(), haDirectoryAddress, false ) ) + if ( NetworkUtil::ParseNetworkAddress ( jsonDirectoryIp.toString(), haDirectoryAddress, pClient->IsIPv6Available() ) ) { // send the request for the server list pClient->CreateCLReqServerListMes ( haDirectoryAddress ); diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index 05127ded37..7ad0f0b159 100644 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -355,7 +355,7 @@ void CConnectDlg::RequestServerList() if ( NetworkUtil::ParseNetworkAddress ( NetworkUtil::GetDirectoryAddress ( pSettings->eDirectoryType, pSettings->vstrDirectoryAddress[pSettings->iCustomDirectoryIndex] ), haDirectoryAddress, - false ) ) + pClient->IsIPv6Available() ) ) { // send the request for the server list emit ReqServerListQuery ( haDirectoryAddress ); diff --git a/src/global.h b/src/global.h index 5414a58c41..bfc0448c1e 100644 --- a/src/global.h +++ b/src/global.h @@ -285,7 +285,7 @@ LED bar: lbr #define MAX_LEN_CHAT_TEXT 1600 #define MAX_LEN_CHAT_TEXT_PLUS_HTML 1800 #define MAX_LEN_SERVER_NAME 20 -#define MAX_LEN_IP_ADDRESS 15 +#define MAX_LEN_IP_ADDRESS 39 // 15 for IPv4, 39 for IPv6 #define MAX_LEN_SERVER_CITY 20 #define MAX_LEN_VERSION_TEXT 50 diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 0dafa73863..186b924fe3 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -1012,7 +1012,7 @@ void CServerListManager::SetRegistered ( const bool bIsRegister ) // Allow IPv4 only for communicating with Directories // Use SRV DNS discovery for directory connections, fallback to A/AAAA if none. const QString strNetworkAddress = NetworkUtil::GetDirectoryAddress ( DirectoryType, strDirectoryAddress ); - const bool bDirectoryAddressValid = NetworkUtil::ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, false ); + const bool bDirectoryAddressValid = NetworkUtil::ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, pServer->IsIPv6Available() ); // lock the mutex again now that the address has been resolved. locker.relock(); @@ -1027,7 +1027,18 @@ void CServerListManager::SetRegistered ( const bool bIsRegister ) // For a registered server, the server properties are stored in the // very first item in the server list (which is actually no server list // but just one item long for the registered server). - pConnLessProtocol->CreateCLRegisterServerExMes ( DirectoryAddress, ServerList[0].LHostAddr, ServerList[0] ); + if ( DirectoryAddress.InetAddr.protocol() == QAbstractSocket::IPv4Protocol ) + { + pConnLessProtocol->CreateCLRegisterServerExMes ( DirectoryAddress, ServerPublicIP, ServerList[0] ); + } + else if ( DirectoryAddress.InetAddr.protocol() == QAbstractSocket::IPv6Protocol ) + { + pConnLessProtocol->CreateCLRegisterServerExMes ( DirectoryAddress, ServerPublicIP6, ServerList[0] ); + } + else + { + SetSvrRegStatus ( SRS_BAD_ADDRESS ); + } } else { diff --git a/src/serverlist.h b/src/serverlist.h index f18c40678d..171ffb47d3 100644 --- a/src/serverlist.h +++ b/src/serverlist.h @@ -139,7 +139,7 @@ class CServerListEntry : public CServerInfo QString strCountry, QString strNumClients, bool isPermanent, - bool bEnableIPv6 ); + bool bIPv6Available ); QString toCSV(); // time on which the entry was registered