mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
fix an accidental DOS and remove getNodeActiveSocketOrPing API
This commit is contained in:
parent
a5636d2dc0
commit
3ad8e7260e
7 changed files with 23 additions and 32 deletions
|
@ -388,7 +388,7 @@ void Audio::handleAudioInput() {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer);
|
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer);
|
||||||
|
|
||||||
if (audioMixer && nodeList->getNodeActiveSocketOrPing(audioMixer)) {
|
if (audioMixer && audioMixer->getActiveSocket()) {
|
||||||
MyAvatar* interfaceAvatar = Application::getInstance()->getAvatar();
|
MyAvatar* interfaceAvatar = Application::getInstance()->getAvatar();
|
||||||
glm::vec3 headPosition = interfaceAvatar->getHead().getPosition();
|
glm::vec3 headPosition = interfaceAvatar->getHead().getPosition();
|
||||||
glm::quat headOrientation = interfaceAvatar->getHead().getOrientation();
|
glm::quat headOrientation = interfaceAvatar->getHead().getOrientation();
|
||||||
|
|
|
@ -265,7 +265,7 @@ void VoxelStatsDialog::showOctreeServersOfType(int& serverCount, NodeType_t serv
|
||||||
std::stringstream extraDetails("");
|
std::stringstream extraDetails("");
|
||||||
std::stringstream linkDetails("");
|
std::stringstream linkDetails("");
|
||||||
|
|
||||||
if (nodeList->getNodeActiveSocketOrPing(node)) {
|
if (node->getActiveSocket()) {
|
||||||
serverDetails << "active ";
|
serverDetails << "active ";
|
||||||
} else {
|
} else {
|
||||||
serverDetails << "inactive ";
|
serverDetails << "inactive ";
|
||||||
|
|
|
@ -45,7 +45,7 @@ bool JurisdictionListener::queueJurisdictionRequest() {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
||||||
if (nodeList->getNodeActiveSocketOrPing(node) && node->getType() == getNodeType()) {
|
if (node->getType() == getNodeType() && node->getActiveSocket()) {
|
||||||
_packetSender.queuePacketForSending(node, QByteArray(reinterpret_cast<char*>(bufferOut), sizeOut));
|
_packetSender.queuePacketForSending(node, QByteArray(reinterpret_cast<char*>(bufferOut), sizeOut));
|
||||||
nodeCount++;
|
nodeCount++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,19 +60,17 @@ bool OctreeEditPacketSender::serversExist() const {
|
||||||
|
|
||||||
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
||||||
// only send to the NodeTypes that are getMyNodeType()
|
// only send to the NodeTypes that are getMyNodeType()
|
||||||
if (node->getType() == getMyNodeType()) {
|
if (node->getType() == getMyNodeType() && node->getActiveSocket()) {
|
||||||
if (nodeList->getNodeActiveSocketOrPing(node)) {
|
QUuid nodeUUID = node->getUUID();
|
||||||
QUuid nodeUUID = node->getUUID();
|
// If we've got Jurisdictions set, then check to see if we know the jurisdiction for this server
|
||||||
// If we've got Jurisdictions set, then check to see if we know the jurisdiction for this server
|
if (_serverJurisdictions) {
|
||||||
if (_serverJurisdictions) {
|
// lookup our nodeUUID in the jurisdiction map, if it's missing then we're
|
||||||
// lookup our nodeUUID in the jurisdiction map, if it's missing then we're
|
// missing at least one jurisdiction
|
||||||
// missing at least one jurisdiction
|
if ((*_serverJurisdictions).find(nodeUUID) == (*_serverJurisdictions).end()) {
|
||||||
if ((*_serverJurisdictions).find(nodeUUID) == (*_serverJurisdictions).end()) {
|
atLeastOnJurisdictionMissing = true;
|
||||||
atLeastOnJurisdictionMissing = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
hasServers = true;
|
|
||||||
}
|
}
|
||||||
|
hasServers = true;
|
||||||
}
|
}
|
||||||
if (atLeastOnJurisdictionMissing) {
|
if (atLeastOnJurisdictionMissing) {
|
||||||
break; // no point in looking further...
|
break; // no point in looking further...
|
||||||
|
@ -91,7 +89,7 @@ void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned c
|
||||||
// only send to the NodeTypes that are getMyNodeType()
|
// only send to the NodeTypes that are getMyNodeType()
|
||||||
if (node->getType() == getMyNodeType() &&
|
if (node->getType() == getMyNodeType() &&
|
||||||
((node->getUUID() == nodeUUID) || (nodeUUID.isNull()))) {
|
((node->getUUID() == nodeUUID) || (nodeUUID.isNull()))) {
|
||||||
if (nodeList->getNodeActiveSocketOrPing(node)) {
|
if (node->getActiveSocket()) {
|
||||||
queuePacketForSending(node, QByteArray(reinterpret_cast<char*>(buffer), length));
|
queuePacketForSending(node, QByteArray(reinterpret_cast<char*>(buffer), length));
|
||||||
|
|
||||||
// debugging output...
|
// debugging output...
|
||||||
|
|
|
@ -127,7 +127,7 @@ qint64 NodeList::writeDatagram(const QByteArray& datagram, const SharedNodePoint
|
||||||
// if we don't have an ovveriden address, assume they want to send to the node's active socket
|
// if we don't have an ovveriden address, assume they want to send to the node's active socket
|
||||||
const HifiSockAddr* destinationSockAddr = &overridenSockAddr;
|
const HifiSockAddr* destinationSockAddr = &overridenSockAddr;
|
||||||
if (overridenSockAddr.isNull()) {
|
if (overridenSockAddr.isNull()) {
|
||||||
if (getNodeActiveSocketOrPing(destinationNode)) {
|
if (destinationNode->getActiveSocket()) {
|
||||||
// use the node's active socket as the destination socket
|
// use the node's active socket as the destination socket
|
||||||
destinationSockAddr = destinationNode->getActiveSocket();
|
destinationSockAddr = destinationNode->getActiveSocket();
|
||||||
} else {
|
} else {
|
||||||
|
@ -140,6 +140,8 @@ qint64 NodeList::writeDatagram(const QByteArray& datagram, const SharedNodePoint
|
||||||
// setup the MD5 hash for source verification in the header
|
// setup the MD5 hash for source verification in the header
|
||||||
replaceHashInPacketGivenConnectionUUID(datagramCopy, destinationNode->getConnectionSecret());
|
replaceHashInPacketGivenConnectionUUID(datagramCopy, destinationNode->getConnectionSecret());
|
||||||
|
|
||||||
|
qDebug() << "Sending a packet of type" << packetTypeForPacket(datagram);
|
||||||
|
|
||||||
return _nodeSocket.writeDatagram(datagramCopy, destinationSockAddr->getAddress(), destinationSockAddr->getPort());
|
return _nodeSocket.writeDatagram(datagramCopy, destinationSockAddr->getAddress(), destinationSockAddr->getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,8 +682,11 @@ SharedNodePointer NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType,
|
||||||
Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket);
|
Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket);
|
||||||
SharedNodePointer newNodeSharedPointer(newNode, &QObject::deleteLater);
|
SharedNodePointer newNodeSharedPointer(newNode, &QObject::deleteLater);
|
||||||
|
|
||||||
|
// try and ping the new node right away to open a connection
|
||||||
|
pingPublicAndLocalSocketsForInactiveNode(newNodeSharedPointer);
|
||||||
|
|
||||||
_nodeHash.insert(newNode->getUUID(), newNodeSharedPointer);
|
_nodeHash.insert(newNode->getUUID(), newNodeSharedPointer);
|
||||||
|
|
||||||
_nodeHashMutex.unlock();
|
_nodeHashMutex.unlock();
|
||||||
|
|
||||||
qDebug() << "Added" << *newNode;
|
qDebug() << "Added" << *newNode;
|
||||||
|
@ -740,16 +745,6 @@ void NodeList::pingInactiveNodes() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const HifiSockAddr* NodeList::getNodeActiveSocketOrPing(const SharedNodePointer& node) {
|
|
||||||
if (node && node->getActiveSocket()) {
|
|
||||||
return node->getActiveSocket();
|
|
||||||
} else if (node) {
|
|
||||||
pingPublicAndLocalSocketsForInactiveNode(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NodeList::activateSocketFromNodeCommunication(const QByteArray& packet, const SharedNodePointer& sendingNode) {
|
void NodeList::activateSocketFromNodeCommunication(const QByteArray& packet, const SharedNodePointer& sendingNode) {
|
||||||
// deconstruct this ping packet to see if it is a public or local reply
|
// deconstruct this ping packet to see if it is a public or local reply
|
||||||
QDataStream packetStream(packet);
|
QDataStream packetStream(packet);
|
||||||
|
|
|
@ -129,8 +129,6 @@ public:
|
||||||
|
|
||||||
void loadData(QSettings* settings);
|
void loadData(QSettings* settings);
|
||||||
void saveData(QSettings* settings);
|
void saveData(QSettings* settings);
|
||||||
|
|
||||||
const HifiSockAddr* getNodeActiveSocketOrPing(const SharedNodePointer& node);
|
|
||||||
public slots:
|
public slots:
|
||||||
void sendDomainServerCheckIn();
|
void sendDomainServerCheckIn();
|
||||||
void pingInactiveNodes();
|
void pingInactiveNodes();
|
||||||
|
|
|
@ -105,12 +105,12 @@ QUuid uuidFromPacketHeader(const QByteArray& packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray hashFromPacketHeader(const QByteArray& packet) {
|
QByteArray hashFromPacketHeader(const QByteArray& packet) {
|
||||||
return packet.mid(NUM_STATIC_HEADER_BYTES - NUM_BYTES_MD5_HASH, NUM_BYTES_MD5_HASH);
|
return packet.mid(numBytesForPacketHeader(packet) - NUM_BYTES_MD5_HASH, NUM_BYTES_MD5_HASH);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray hashForPacketAndConnectionUUID(const QByteArray& packet, const QUuid& connectionUUID) {
|
QByteArray hashForPacketAndConnectionUUID(const QByteArray& packet, const QUuid& connectionUUID) {
|
||||||
return QCryptographicHash::hash(packet.mid(numBytesForPacketHeader(packet))
|
return QCryptographicHash::hash(packet.mid(numBytesForPacketHeader(packet)) + connectionUUID.toRfc4122(),
|
||||||
+ connectionUUID.toRfc4122(), QCryptographicHash::Md5);
|
QCryptographicHash::Md5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void replaceHashInPacketGivenConnectionUUID(QByteArray& packet, const QUuid& connectionUUID) {
|
void replaceHashInPacketGivenConnectionUUID(QByteArray& packet, const QUuid& connectionUUID) {
|
||||||
|
|
Loading…
Reference in a new issue