mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:09:52 +02:00
Merge pull request #9478 from birarda/bug/too-many-casts
some reinterpret/dynamic cast cleanup in domain-server
This commit is contained in:
commit
b053fb55aa
3 changed files with 45 additions and 45 deletions
|
@ -107,7 +107,7 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointer<ReceivedMessag
|
||||||
|
|
||||||
if (node) {
|
if (node) {
|
||||||
// set the sending sock addr and node interest set on this node
|
// set the sending sock addr and node interest set on this node
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(node->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||||
nodeData->setSendingSockAddr(message->getSenderSockAddr());
|
nodeData->setSendingSockAddr(message->getSenderSockAddr());
|
||||||
|
|
||||||
// guard against patched agents asking to hear about other agents
|
// guard against patched agents asking to hear about other agents
|
||||||
|
@ -128,12 +128,12 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointer<ReceivedMessag
|
||||||
emit connectedNode(node);
|
emit connectedNode(node);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Refusing connection from node at" << message->getSenderSockAddr()
|
qDebug() << "Refusing connection from node at" << message->getSenderSockAddr()
|
||||||
<< "with hardware address" << nodeConnection.hardwareAddress
|
<< "with hardware address" << nodeConnection.hardwareAddress
|
||||||
<< "and machine fingerprint" << nodeConnection.machineFingerprint;
|
<< "and machine fingerprint" << nodeConnection.machineFingerprint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NodePermissions DomainGatekeeper::setPermissionsForUser(bool isLocalUser, QString verifiedUsername, const QHostAddress& senderAddress,
|
NodePermissions DomainGatekeeper::setPermissionsForUser(bool isLocalUser, QString verifiedUsername, const QHostAddress& senderAddress,
|
||||||
const QString& hardwareAddress, const QUuid& machineFingerprint) {
|
const QString& hardwareAddress, const QUuid& machineFingerprint) {
|
||||||
NodePermissions userPerms;
|
NodePermissions userPerms;
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ void DomainGatekeeper::updateNodePermissions() {
|
||||||
QString hardwareAddress;
|
QString hardwareAddress;
|
||||||
QUuid machineFingerprint;
|
QUuid machineFingerprint;
|
||||||
|
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(node->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||||
if (nodeData) {
|
if (nodeData) {
|
||||||
hardwareAddress = nodeData->getHardwareAddress();
|
hardwareAddress = nodeData->getHardwareAddress();
|
||||||
machineFingerprint = nodeData->getMachineFingerprint();
|
machineFingerprint = nodeData->getMachineFingerprint();
|
||||||
|
@ -336,7 +336,7 @@ SharedNodePointer DomainGatekeeper::processAssignmentConnectRequest(const NodeCo
|
||||||
// add the new node
|
// add the new node
|
||||||
SharedNodePointer newNode = addVerifiedNodeFromConnectRequest(nodeConnection);
|
SharedNodePointer newNode = addVerifiedNodeFromConnectRequest(nodeConnection);
|
||||||
|
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(newNode->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(newNode->getLinkedData());
|
||||||
|
|
||||||
// set assignment related data on the linked data for this node
|
// set assignment related data on the linked data for this node
|
||||||
nodeData->setAssignmentUUID(matchingQueuedAssignment->getUUID());
|
nodeData->setAssignmentUUID(matchingQueuedAssignment->getUUID());
|
||||||
|
@ -458,7 +458,7 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect
|
||||||
newNode->setPermissions(userPerms);
|
newNode->setPermissions(userPerms);
|
||||||
|
|
||||||
// grab the linked data for our new node so we can set the username
|
// grab the linked data for our new node so we can set the username
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(newNode->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(newNode->getLinkedData());
|
||||||
|
|
||||||
// if we have a username from the connect request, set it on the DomainServerNodeData
|
// if we have a username from the connect request, set it on the DomainServerNodeData
|
||||||
nodeData->setUsername(username);
|
nodeData->setUsername(username);
|
||||||
|
|
|
@ -107,7 +107,7 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
|
|
||||||
qRegisterMetaType<DomainServerWebSessionData>("DomainServerWebSessionData");
|
qRegisterMetaType<DomainServerWebSessionData>("DomainServerWebSessionData");
|
||||||
qRegisterMetaTypeStreamOperators<DomainServerWebSessionData>("DomainServerWebSessionData");
|
qRegisterMetaTypeStreamOperators<DomainServerWebSessionData>("DomainServerWebSessionData");
|
||||||
|
|
||||||
// make sure we hear about newly connected nodes from our gatekeeper
|
// make sure we hear about newly connected nodes from our gatekeeper
|
||||||
connect(&_gatekeeper, &DomainGatekeeper::connectedNode, this, &DomainServer::handleConnectedNode);
|
connect(&_gatekeeper, &DomainGatekeeper::connectedNode, this, &DomainServer::handleConnectedNode);
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ bool DomainServer::optionallyReadX509KeyAndCertificate() {
|
||||||
QString keyPassphraseString = QProcessEnvironment::systemEnvironment().value(X509_KEY_PASSPHRASE_ENV);
|
QString keyPassphraseString = QProcessEnvironment::systemEnvironment().value(X509_KEY_PASSPHRASE_ENV);
|
||||||
|
|
||||||
qDebug() << "Reading certificate file at" << certPath << "for HTTPS.";
|
qDebug() << "Reading certificate file at" << certPath << "for HTTPS.";
|
||||||
qDebug() << "Reading key file at" << keyPath << "for HTTPS.";
|
qDebug() << "Reading key file at" << keyPath << "for HTTPS.";
|
||||||
|
|
||||||
QFile certFile(certPath);
|
QFile certFile(certPath);
|
||||||
certFile.open(QIODevice::ReadOnly);
|
certFile.open(QIODevice::ReadOnly);
|
||||||
|
@ -528,12 +528,12 @@ void DomainServer::setupNodeListAndAssignments() {
|
||||||
packetReceiver.registerListener(PacketType::DomainServerPathQuery, this, "processPathQueryPacket");
|
packetReceiver.registerListener(PacketType::DomainServerPathQuery, this, "processPathQueryPacket");
|
||||||
packetReceiver.registerListener(PacketType::NodeJsonStats, this, "processNodeJSONStatsPacket");
|
packetReceiver.registerListener(PacketType::NodeJsonStats, this, "processNodeJSONStatsPacket");
|
||||||
packetReceiver.registerListener(PacketType::DomainDisconnectRequest, this, "processNodeDisconnectRequestPacket");
|
packetReceiver.registerListener(PacketType::DomainDisconnectRequest, this, "processNodeDisconnectRequestPacket");
|
||||||
|
|
||||||
// NodeList won't be available to the settings manager when it is created, so call registerListener here
|
// NodeList won't be available to the settings manager when it is created, so call registerListener here
|
||||||
packetReceiver.registerListener(PacketType::DomainSettingsRequest, &_settingsManager, "processSettingsRequestPacket");
|
packetReceiver.registerListener(PacketType::DomainSettingsRequest, &_settingsManager, "processSettingsRequestPacket");
|
||||||
packetReceiver.registerListener(PacketType::NodeKickRequest, &_settingsManager, "processNodeKickRequestPacket");
|
packetReceiver.registerListener(PacketType::NodeKickRequest, &_settingsManager, "processNodeKickRequestPacket");
|
||||||
packetReceiver.registerListener(PacketType::UsernameFromIDRequest, &_settingsManager, "processUsernameFromIDRequestPacket");
|
packetReceiver.registerListener(PacketType::UsernameFromIDRequest, &_settingsManager, "processUsernameFromIDRequestPacket");
|
||||||
|
|
||||||
// register the gatekeeper for the packets it needs to receive
|
// register the gatekeeper for the packets it needs to receive
|
||||||
packetReceiver.registerListener(PacketType::DomainConnectRequest, &_gatekeeper, "processConnectRequestPacket");
|
packetReceiver.registerListener(PacketType::DomainConnectRequest, &_gatekeeper, "processConnectRequestPacket");
|
||||||
packetReceiver.registerListener(PacketType::ICEPing, &_gatekeeper, "processICEPingPacket");
|
packetReceiver.registerListener(PacketType::ICEPing, &_gatekeeper, "processICEPingPacket");
|
||||||
|
@ -542,7 +542,7 @@ void DomainServer::setupNodeListAndAssignments() {
|
||||||
|
|
||||||
packetReceiver.registerListener(PacketType::ICEServerHeartbeatDenied, this, "processICEServerHeartbeatDenialPacket");
|
packetReceiver.registerListener(PacketType::ICEServerHeartbeatDenied, this, "processICEServerHeartbeatDenialPacket");
|
||||||
packetReceiver.registerListener(PacketType::ICEServerHeartbeatACK, this, "processICEServerHeartbeatACK");
|
packetReceiver.registerListener(PacketType::ICEServerHeartbeatACK, this, "processICEServerHeartbeatACK");
|
||||||
|
|
||||||
// add whatever static assignments that have been parsed to the queue
|
// add whatever static assignments that have been parsed to the queue
|
||||||
addStaticAssignmentsToQueue();
|
addStaticAssignmentsToQueue();
|
||||||
|
|
||||||
|
@ -811,18 +811,18 @@ void DomainServer::populateDefaultStaticAssignmentsExcludingTypes(const QSet<Ass
|
||||||
if (!excludedTypes.contains(defaultedType)
|
if (!excludedTypes.contains(defaultedType)
|
||||||
&& defaultedType != Assignment::UNUSED_1
|
&& defaultedType != Assignment::UNUSED_1
|
||||||
&& defaultedType != Assignment::AgentType) {
|
&& defaultedType != Assignment::AgentType) {
|
||||||
|
|
||||||
if (defaultedType == Assignment::AssetServerType) {
|
if (defaultedType == Assignment::AssetServerType) {
|
||||||
// Make sure the asset-server is enabled before adding it here.
|
// Make sure the asset-server is enabled before adding it here.
|
||||||
// Initially we do not assign it by default so we can test it in HF domains first
|
// Initially we do not assign it by default so we can test it in HF domains first
|
||||||
static const QString ASSET_SERVER_ENABLED_KEYPATH = "asset_server.enabled";
|
static const QString ASSET_SERVER_ENABLED_KEYPATH = "asset_server.enabled";
|
||||||
|
|
||||||
if (!_settingsManager.valueOrDefaultValueForKeyPath(ASSET_SERVER_ENABLED_KEYPATH).toBool()) {
|
if (!_settingsManager.valueOrDefaultValueForKeyPath(ASSET_SERVER_ENABLED_KEYPATH).toBool()) {
|
||||||
// skip to the next iteration if asset-server isn't enabled
|
// skip to the next iteration if asset-server isn't enabled
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// type has not been set from a command line or config file config, use the default
|
// type has not been set from a command line or config file config, use the default
|
||||||
// by clearing whatever exists and writing a single default assignment with no payload
|
// by clearing whatever exists and writing a single default assignment with no payload
|
||||||
Assignment* newAssignment = new Assignment(Assignment::CreateCommand, (Assignment::Type) defaultedType);
|
Assignment* newAssignment = new Assignment(Assignment::CreateCommand, (Assignment::Type) defaultedType);
|
||||||
|
@ -839,9 +839,9 @@ void DomainServer::processListRequestPacket(QSharedPointer<ReceivedMessage> mess
|
||||||
// update this node's sockets in case they have changed
|
// update this node's sockets in case they have changed
|
||||||
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
|
// update the NodeInterestSet in case there have been any changes
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(sendingNode->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(sendingNode->getLinkedData());
|
||||||
|
|
||||||
// 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();
|
||||||
|
@ -928,14 +928,14 @@ void DomainServer::handleConnectedNode(SharedNodePointer newNode) {
|
||||||
|
|
||||||
void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const HifiSockAddr &senderSockAddr) {
|
void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const HifiSockAddr &senderSockAddr) {
|
||||||
const int NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES = NUM_BYTES_RFC4122_UUID + NUM_BYTES_RFC4122_UUID + 2;
|
const int NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES = NUM_BYTES_RFC4122_UUID + NUM_BYTES_RFC4122_UUID + 2;
|
||||||
|
|
||||||
// setup the extended header for the domain list packets
|
// setup the extended header for the domain list packets
|
||||||
// this data is at the beginning of each of the domain list packets
|
// this data is at the beginning of each of the domain list packets
|
||||||
QByteArray extendedHeader(NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES, 0);
|
QByteArray extendedHeader(NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES, 0);
|
||||||
QDataStream extendedHeaderStream(&extendedHeader, QIODevice::WriteOnly);
|
QDataStream extendedHeaderStream(&extendedHeader, QIODevice::WriteOnly);
|
||||||
|
|
||||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
|
||||||
extendedHeaderStream << limitedNodeList->getSessionUUID();
|
extendedHeaderStream << limitedNodeList->getSessionUUID();
|
||||||
extendedHeaderStream << node->getUUID();
|
extendedHeaderStream << node->getUUID();
|
||||||
extendedHeaderStream << node->getPermissions();
|
extendedHeaderStream << node->getPermissions();
|
||||||
|
@ -945,7 +945,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
||||||
// always send the node their own UUID back
|
// always send the node their own UUID back
|
||||||
QDataStream domainListStream(domainListPackets.get());
|
QDataStream domainListStream(domainListPackets.get());
|
||||||
|
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(node->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||||
|
|
||||||
// store the nodeInterestSet on this DomainServerNodeData, in case it has changed
|
// store the nodeInterestSet on this DomainServerNodeData, in case it has changed
|
||||||
auto& nodeInterestSet = nodeData->getNodeInterestSet();
|
auto& nodeInterestSet = nodeData->getNodeInterestSet();
|
||||||
|
@ -958,7 +958,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
||||||
limitedNodeList->eachNode([&](const SharedNodePointer& otherNode){
|
limitedNodeList->eachNode([&](const SharedNodePointer& otherNode){
|
||||||
if (otherNode->getUUID() != node->getUUID()
|
if (otherNode->getUUID() != node->getUUID()
|
||||||
&& nodeInterestSet.contains(otherNode->getType())) {
|
&& nodeInterestSet.contains(otherNode->getType())) {
|
||||||
|
|
||||||
// since we're about to add a node to the packet we start a segment
|
// since we're about to add a node to the packet we start a segment
|
||||||
domainListPackets->startSegment();
|
domainListPackets->startSegment();
|
||||||
|
|
||||||
|
@ -974,7 +974,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// send an empty list to the node, in case there were no other nodes
|
// send an empty list to the node, in case there were no other nodes
|
||||||
domainListPackets->closeCurrentPacket(true);
|
domainListPackets->closeCurrentPacket(true);
|
||||||
|
|
||||||
|
@ -983,8 +983,8 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid DomainServer::connectionSecretForNodes(const SharedNodePointer& nodeA, const SharedNodePointer& nodeB) {
|
QUuid DomainServer::connectionSecretForNodes(const SharedNodePointer& nodeA, const SharedNodePointer& nodeB) {
|
||||||
DomainServerNodeData* nodeAData = dynamic_cast<DomainServerNodeData*>(nodeA->getLinkedData());
|
DomainServerNodeData* nodeAData = static_cast<DomainServerNodeData*>(nodeA->getLinkedData());
|
||||||
DomainServerNodeData* nodeBData = dynamic_cast<DomainServerNodeData*>(nodeB->getLinkedData());
|
DomainServerNodeData* nodeBData = static_cast<DomainServerNodeData*>(nodeB->getLinkedData());
|
||||||
|
|
||||||
if (nodeAData && nodeBData) {
|
if (nodeAData && nodeBData) {
|
||||||
QUuid& secretUUID = nodeAData->getSessionSecretHash()[nodeB->getUUID()];
|
QUuid& secretUUID = nodeAData->getSessionSecretHash()[nodeB->getUUID()];
|
||||||
|
@ -994,7 +994,7 @@ QUuid DomainServer::connectionSecretForNodes(const SharedNodePointer& nodeA, con
|
||||||
secretUUID = QUuid::createUuid();
|
secretUUID = QUuid::createUuid();
|
||||||
|
|
||||||
// set it on the other Node's sessionSecretHash
|
// set it on the other Node's sessionSecretHash
|
||||||
reinterpret_cast<DomainServerNodeData*>(nodeBData)->getSessionSecretHash().insert(nodeA->getUUID(), secretUUID);
|
static_cast<DomainServerNodeData*>(nodeBData)->getSessionSecretHash().insert(nodeA->getUUID(), secretUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return secretUUID;
|
return secretUUID;
|
||||||
|
@ -1020,7 +1020,7 @@ void DomainServer::broadcastNewNode(const SharedNodePointer& addedNode) {
|
||||||
[&](const SharedNodePointer& node)->bool {
|
[&](const SharedNodePointer& node)->bool {
|
||||||
if (node->getLinkedData() && node->getActiveSocket() && node != addedNode) {
|
if (node->getLinkedData() && node->getActiveSocket() && node != addedNode) {
|
||||||
// is the added Node in this node's interest list?
|
// is the added Node in this node's interest list?
|
||||||
DomainServerNodeData* nodeData = dynamic_cast<DomainServerNodeData*>(node->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||||
return nodeData->getNodeInterestSet().contains(addedNode->getType());
|
return nodeData->getNodeInterestSet().contains(addedNode->getType());
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1124,7 +1124,7 @@ void DomainServer::processRequestAssignmentPacket(QSharedPointer<ReceivedMessage
|
||||||
void DomainServer::setupPendingAssignmentCredits() {
|
void DomainServer::setupPendingAssignmentCredits() {
|
||||||
// enumerate the NodeList to find the assigned nodes
|
// enumerate the NodeList to find the assigned nodes
|
||||||
DependencyManager::get<LimitedNodeList>()->eachNode([&](const SharedNodePointer& node){
|
DependencyManager::get<LimitedNodeList>()->eachNode([&](const SharedNodePointer& node){
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(node->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||||
|
|
||||||
if (!nodeData->getAssignmentUUID().isNull() && !nodeData->getWalletUUID().isNull()) {
|
if (!nodeData->getAssignmentUUID().isNull() && !nodeData->getWalletUUID().isNull()) {
|
||||||
// check if we have a non-finalized transaction for this node to add this amount to
|
// check if we have a non-finalized transaction for this node to add this amount to
|
||||||
|
@ -1510,7 +1510,7 @@ void DomainServer::sendHeartbeatToIceServer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::processNodeJSONStatsPacket(QSharedPointer<ReceivedMessage> packetList, SharedNodePointer sendingNode) {
|
void DomainServer::processNodeJSONStatsPacket(QSharedPointer<ReceivedMessage> packetList, SharedNodePointer sendingNode) {
|
||||||
auto nodeData = dynamic_cast<DomainServerNodeData*>(sendingNode->getLinkedData());
|
auto nodeData = static_cast<DomainServerNodeData*>(sendingNode->getLinkedData());
|
||||||
if (nodeData) {
|
if (nodeData) {
|
||||||
nodeData->updateJSONStats(packetList->getMessage());
|
nodeData->updateJSONStats(packetList->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -1556,7 +1556,7 @@ QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) {
|
||||||
nodeJson[JSON_KEY_UPTIME] = QString::number(double(QDateTime::currentMSecsSinceEpoch() - node->getWakeTimestamp()) / 1000.0);
|
nodeJson[JSON_KEY_UPTIME] = QString::number(double(QDateTime::currentMSecsSinceEpoch() - node->getWakeTimestamp()) / 1000.0);
|
||||||
|
|
||||||
// if the node has pool information, add it
|
// if the node has pool information, add it
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(node->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||||
|
|
||||||
// add the node username, if it exists
|
// add the node username, if it exists
|
||||||
nodeJson[JSON_KEY_USERNAME] = nodeData->getUsername();
|
nodeJson[JSON_KEY_USERNAME] = nodeData->getUsername();
|
||||||
|
@ -1624,23 +1624,23 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
if (connection->requestOperation() == QNetworkAccessManager::GetOperation
|
if (connection->requestOperation() == QNetworkAccessManager::GetOperation
|
||||||
&& assignmentRegex.indexIn(url.path()) != -1) {
|
&& assignmentRegex.indexIn(url.path()) != -1) {
|
||||||
QUuid nodeUUID = QUuid(assignmentRegex.cap(1));
|
QUuid nodeUUID = QUuid(assignmentRegex.cap(1));
|
||||||
|
|
||||||
auto matchingNode = nodeList->nodeWithUUID(nodeUUID);
|
auto matchingNode = nodeList->nodeWithUUID(nodeUUID);
|
||||||
|
|
||||||
// don't handle if we don't have a matching node
|
// don't handle if we don't have a matching node
|
||||||
if (!matchingNode) {
|
if (!matchingNode) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto nodeData = dynamic_cast<DomainServerNodeData*>(matchingNode->getLinkedData());
|
auto nodeData = static_cast<DomainServerNodeData*>(matchingNode->getLinkedData());
|
||||||
|
|
||||||
// don't handle if we don't have node data for this node
|
// don't handle if we don't have node data for this node
|
||||||
if (!nodeData) {
|
if (!nodeData) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedAssignmentPointer matchingAssignment = _allAssignments.value(nodeData->getAssignmentUUID());
|
SharedAssignmentPointer matchingAssignment = _allAssignments.value(nodeData->getAssignmentUUID());
|
||||||
|
|
||||||
// check if we have an assignment that matches this temp UUID, and it is a scripted assignment
|
// check if we have an assignment that matches this temp UUID, and it is a scripted assignment
|
||||||
if (matchingAssignment && matchingAssignment->getType() == Assignment::AgentType) {
|
if (matchingAssignment && matchingAssignment->getType() == Assignment::AgentType) {
|
||||||
// we have a matching assignment and it is for the right type, have the HTTP manager handle it
|
// we have a matching assignment and it is for the right type, have the HTTP manager handle it
|
||||||
|
@ -1655,7 +1655,7 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// request not handled
|
// request not handled
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1687,7 +1687,7 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
|
|
||||||
// enumerate the NodeList to find the assigned nodes
|
// enumerate the NodeList to find the assigned nodes
|
||||||
nodeList->eachNode([this, &assignedNodesJSON](const SharedNodePointer& node){
|
nodeList->eachNode([this, &assignedNodesJSON](const SharedNodePointer& node){
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(node->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||||
|
|
||||||
if (!nodeData->getAssignmentUUID().isNull()) {
|
if (!nodeData->getAssignmentUUID().isNull()) {
|
||||||
// add the node using the UUID as the key
|
// add the node using the UUID as the key
|
||||||
|
@ -1775,7 +1775,7 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
if (matchingNode) {
|
if (matchingNode) {
|
||||||
// create a QJsonDocument with the stats QJsonObject
|
// create a QJsonDocument with the stats QJsonObject
|
||||||
QJsonObject statsObject =
|
QJsonObject statsObject =
|
||||||
reinterpret_cast<DomainServerNodeData*>(matchingNode->getLinkedData())->getStatsJSONObject();
|
static_cast<DomainServerNodeData*>(matchingNode->getLinkedData())->getStatsJSONObject();
|
||||||
|
|
||||||
// add the node type to the JSON data for output purposes
|
// add the node type to the JSON data for output purposes
|
||||||
statsObject["node_type"] = NodeType::getNodeTypeName(matchingNode->getType()).toLower().replace(' ', '-');
|
statsObject["node_type"] = NodeType::getNodeTypeName(matchingNode->getType()).toLower().replace(' ', '-');
|
||||||
|
@ -2247,7 +2247,7 @@ void DomainServer::addStaticAssignmentsToQueue() {
|
||||||
// if the domain-server has just restarted,
|
// if the domain-server has just restarted,
|
||||||
// check if there are static assignments that we need to throw into the assignment queue
|
// check if there are static assignments that we need to throw into the assignment queue
|
||||||
auto sharedAssignments = _allAssignments.values();
|
auto sharedAssignments = _allAssignments.values();
|
||||||
|
|
||||||
// sort the assignments to put the server/mixer assignments first
|
// sort the assignments to put the server/mixer assignments first
|
||||||
qSort(sharedAssignments.begin(), sharedAssignments.end(), [](SharedAssignmentPointer a, SharedAssignmentPointer b){
|
qSort(sharedAssignments.begin(), sharedAssignments.end(), [](SharedAssignmentPointer a, SharedAssignmentPointer b){
|
||||||
if (a->getType() == b->getType()) {
|
if (a->getType() == b->getType()) {
|
||||||
|
@ -2258,9 +2258,9 @@ void DomainServer::addStaticAssignmentsToQueue() {
|
||||||
return a->getType() != Assignment::AgentType;
|
return a->getType() != Assignment::AgentType;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
auto staticAssignment = sharedAssignments.begin();
|
auto staticAssignment = sharedAssignments.begin();
|
||||||
|
|
||||||
while (staticAssignment != sharedAssignments.end()) {
|
while (staticAssignment != sharedAssignments.end()) {
|
||||||
// add any of the un-matched static assignments to the queue
|
// add any of the un-matched static assignments to the queue
|
||||||
|
|
||||||
|
@ -2385,7 +2385,7 @@ void DomainServer::handleKillNode(SharedNodePointer nodeToKill) {
|
||||||
// broadcast out the DomainServerRemovedNode message
|
// broadcast out the DomainServerRemovedNode message
|
||||||
limitedNodeList->eachMatchingNode([&nodeType](const SharedNodePointer& otherNode) -> bool {
|
limitedNodeList->eachMatchingNode([&nodeType](const SharedNodePointer& otherNode) -> bool {
|
||||||
// only send the removed node packet to nodes that care about the type of node this was
|
// only send the removed node packet to nodes that care about the type of node this was
|
||||||
auto nodeLinkedData = dynamic_cast<DomainServerNodeData*>(otherNode->getLinkedData());
|
auto nodeLinkedData = static_cast<DomainServerNodeData*>(otherNode->getLinkedData());
|
||||||
return (nodeLinkedData != nullptr) && nodeLinkedData->getNodeInterestSet().contains(nodeType);
|
return (nodeLinkedData != nullptr) && nodeLinkedData->getNodeInterestSet().contains(nodeType);
|
||||||
}, [&limitedNodeList](const SharedNodePointer& otherNode){
|
}, [&limitedNodeList](const SharedNodePointer& otherNode){
|
||||||
limitedNodeList->sendUnreliablePacket(*removedNodePacket, *otherNode);
|
limitedNodeList->sendUnreliablePacket(*removedNodePacket, *otherNode);
|
||||||
|
|
|
@ -725,7 +725,7 @@ void DomainServerSettingsManager::processNodeKickRequestPacket(QSharedPointer<Re
|
||||||
}
|
}
|
||||||
|
|
||||||
// potentially remove connect permissions for the MAC address and machine fingerprint
|
// potentially remove connect permissions for the MAC address and machine fingerprint
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(matchingNode->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(matchingNode->getLinkedData());
|
||||||
if (nodeData) {
|
if (nodeData) {
|
||||||
// mac address first
|
// mac address first
|
||||||
NodePermissionsKey macAddressKey(nodeData->getHardwareAddress(), 0);
|
NodePermissionsKey macAddressKey(nodeData->getHardwareAddress(), 0);
|
||||||
|
@ -807,7 +807,7 @@ void DomainServerSettingsManager::processUsernameFromIDRequestPacket(QSharedPoin
|
||||||
usernameFromIDReplyPacket->writeString(verifiedUsername);
|
usernameFromIDReplyPacket->writeString(verifiedUsername);
|
||||||
|
|
||||||
// now put in the machine fingerprint
|
// now put in the machine fingerprint
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(matchingNode->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(matchingNode->getLinkedData());
|
||||||
machineFingerprint = nodeData ? nodeData->getMachineFingerprint() : QUuid();
|
machineFingerprint = nodeData ? nodeData->getMachineFingerprint() : QUuid();
|
||||||
usernameFromIDReplyPacket->write(machineFingerprint.toRfc4122());
|
usernameFromIDReplyPacket->write(machineFingerprint.toRfc4122());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue