Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,18 +982,26 @@ bool NetworkUtil::ParseNetworkAddress ( QString strAddress,
// that the string contains a valid host name string
const QHostInfo HostInfo = QHostInfo::fromName ( strAddress );

if ( HostInfo.error() == QHostInfo::NoError )
if ( HostInfo.error() != QHostInfo::NoError )
{
// apply IP address to QT object
if ( !HostInfo.addresses().isEmpty() )
{
// use the first IP address
InetAddr = HostInfo.addresses().first();
}
return false; // invalid address
}
else

// use the first IPv4 address, if any
bool bFoundIPv4 = false;
foreach ( const QHostAddress HostAddr, HostInfo.addresses() )
{
return false; // invalid address
if ( HostAddr.protocol() == QAbstractSocket::IPv4Protocol )
{
InetAddr = HostAddr;
bFoundIPv4 = true;
break;
}
}
if ( !bFoundIPv4 )
{
// only found IPv6 addresses
return false;
}
}

Expand Down