always remove old socket-matching node before add

This commit is contained in:
Stephen Birarda 2018-08-24 14:21:54 -07:00
parent cb4ce4fedb
commit d8b5a1a4a6

View file

@ -463,19 +463,15 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect
limitedNodeList->eachNodeBreakable([nodeConnection, username, &existingNodeID](const SharedNodePointer& node){ limitedNodeList->eachNodeBreakable([nodeConnection, username, &existingNodeID](const SharedNodePointer& node){
if (node->getPublicSocket() == nodeConnection.publicSockAddr && node->getLocalSocket() == nodeConnection.localSockAddr) { if (node->getPublicSocket() == nodeConnection.publicSockAddr && node->getLocalSocket() == nodeConnection.localSockAddr) {
// we have a node that already has these exact sockets - this can occur if a node // we have a node that already has these exact sockets
// is failing to connect to the domain // this can occur if a node is failing to connect to the domain
// we'll re-use the existing node ID // remove the old node before adding the new node
// as long as the user hasn't changed their username (by logging in or logging out) qDebug() << "Deleting existing connection from same sockaddr: " << node->getUUID();
auto existingNodeData = static_cast<DomainServerNodeData*>(node->getLinkedData()); existingNodeID = node->getUUID();
return false;
if (existingNodeData->getUsername() == username) {
qDebug() << "Deleting existing connection from same sockaddr: " << node->getUUID();
existingNodeID = node->getUUID();
return false;
}
} }
return true; return true;
}); });