mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:42:58 +02:00
prefer IPv4 address when looking up for domain IP
This commit is contained in:
parent
a9efa169be
commit
b4f9e393a4
1 changed files with 15 additions and 9 deletions
|
@ -106,7 +106,7 @@ void NodeList::setDomainHostname(const QString& domainHostname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset our _domainIP to the null address so that a lookup happens on next check in
|
// reset our _domainIP to the null address so that a lookup happens on next check in
|
||||||
_domainIP = QHostAddress();
|
_domainIP.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::timePingReply(sockaddr *nodeAddress, unsigned char *packetData) {
|
void NodeList::timePingReply(sockaddr *nodeAddress, unsigned char *packetData) {
|
||||||
|
@ -283,15 +283,21 @@ void NodeList::sendDomainServerCheckIn(const char* assignmentUUID) {
|
||||||
|
|
||||||
QHostInfo domainServerHostInfo = QHostInfo::fromName(_domainHostname);
|
QHostInfo domainServerHostInfo = QHostInfo::fromName(_domainHostname);
|
||||||
|
|
||||||
if (!domainServerHostInfo.addresses().isEmpty()) {
|
for (int i = 0; i < domainServerHostInfo.addresses().size(); i++) {
|
||||||
// set our domainIP to the first IP address
|
if (domainServerHostInfo.addresses()[i].protocol() == QAbstractSocket::IPv4Protocol) {
|
||||||
_domainIP = domainServerHostInfo.addresses().first();
|
_domainIP = domainServerHostInfo.addresses()[i];
|
||||||
|
|
||||||
|
qDebug("DS at %s is at %s\n", _domainHostname.toStdString().c_str(), _domainIP.toString().toStdString().c_str());
|
||||||
|
|
||||||
|
printedDomainServerIP = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
qDebug("DS at %s is at %s\n", _domainHostname.toStdString().c_str(), _domainIP.toString().toStdString().c_str());
|
// if we got here without a break out of the for loop then we failed to lookup the address
|
||||||
|
if (i == domainServerHostInfo.addresses().size() - 1) {
|
||||||
printedDomainServerIP = true;
|
qDebug("Failed domain server lookup\n");
|
||||||
} else {
|
}
|
||||||
qDebug("Failed domain server lookup\n");
|
|
||||||
}
|
}
|
||||||
} else if (!printedDomainServerIP) {
|
} else if (!printedDomainServerIP) {
|
||||||
qDebug("Domain Server IP: %s\n", _domainIP.toString().toStdString().c_str());
|
qDebug("Domain Server IP: %s\n", _domainIP.toString().toStdString().c_str());
|
||||||
|
|
Loading…
Reference in a new issue