mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
re-use same socketed node for subsequent connections
This commit is contained in:
parent
2560cd0229
commit
35973d4e30
2 changed files with 29 additions and 10 deletions
|
@ -258,9 +258,26 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect
|
||||||
if (onlyEditorsAreRezzers) {
|
if (onlyEditorsAreRezzers) {
|
||||||
canRez = isAllowedEditor;
|
canRez = isAllowedEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUuid hintNodeID;
|
||||||
|
|
||||||
|
// in case this is a node that's failing to connect
|
||||||
|
// double check we don't have a node whose sockets match exactly already in the list
|
||||||
|
limitedNodeList->eachNodeBreakable([&nodeConnection, &hintNodeID](const SharedNodePointer& node){
|
||||||
|
if (node->getPublicSocket() == nodeConnection.publicSockAddr
|
||||||
|
&& node->getLocalSocket() == nodeConnection.localSockAddr) {
|
||||||
|
// we have a node that already has these exact sockets - this occurs if a node
|
||||||
|
// is unable to connect to the domain
|
||||||
|
hintNodeID = node->getUUID();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
// add the new node
|
// 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->setIsAllowedEditor(isAllowedEditor);
|
newNode->setIsAllowedEditor(isAllowedEditor);
|
||||||
|
@ -279,28 +296,29 @@ 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 nodeUUID;
|
|
||||||
|
|
||||||
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
|
||||||
nodeUUID = nodeConnection.connectUUID;
|
nodeID = nodeConnection.connectUUID;
|
||||||
|
|
||||||
if (connectedPeer->getActiveSocket()) {
|
if (connectedPeer->getActiveSocket()) {
|
||||||
// set their discovered socket to whatever the activated socket on the network peer object was
|
// set their discovered socket to whatever the activated socket on the network peer object was
|
||||||
discoveredSocket = *connectedPeer->getActiveSocket();
|
discoveredSocket = *connectedPeer->getActiveSocket();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// we got a connectUUID we didn't recognize, just add the node with a new UUID
|
// we got a connectUUID we didn't recognize, either use the hinted node ID or randomly generate a new one
|
||||||
nodeUUID = QUuid::createUuid();
|
if (nodeID.isNull()) {
|
||||||
|
nodeID = QUuid::createUuid();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
|
||||||
SharedNodePointer newNode = limitedNodeList->addOrUpdateNode(nodeUUID, nodeConnection.nodeType,
|
SharedNodePointer newNode = limitedNodeList->addOrUpdateNode(nodeID, nodeConnection.nodeType,
|
||||||
nodeConnection.publicSockAddr, nodeConnection.localSockAddr);
|
nodeConnection.publicSockAddr, nodeConnection.localSockAddr);
|
||||||
|
|
||||||
// So that we can send messages to this node at will - we need to activate the correct socket on this node now
|
// So that we can send messages to this node at will - we need to activate the correct socket on this node now
|
||||||
|
|
|
@ -59,7 +59,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