send a symmetric ping packet if appropriate when pinging nodes

This commit is contained in:
Stephen Birarda 2014-03-28 09:11:20 -07:00
parent f80b415497
commit 8b1b2d8d99
2 changed files with 8 additions and 3 deletions

View file

@ -791,7 +791,7 @@ QByteArray NodeList::constructPingReplyPacket(const QByteArray& pingPacket) {
return replyPacket;
}
void NodeList::pingPublicAndLocalSocketsForInactiveNode(const SharedNodePointer& node) {
void NodeList::pingPunchForInactiveNode(const SharedNodePointer& node) {
// send the ping packet to the local and public sockets for this node
QByteArray localPingPacket = constructPingPacket(PingType::Local);
@ -799,6 +799,11 @@ void NodeList::pingPublicAndLocalSocketsForInactiveNode(const SharedNodePointer&
QByteArray publicPingPacket = constructPingPacket(PingType::Public);
writeDatagram(publicPingPacket, node, node->getPublicSocket());
if (!node->getSymmetricSocket().isNull()) {
QByteArray symmetricPingPacket = constructPingPacket(PingType::Symmetric);
writeDatagram(symmetricPingPacket, node, node->getSymmetricSocket());
}
}
SharedNodePointer NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType,
@ -869,7 +874,7 @@ void NodeList::pingInactiveNodes() {
foreach (const SharedNodePointer& node, getNodeHash()) {
if (!node->getActiveSocket()) {
// we don't have an active link to this node, ping it to set that up
pingPublicAndLocalSocketsForInactiveNode(node);
pingPunchForInactiveNode(node);
}
}
}

View file

@ -102,7 +102,7 @@ public:
QByteArray constructPingPacket(PingType_t pingType = PingType::Agnostic);
QByteArray constructPingReplyPacket(const QByteArray& pingPacket);
void pingPublicAndLocalSocketsForInactiveNode(const SharedNodePointer& node);
void pingPunchForInactiveNode(const SharedNodePointer& node);
SharedNodePointer nodeWithUUID(const QUuid& nodeUUID, bool blockingLock = true);
SharedNodePointer sendingNodeForPacket(const QByteArray& packet);