network chatter between Monitor and AssignmentClients is expected to be localhost only

This commit is contained in:
Seth Alves 2015-02-20 14:25:43 -08:00
parent 70c96e496f
commit 8cee88acb4
2 changed files with 23 additions and 14 deletions

View file

@ -259,8 +259,13 @@ void AssignmentClient::readPendingDatagrams() {
qDebug() << "Received an assignment that could not be unpacked. Re-requesting.";
}
} else if (packetTypeForPacket(receivedPacket) == PacketTypeStopNode) {
if (senderSockAddr.getAddress() == QHostAddress::LocalHost ||
senderSockAddr.getAddress() == QHostAddress::LocalHostIPv6) {
qDebug() << "Network told me to exit.";
emit stopAssignmentClient();
} else {
qDebug() << "Got a stop packet from other than localhost.";
}
} else {
// have the NodeList attempt to handle it
nodeList->processNodeData(senderSockAddr, receivedPacket);

View file

@ -87,10 +87,12 @@ void AssignmentClientMonitor::spawnChildClient() {
assignmentClient->setProcessChannelMode(QProcess::ForwardedChannels);
assignmentClient->start(applicationFilePath(), _childArguments);
qDebug() << "Spawned a child client with PID" << assignmentClient->pid();
}
void AssignmentClientMonitor::checkSpares() {
auto nodeList = DependencyManager::get<NodeList>();
QUuid aSpareId = "";
@ -100,7 +102,6 @@ void AssignmentClientMonitor::checkSpares() {
nodeList->eachNode([&](const SharedNodePointer& node){
AssignmentClientChildData *childData = static_cast<AssignmentClientChildData*>(node->getLinkedData());
qDebug() << " " << node->getUUID() << childData->getChildType();
if (childData->getChildType() == "none") {
spareCount ++;
aSpareId = node->getUUID();
@ -142,7 +143,9 @@ void AssignmentClientMonitor::readPendingDatagrams() {
QUuid packetUUID = uuidFromPacketHeader(receivedPacket);
SharedNodePointer matchingNode = nodeList->sendingNodeForPacket(receivedPacket);
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 (senderSockAddr.getAddress() == QHostAddress::LocalHost ||
senderSockAddr.getAddress() == QHostAddress::LocalHostIPv6) {
if (!packetUUID.isNull()) {
matchingNode = DependencyManager::get<LimitedNodeList>()->addOrUpdateNode
(packetUUID, NodeType::Unassigned, senderSockAddr, senderSockAddr, false);
@ -155,6 +158,7 @@ void AssignmentClientMonitor::readPendingDatagrams() {
nodeList->writeUnverifiedDatagram(diePacket, senderSockAddr);
}
}
}
if (matchingNode) {
// update our records about how to reach this child