mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 23:32:48 +02:00
allow a blocking lookup of IP address in HifiSockAddr
This commit is contained in:
parent
acef1b868c
commit
74753e5b8b
3 changed files with 12 additions and 10 deletions
|
@ -96,17 +96,14 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
||||||
assignmentServerPort =
|
assignmentServerPort =
|
||||||
argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION).toString().toUInt();
|
argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION).toString().toUInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiSockAddr assignmentServerSocket(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME, assignmentServerPort);
|
|
||||||
|
|
||||||
// check for an overriden assignment server hostname
|
// check for an overriden assignment server hostname
|
||||||
if (argumentVariantMap.contains(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION)) {
|
if (argumentVariantMap.contains(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION)) {
|
||||||
_assignmentServerHostname = argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION).toString();
|
|
||||||
|
|
||||||
// change the hostname for our assignment server
|
// change the hostname for our assignment server
|
||||||
assignmentServerSocket = HifiSockAddr(_assignmentServerHostname, assignmentServerSocket.getPort());
|
_assignmentServerHostname = argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HifiSockAddr assignmentServerSocket(_assignmentServerHostname, assignmentServerPort, true);
|
||||||
nodeList->setAssignmentServerSocket(assignmentServerSocket);
|
nodeList->setAssignmentServerSocket(assignmentServerSocket);
|
||||||
|
|
||||||
qDebug() << "Assignment server socket is" << assignmentServerSocket;
|
qDebug() << "Assignment server socket is" << assignmentServerSocket;
|
||||||
|
|
|
@ -36,15 +36,20 @@ HifiSockAddr::HifiSockAddr(const HifiSockAddr& otherSockAddr) {
|
||||||
_port = otherSockAddr._port;
|
_port = otherSockAddr._port;
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiSockAddr::HifiSockAddr(const QString& hostname, quint16 hostOrderPort) :
|
HifiSockAddr::HifiSockAddr(const QString& hostname, quint16 hostOrderPort, bool shouldBlockForLookup) :
|
||||||
_address(hostname),
|
_address(hostname),
|
||||||
_port(hostOrderPort)
|
_port(hostOrderPort)
|
||||||
{
|
{
|
||||||
// if we parsed an IPv4 address out of the hostname, don't look it up
|
// if we parsed an IPv4 address out of the hostname, don't look it up
|
||||||
if (_address.protocol() != QAbstractSocket::IPv4Protocol) {
|
if (_address.protocol() != QAbstractSocket::IPv4Protocol) {
|
||||||
// sync lookup the IP by the hostname
|
// lookup the IP by the hostname
|
||||||
int lookupID = QHostInfo::lookupHost(hostname, this, SLOT(handleLookupResult(QHostInfo)));
|
if (shouldBlockForLookup) {
|
||||||
qDebug() << "Looking up IP address for hostname" << hostname << "- lookup ID is" << lookupID;
|
QHostInfo result = QHostInfo::fromName(hostname);
|
||||||
|
handleLookupResult(result);
|
||||||
|
} else {
|
||||||
|
int lookupID = QHostInfo::lookupHost(hostname, this, SLOT(handleLookupResult(QHostInfo)));
|
||||||
|
qDebug() << "Looking up IP address for hostname" << hostname << "- lookup ID is" << lookupID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
HifiSockAddr();
|
HifiSockAddr();
|
||||||
HifiSockAddr(const QHostAddress& address, quint16 port);
|
HifiSockAddr(const QHostAddress& address, quint16 port);
|
||||||
HifiSockAddr(const HifiSockAddr& otherSockAddr);
|
HifiSockAddr(const HifiSockAddr& otherSockAddr);
|
||||||
HifiSockAddr(const QString& hostname, quint16 hostOrderPort);
|
HifiSockAddr(const QString& hostname, quint16 hostOrderPort, bool shouldBlockForLookup = false);
|
||||||
HifiSockAddr(const sockaddr* sockaddr);
|
HifiSockAddr(const sockaddr* sockaddr);
|
||||||
|
|
||||||
bool isNull() const { return _address.isNull() && _port == 0; }
|
bool isNull() const { return _address.isNull() && _port == 0; }
|
||||||
|
|
Loading…
Reference in a new issue