mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 04:37:48 +02:00
Merge pull request #10772 from birarda/bug/domain-double-connect
use existing node ID during repeated connect requests
This commit is contained in:
commit
01d9812247
2 changed files with 30 additions and 7 deletions
|
@ -435,8 +435,29 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect
|
||||||
return SharedNodePointer();
|
return SharedNodePointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUuid hintNodeID;
|
||||||
|
|
||||||
|
// in case this is a node that's failing to connect
|
||||||
|
// double check we don't have the same node whose sockets match exactly already in the list
|
||||||
|
limitedNodeList->eachNodeBreakable([&](const SharedNodePointer& node){
|
||||||
|
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
|
||||||
|
// is failing to connect to the domain
|
||||||
|
|
||||||
|
// we'll re-use the existing node ID
|
||||||
|
// as long as the user hasn't changed their username (by logging in or logging out)
|
||||||
|
auto existingNodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||||
|
|
||||||
|
if (existingNodeData->getUsername() == username) {
|
||||||
|
hintNodeID = node->getUUID();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
// add the connecting node (or re-use the matched one from eachNodeBreakable above)
|
// add the connecting node (or re-use the matched one from eachNodeBreakable above)
|
||||||
SharedNodePointer newNode = addVerifiedNodeFromConnectRequest(nodeConnection);
|
SharedNodePointer newNode = addVerifiedNodeFromConnectRequest(nodeConnection, hintNodeID);
|
||||||
|
|
||||||
// set the edit rights for this user
|
// set the edit rights for this user
|
||||||
newNode->setPermissions(userPerms);
|
newNode->setPermissions(userPerms);
|
||||||
|
@ -464,12 +485,11 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect
|
||||||
return newNode;
|
return newNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedNodePointer DomainGatekeeper::addVerifiedNodeFromConnectRequest(const NodeConnectionData& nodeConnection) {
|
SharedNodePointer DomainGatekeeper::addVerifiedNodeFromConnectRequest(const NodeConnectionData& nodeConnection,
|
||||||
|
QUuid nodeID) {
|
||||||
HifiSockAddr discoveredSocket = nodeConnection.senderSockAddr;
|
HifiSockAddr discoveredSocket = nodeConnection.senderSockAddr;
|
||||||
SharedNetworkPeer connectedPeer = _icePeers.value(nodeConnection.connectUUID);
|
SharedNetworkPeer connectedPeer = _icePeers.value(nodeConnection.connectUUID);
|
||||||
|
|
||||||
QUuid nodeID;
|
|
||||||
|
|
||||||
if (connectedPeer) {
|
if (connectedPeer) {
|
||||||
// this user negotiated a connection with us via ICE, so re-use their ICE client ID
|
// this user negotiated a connection with us via ICE, so re-use their ICE client ID
|
||||||
nodeID = nodeConnection.connectUUID;
|
nodeID = nodeConnection.connectUUID;
|
||||||
|
@ -479,8 +499,10 @@ SharedNodePointer DomainGatekeeper::addVerifiedNodeFromConnectRequest(const Node
|
||||||
discoveredSocket = *connectedPeer->getActiveSocket();
|
discoveredSocket = *connectedPeer->getActiveSocket();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// we got a connectUUID we didn't recognize, randomly generate a new one
|
// we got a connectUUID we didn't recognize, either use the hinted node ID or randomly generate a new one
|
||||||
nodeID = QUuid::createUuid();
|
if (nodeID.isNull()) {
|
||||||
|
nodeID = QUuid::createUuid();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
|
|
@ -76,7 +76,8 @@ private:
|
||||||
SharedNodePointer processAgentConnectRequest(const NodeConnectionData& nodeConnection,
|
SharedNodePointer processAgentConnectRequest(const NodeConnectionData& nodeConnection,
|
||||||
const QString& username,
|
const QString& username,
|
||||||
const QByteArray& usernameSignature);
|
const QByteArray& usernameSignature);
|
||||||
SharedNodePointer addVerifiedNodeFromConnectRequest(const NodeConnectionData& nodeConnection);
|
SharedNodePointer addVerifiedNodeFromConnectRequest(const NodeConnectionData& nodeConnection,
|
||||||
|
QUuid nodeID = QUuid());
|
||||||
|
|
||||||
bool verifyUserSignature(const QString& username, const QByteArray& usernameSignature,
|
bool verifyUserSignature(const QString& username, const QByteArray& usernameSignature,
|
||||||
const HifiSockAddr& senderSockAddr);
|
const HifiSockAddr& senderSockAddr);
|
||||||
|
|
Loading…
Reference in a new issue