mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-06 12:12:59 +02:00
Merge pull request #995 from daleglass-overte/improve-network-debugging
Improve network debugging messages to help with Conan PR
This commit is contained in:
commit
6c754c1ef2
5 changed files with 37 additions and 21 deletions
|
@ -41,7 +41,7 @@
|
|||
|
||||
#if defined(Q_OS_WIN)
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
|
@ -501,7 +501,7 @@ qint64 LimitedNodeList::sendUnreliableUnorderedPacketList(NLPacketList& packetLi
|
|||
}
|
||||
return bytesSent;
|
||||
} else {
|
||||
qCDebug(networking) << "LimitedNodeList::sendUnreliableUnorderedPacketList called without active socket for node"
|
||||
qCDebug(networking) << "LimitedNodeList::sendUnreliableUnorderedPacketList called without active socket for node"
|
||||
<< destinationNode << " - not sending.";
|
||||
return ERROR_SENDING_PACKET_BYTES;
|
||||
}
|
||||
|
@ -1143,7 +1143,7 @@ void LimitedNodeList::startSTUNPublicSocketUpdate() {
|
|||
if (_stunSockAddr.getAddress().isNull()) {
|
||||
|
||||
// if we fail to lookup the socket then timeout the STUN address lookup
|
||||
connect(&_stunSockAddr, &SockAddr::lookupFailed, this, &LimitedNodeList::possiblyTimeoutSTUNAddressLookup);
|
||||
connect(&_stunSockAddr, &SockAddr::lookupFailed, this, &LimitedNodeList::STUNAddressLookupFailed);
|
||||
|
||||
// immediately send a STUN request once we know the socket
|
||||
connect(&_stunSockAddr, &SockAddr::lookupCompleted, this, &LimitedNodeList::sendSTUNRequest);
|
||||
|
@ -1157,7 +1157,7 @@ void LimitedNodeList::startSTUNPublicSocketUpdate() {
|
|||
QTimer* lookupTimeoutTimer = new QTimer { this };
|
||||
lookupTimeoutTimer->setSingleShot(true);
|
||||
|
||||
connect(lookupTimeoutTimer, &QTimer::timeout, this, &LimitedNodeList::possiblyTimeoutSTUNAddressLookup);
|
||||
connect(lookupTimeoutTimer, &QTimer::timeout, this, &LimitedNodeList::STUNAddressLookupTimeout);
|
||||
|
||||
// delete the lookup timeout timer once it has fired
|
||||
connect(lookupTimeoutTimer, &QTimer::timeout, lookupTimeoutTimer, &QTimer::deleteLater);
|
||||
|
@ -1172,10 +1172,18 @@ void LimitedNodeList::startSTUNPublicSocketUpdate() {
|
|||
}
|
||||
}
|
||||
|
||||
void LimitedNodeList::possiblyTimeoutSTUNAddressLookup() {
|
||||
void LimitedNodeList::STUNAddressLookupFailed() {
|
||||
if (_stunSockAddr.getAddress().isNull()) {
|
||||
// got a lookup failure
|
||||
qCCritical(networking) << "PAGE: Failed to lookup address of STUN server" << STUN_SERVER_HOSTNAME;
|
||||
stopInitialSTUNUpdate(false);
|
||||
}
|
||||
}
|
||||
|
||||
void LimitedNodeList::STUNAddressLookupTimeout() {
|
||||
if (_stunSockAddr.getAddress().isNull()) {
|
||||
// our stun address is still NULL, but we've been waiting for long enough - time to force a fail
|
||||
qCCritical(networking) << "PAGE: Failed to lookup address of STUN server" << STUN_SERVER_HOSTNAME;
|
||||
qCCritical(networking) << "PAGE: Address lookup of STUN server" << STUN_SERVER_HOSTNAME << "timed out";
|
||||
stopInitialSTUNUpdate(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -483,7 +483,8 @@ protected:
|
|||
|
||||
private slots:
|
||||
void flagTimeForConnectionStep(ConnectionStep connectionStep, quint64 timestamp);
|
||||
void possiblyTimeoutSTUNAddressLookup();
|
||||
void STUNAddressLookupTimeout();
|
||||
void STUNAddressLookupFailed();
|
||||
void addSTUNHandlerToUnfiltered(); // called once STUN socket known
|
||||
|
||||
private:
|
||||
|
|
|
@ -67,12 +67,13 @@ SockAddr::SockAddr(SocketType socketType, const QString& hostname, quint16 hostO
|
|||
if (_address.protocol() != QAbstractSocket::IPv4Protocol) {
|
||||
// lookup the IP by the hostname
|
||||
if (shouldBlockForLookup) {
|
||||
qCDebug(networking) << "Synchronously looking up IP address for hostname" << hostname;
|
||||
qCDebug(networking) << "Synchronously looking up IP address for hostname" << hostname << "for" << socketType << "socket on port" << hostOrderPort;
|
||||
QHostInfo result = QHostInfo::fromName(hostname);
|
||||
handleLookupResult(result);
|
||||
} else {
|
||||
int lookupID = QHostInfo::lookupHost(hostname, this, SLOT(handleLookupResult(QHostInfo)));
|
||||
qCDebug(networking) << "Asynchronously looking up IP address for hostname" << hostname << "- lookup ID is" << lookupID;
|
||||
qCDebug(networking) << "Asynchronously looking up IP address for hostname" << hostname << "for" << socketType << "socket on port" << hostOrderPort;
|
||||
int lookupID = QHostInfo::lookupHost(hostname, this, &SockAddr::handleLookupResult);
|
||||
qCDebug(networking) << "Lookup ID for " << hostname << "is" << lookupID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +96,8 @@ bool SockAddr::operator==(const SockAddr& rhsSockAddr) const {
|
|||
}
|
||||
|
||||
void SockAddr::handleLookupResult(const QHostInfo& hostInfo) {
|
||||
qCDebug(networking) << "handleLookupResult for" << hostInfo.lookupId();
|
||||
|
||||
if (hostInfo.error() != QHostInfo::NoError) {
|
||||
qCDebug(networking) << "Lookup failed for" << hostInfo.lookupId() << ":" << hostInfo.errorString();
|
||||
emit lookupFailed();
|
||||
|
|
|
@ -36,6 +36,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
inline QDebug operator<<(QDebug debug, SocketType type) {
|
||||
debug << SocketTypeToString::socketTypeToString(type);
|
||||
return debug;
|
||||
}
|
||||
/// @}
|
||||
|
||||
#endif // overte_SocketType_h
|
||||
|
|
|
@ -45,7 +45,7 @@ void NetworkSocket::setSocketOption(SocketType socketType, QAbstractSocket::Sock
|
|||
break;
|
||||
#endif
|
||||
default:
|
||||
qCCritical(networking) << "Socket type not specified in setSocketOption()";
|
||||
qCCritical(networking) << "Socket type" << socketType << "not recognized in setSocketOption()";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ QVariant NetworkSocket::socketOption(SocketType socketType, QAbstractSocket::Soc
|
|||
return _webrtcSocket.socketOption(option);
|
||||
#endif
|
||||
default:
|
||||
qCCritical(networking) << "Socket type not specified in socketOption()";
|
||||
qCCritical(networking) << "Socket type" << socketType << "not recognized in socketOption()";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ void NetworkSocket::bind(SocketType socketType, const QHostAddress& address, qui
|
|||
break;
|
||||
#endif
|
||||
default:
|
||||
qCCritical(networking) << "Socket type not specified in bind()";
|
||||
qCCritical(networking) << "Socket type" << socketType << "not recognized in bind()";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ void NetworkSocket::abort(SocketType socketType) {
|
|||
break;
|
||||
#endif
|
||||
default:
|
||||
qCCritical(networking) << "Socket type not specified in abort()";
|
||||
qCCritical(networking) << "Socket type" << socketType << "not recognized in abort()";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ quint16 NetworkSocket::localPort(SocketType socketType) const {
|
|||
return _webrtcSocket.localPort();
|
||||
#endif
|
||||
default:
|
||||
qCCritical(networking) << "Socket type not specified in localPort()";
|
||||
qCCritical(networking) << "Socket type" << socketType << "not recognized in localPort()";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ qintptr NetworkSocket::socketDescriptor(SocketType socketType) const {
|
|||
return 0;
|
||||
#endif
|
||||
default:
|
||||
qCCritical(networking) << "Socket type not specified in socketDescriptor()";
|
||||
qCCritical(networking) << "Socket type" << socketType << "not recognized in socketDescriptor()";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ qint64 NetworkSocket::writeDatagram(const QByteArray& datagram, const SockAddr&
|
|||
return _webrtcSocket.writeDatagram(datagram, sockAddr);
|
||||
#endif
|
||||
default:
|
||||
qCCritical(networking) << "Socket type not specified in writeDatagram() address";
|
||||
qCCritical(networking) << "Socket type" << sockAddr.getType() << "not recognized in writeDatagram() address";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ qint64 NetworkSocket::bytesToWrite(SocketType socketType, const SockAddr& addres
|
|||
return _webrtcSocket.bytesToWrite(address);
|
||||
#endif
|
||||
default:
|
||||
qCCritical(networking) << "Socket type not specified in bytesToWrite()";
|
||||
qCCritical(networking) << "Socket type" << socketType << "not recognized in bytesToWrite()";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ QAbstractSocket::SocketState NetworkSocket::state(SocketType socketType) const {
|
|||
return _webrtcSocket.state();
|
||||
#endif
|
||||
default:
|
||||
qCCritical(networking) << "Socket type not specified in state()";
|
||||
qCCritical(networking) << "Socket type" << socketType << "not recognized in state()";
|
||||
return QAbstractSocket::SocketState::UnconnectedState;
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ QAbstractSocket::SocketError NetworkSocket::error(SocketType socketType) const {
|
|||
return _webrtcSocket.error();
|
||||
#endif
|
||||
default:
|
||||
qCCritical(networking) << "Socket type not specified in error()";
|
||||
qCCritical(networking) << "Socket type" << socketType << "not recognized in error()";
|
||||
return QAbstractSocket::SocketError::UnknownSocketError;
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ QString NetworkSocket::errorString(SocketType socketType) const {
|
|||
return _webrtcSocket.errorString();
|
||||
#endif
|
||||
default:
|
||||
qCCritical(networking) << "Socket type not specified in errorString()";
|
||||
qCCritical(networking) << "Socket type" << socketType << "not recognized in errorString()";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue