mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-02 21:31:47 +02:00
remove ICE peers once nodes connect or are killed
This commit is contained in:
parent
666bdb03b7
commit
8f6600facf
4 changed files with 34 additions and 5 deletions
|
@ -520,6 +520,10 @@ SharedNodePointer DomainGatekeeper::addVerifiedNodeFromConnectRequest(const Node
|
||||||
// create a new node ID for the verified connecting node
|
// create a new node ID for the verified connecting node
|
||||||
auto nodeID = QUuid::createUuid();
|
auto nodeID = QUuid::createUuid();
|
||||||
|
|
||||||
|
// add a mapping from connection node ID to ICE peer ID
|
||||||
|
// so that we can remove the ICE peer once we see this node connect
|
||||||
|
_nodeToICEPeerIDs.insert(nodeID, nodeConnection.connectUUID);
|
||||||
|
|
||||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
|
||||||
Node::LocalID newLocalID = findOrCreateLocalID(nodeID);
|
Node::LocalID newLocalID = findOrCreateLocalID(nodeID);
|
||||||
|
@ -533,6 +537,15 @@ SharedNodePointer DomainGatekeeper::addVerifiedNodeFromConnectRequest(const Node
|
||||||
return newNode;
|
return newNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DomainGatekeeper::cleanupICEPeerForNode(const QUuid& nodeID) {
|
||||||
|
// remove this node ID from our node to ICE peer ID map
|
||||||
|
// and the associated ICE peer (if it still exists)
|
||||||
|
auto icePeerID = _nodeToICEPeerIDs.take(nodeID);
|
||||||
|
if (!icePeerID.isNull()) {
|
||||||
|
_icePeers.remove(icePeerID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DomainGatekeeper::verifyUserSignature(const QString& username,
|
bool DomainGatekeeper::verifyUserSignature(const QString& username,
|
||||||
const QByteArray& usernameSignature,
|
const QByteArray& usernameSignature,
|
||||||
const HifiSockAddr& senderSockAddr) {
|
const HifiSockAddr& senderSockAddr) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
const QUuid& walletUUID, const QString& nodeVersion);
|
const QUuid& walletUUID, const QString& nodeVersion);
|
||||||
QUuid assignmentUUIDForPendingAssignment(const QUuid& tempUUID);
|
QUuid assignmentUUIDForPendingAssignment(const QUuid& tempUUID);
|
||||||
|
|
||||||
void removeICEPeer(const QUuid& peerUUID) { _icePeers.remove(peerUUID); }
|
void cleanupICEPeerForNode(const QUuid& nodeID);
|
||||||
|
|
||||||
Node::LocalID findOrCreateLocalID(const QUuid& uuid);
|
Node::LocalID findOrCreateLocalID(const QUuid& uuid);
|
||||||
|
|
||||||
|
@ -101,6 +101,10 @@ private:
|
||||||
|
|
||||||
QHash<QUuid, SharedNetworkPeer> _icePeers;
|
QHash<QUuid, SharedNetworkPeer> _icePeers;
|
||||||
|
|
||||||
|
using ConnectingNodeID = QUuid;
|
||||||
|
using ICEPeerID = QUuid;
|
||||||
|
QHash<ConnectingNodeID, ICEPeerID> _nodeToICEPeerIDs;
|
||||||
|
|
||||||
QHash<QString, QUuid> _connectionTokenHash;
|
QHash<QString, QUuid> _connectionTokenHash;
|
||||||
|
|
||||||
// the word "optimistic" below is used for keys that we request during user connection before the user has
|
// the word "optimistic" below is used for keys that we request during user connection before the user has
|
||||||
|
|
|
@ -1017,15 +1017,22 @@ void DomainServer::processListRequestPacket(QSharedPointer<ReceivedMessage> mess
|
||||||
sendingNode->setPublicSocket(nodeRequestData.publicSockAddr);
|
sendingNode->setPublicSocket(nodeRequestData.publicSockAddr);
|
||||||
sendingNode->setLocalSocket(nodeRequestData.localSockAddr);
|
sendingNode->setLocalSocket(nodeRequestData.localSockAddr);
|
||||||
|
|
||||||
// update the NodeInterestSet in case there have been any changes
|
|
||||||
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(sendingNode->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(sendingNode->getLinkedData());
|
||||||
|
|
||||||
|
if (!nodeData->hasCheckedIn()) {
|
||||||
|
nodeData->setHasCheckedIn(true);
|
||||||
|
|
||||||
|
// on first check in, make sure we've cleaned up any ICE peer for this node
|
||||||
|
_gatekeeper.cleanupICEPeerForNode(sendingNode->getUUID());
|
||||||
|
}
|
||||||
|
|
||||||
// guard against patched agents asking to hear about other agents
|
// guard against patched agents asking to hear about other agents
|
||||||
auto safeInterestSet = nodeRequestData.interestList.toSet();
|
auto safeInterestSet = nodeRequestData.interestList.toSet();
|
||||||
if (sendingNode->getType() == NodeType::Agent) {
|
if (sendingNode->getType() == NodeType::Agent) {
|
||||||
safeInterestSet.remove(NodeType::Agent);
|
safeInterestSet.remove(NodeType::Agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update the NodeInterestSet in case there have been any changes
|
||||||
nodeData->setNodeInterestSet(safeInterestSet);
|
nodeData->setNodeInterestSet(safeInterestSet);
|
||||||
|
|
||||||
// update the connecting hostname in case it has changed
|
// update the connecting hostname in case it has changed
|
||||||
|
@ -2945,7 +2952,7 @@ void DomainServer::nodeAdded(SharedNodePointer node) {
|
||||||
|
|
||||||
void DomainServer::nodeKilled(SharedNodePointer node) {
|
void DomainServer::nodeKilled(SharedNodePointer node) {
|
||||||
// if this peer connected via ICE then remove them from our ICE peers hash
|
// if this peer connected via ICE then remove them from our ICE peers hash
|
||||||
_gatekeeper.removeICEPeer(node->getUUID());
|
_gatekeeper.cleanupICEPeerForNode(node->getUUID());
|
||||||
|
|
||||||
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||||
|
|
||||||
|
|
|
@ -67,9 +67,12 @@ public:
|
||||||
const QString& getPlaceName() { return _placeName; }
|
const QString& getPlaceName() { return _placeName; }
|
||||||
void setPlaceName(const QString& placeName) { _placeName = placeName; }
|
void setPlaceName(const QString& placeName) { _placeName = placeName; }
|
||||||
|
|
||||||
bool wasAssigned() const { return _wasAssigned; };
|
bool wasAssigned() const { return _wasAssigned; }
|
||||||
void setWasAssigned(bool wasAssigned) { _wasAssigned = wasAssigned; }
|
void setWasAssigned(bool wasAssigned) { _wasAssigned = wasAssigned; }
|
||||||
|
|
||||||
|
bool hasCheckedIn() const { return _hasCheckedIn; }
|
||||||
|
void setHasCheckedIn(bool hasCheckedIn) { _hasCheckedIn = hasCheckedIn; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QJsonObject overrideValuesIfNeeded(const QJsonObject& newStats);
|
QJsonObject overrideValuesIfNeeded(const QJsonObject& newStats);
|
||||||
QJsonArray overrideValuesIfNeeded(const QJsonArray& newStats);
|
QJsonArray overrideValuesIfNeeded(const QJsonArray& newStats);
|
||||||
|
@ -94,6 +97,8 @@ private:
|
||||||
QString _placeName;
|
QString _placeName;
|
||||||
|
|
||||||
bool _wasAssigned { false };
|
bool _wasAssigned { false };
|
||||||
|
|
||||||
|
bool _hasCheckedIn { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_DomainServerNodeData_h
|
#endif // hifi_DomainServerNodeData_h
|
||||||
|
|
Loading…
Reference in a new issue