mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:28:09 +02:00
network chatter between Monitor and AssignmentClients is expected to be localhost only
This commit is contained in:
parent
70c96e496f
commit
8cee88acb4
2 changed files with 23 additions and 14 deletions
|
@ -259,8 +259,13 @@ void AssignmentClient::readPendingDatagrams() {
|
||||||
qDebug() << "Received an assignment that could not be unpacked. Re-requesting.";
|
qDebug() << "Received an assignment that could not be unpacked. Re-requesting.";
|
||||||
}
|
}
|
||||||
} else if (packetTypeForPacket(receivedPacket) == PacketTypeStopNode) {
|
} else if (packetTypeForPacket(receivedPacket) == PacketTypeStopNode) {
|
||||||
qDebug() << "Network told me to exit.";
|
if (senderSockAddr.getAddress() == QHostAddress::LocalHost ||
|
||||||
emit stopAssignmentClient();
|
senderSockAddr.getAddress() == QHostAddress::LocalHostIPv6) {
|
||||||
|
qDebug() << "Network told me to exit.";
|
||||||
|
emit stopAssignmentClient();
|
||||||
|
} else {
|
||||||
|
qDebug() << "Got a stop packet from other than localhost.";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// have the NodeList attempt to handle it
|
// have the NodeList attempt to handle it
|
||||||
nodeList->processNodeData(senderSockAddr, receivedPacket);
|
nodeList->processNodeData(senderSockAddr, receivedPacket);
|
||||||
|
|
|
@ -87,10 +87,12 @@ void AssignmentClientMonitor::spawnChildClient() {
|
||||||
assignmentClient->setProcessChannelMode(QProcess::ForwardedChannels);
|
assignmentClient->setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
|
|
||||||
assignmentClient->start(applicationFilePath(), _childArguments);
|
assignmentClient->start(applicationFilePath(), _childArguments);
|
||||||
|
|
||||||
qDebug() << "Spawned a child client with PID" << assignmentClient->pid();
|
qDebug() << "Spawned a child client with PID" << assignmentClient->pid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AssignmentClientMonitor::checkSpares() {
|
void AssignmentClientMonitor::checkSpares() {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
QUuid aSpareId = "";
|
QUuid aSpareId = "";
|
||||||
|
@ -100,7 +102,6 @@ void AssignmentClientMonitor::checkSpares() {
|
||||||
|
|
||||||
nodeList->eachNode([&](const SharedNodePointer& node){
|
nodeList->eachNode([&](const SharedNodePointer& node){
|
||||||
AssignmentClientChildData *childData = static_cast<AssignmentClientChildData*>(node->getLinkedData());
|
AssignmentClientChildData *childData = static_cast<AssignmentClientChildData*>(node->getLinkedData());
|
||||||
qDebug() << " " << node->getUUID() << childData->getChildType();
|
|
||||||
if (childData->getChildType() == "none") {
|
if (childData->getChildType() == "none") {
|
||||||
spareCount ++;
|
spareCount ++;
|
||||||
aSpareId = node->getUUID();
|
aSpareId = node->getUUID();
|
||||||
|
@ -142,17 +143,20 @@ void AssignmentClientMonitor::readPendingDatagrams() {
|
||||||
QUuid packetUUID = uuidFromPacketHeader(receivedPacket);
|
QUuid packetUUID = uuidFromPacketHeader(receivedPacket);
|
||||||
SharedNodePointer matchingNode = nodeList->sendingNodeForPacket(receivedPacket);
|
SharedNodePointer matchingNode = nodeList->sendingNodeForPacket(receivedPacket);
|
||||||
if (!matchingNode) {
|
if (!matchingNode) {
|
||||||
// XXX only do this if from local machine
|
// The parent only expects to be talking with prorams running on this same machine.
|
||||||
if (!packetUUID.isNull()) {
|
if (senderSockAddr.getAddress() == QHostAddress::LocalHost ||
|
||||||
matchingNode = DependencyManager::get<LimitedNodeList>()->addOrUpdateNode
|
senderSockAddr.getAddress() == QHostAddress::LocalHostIPv6) {
|
||||||
(packetUUID, NodeType::Unassigned, senderSockAddr, senderSockAddr, false);
|
if (!packetUUID.isNull()) {
|
||||||
AssignmentClientChildData *childData = new AssignmentClientChildData("unknown");
|
matchingNode = DependencyManager::get<LimitedNodeList>()->addOrUpdateNode
|
||||||
matchingNode->setLinkedData(childData);
|
(packetUUID, NodeType::Unassigned, senderSockAddr, senderSockAddr, false);
|
||||||
} else {
|
AssignmentClientChildData *childData = new AssignmentClientChildData("unknown");
|
||||||
// tell unknown assignment-client child to exit.
|
matchingNode->setLinkedData(childData);
|
||||||
qDebug() << "asking unknown child to exit.";
|
} else {
|
||||||
QByteArray diePacket = byteArrayWithPopulatedHeader(PacketTypeStopNode);
|
// tell unknown assignment-client child to exit.
|
||||||
nodeList->writeUnverifiedDatagram(diePacket, senderSockAddr);
|
qDebug() << "asking unknown child to exit.";
|
||||||
|
QByteArray diePacket = byteArrayWithPopulatedHeader(PacketTypeStopNode);
|
||||||
|
nodeList->writeUnverifiedDatagram(diePacket, senderSockAddr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue