mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 18:23:22 +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();
|
||||
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer);
|
||||
|
||||
if (audioMixer && nodeList->getNodeActiveSocketOrPing(audioMixer)) {
|
||||
if (audioMixer && audioMixer->getActiveSocket()) {
|
||||
MyAvatar* interfaceAvatar = Application::getInstance()->getAvatar();
|
||||
glm::vec3 headPosition = interfaceAvatar->getHead().getPosition();
|
||||
glm::quat headOrientation = interfaceAvatar->getHead().getOrientation();
|
||||
|
|
|
@ -265,7 +265,7 @@ void VoxelStatsDialog::showOctreeServersOfType(int& serverCount, NodeType_t serv
|
|||
std::stringstream extraDetails("");
|
||||
std::stringstream linkDetails("");
|
||||
|
||||
if (nodeList->getNodeActiveSocketOrPing(node)) {
|
||||
if (node->getActiveSocket()) {
|
||||
serverDetails << "active ";
|
||||
} else {
|
||||
serverDetails << "inactive ";
|
||||
|
|
|
@ -45,7 +45,7 @@ bool JurisdictionListener::queueJurisdictionRequest() {
|
|||
NodeList* nodeList = NodeList::getInstance();
|
||||
|
||||
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));
|
||||
nodeCount++;
|
||||
}
|
||||
|
|
|
@ -60,19 +60,17 @@ bool OctreeEditPacketSender::serversExist() const {
|
|||
|
||||
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
||||
// only send to the NodeTypes that are getMyNodeType()
|
||||
if (node->getType() == getMyNodeType()) {
|
||||
if (nodeList->getNodeActiveSocketOrPing(node)) {
|
||||
QUuid nodeUUID = node->getUUID();
|
||||
// If we've got Jurisdictions set, then check to see if we know the jurisdiction for this server
|
||||
if (_serverJurisdictions) {
|
||||
// lookup our nodeUUID in the jurisdiction map, if it's missing then we're
|
||||
// missing at least one jurisdiction
|
||||
if ((*_serverJurisdictions).find(nodeUUID) == (*_serverJurisdictions).end()) {
|
||||
atLeastOnJurisdictionMissing = true;
|
||||
}
|
||||
if (node->getType() == getMyNodeType() && node->getActiveSocket()) {
|
||||
QUuid nodeUUID = node->getUUID();
|
||||
// If we've got Jurisdictions set, then check to see if we know the jurisdiction for this server
|
||||
if (_serverJurisdictions) {
|
||||
// lookup our nodeUUID in the jurisdiction map, if it's missing then we're
|
||||
// missing at least one jurisdiction
|
||||
if ((*_serverJurisdictions).find(nodeUUID) == (*_serverJurisdictions).end()) {
|
||||
atLeastOnJurisdictionMissing = true;
|
||||
}
|
||||
hasServers = true;
|
||||
}
|
||||
hasServers = true;
|
||||
}
|
||||
if (atLeastOnJurisdictionMissing) {
|
||||
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()
|
||||
if (node->getType() == getMyNodeType() &&
|
||||
((node->getUUID() == nodeUUID) || (nodeUUID.isNull()))) {
|
||||
if (nodeList->getNodeActiveSocketOrPing(node)) {
|
||||
if (node->getActiveSocket()) {
|
||||
queuePacketForSending(node, QByteArray(reinterpret_cast<char*>(buffer), length));
|
||||
|
||||
// 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
|
||||
const HifiSockAddr* destinationSockAddr = &overridenSockAddr;
|
||||
if (overridenSockAddr.isNull()) {
|
||||
if (getNodeActiveSocketOrPing(destinationNode)) {
|
||||
if (destinationNode->getActiveSocket()) {
|
||||
// use the node's active socket as the destination socket
|
||||
destinationSockAddr = destinationNode->getActiveSocket();
|
||||
} else {
|
||||
|
@ -140,6 +140,8 @@ qint64 NodeList::writeDatagram(const QByteArray& datagram, const SharedNodePoint
|
|||
// setup the MD5 hash for source verification in the header
|
||||
replaceHashInPacketGivenConnectionUUID(datagramCopy, destinationNode->getConnectionSecret());
|
||||
|
||||
qDebug() << "Sending a packet of type" << packetTypeForPacket(datagram);
|
||||
|
||||
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);
|
||||
SharedNodePointer newNodeSharedPointer(newNode, &QObject::deleteLater);
|
||||
|
||||
// try and ping the new node right away to open a connection
|
||||
pingPublicAndLocalSocketsForInactiveNode(newNodeSharedPointer);
|
||||
|
||||
_nodeHash.insert(newNode->getUUID(), newNodeSharedPointer);
|
||||
|
||||
|
||||
_nodeHashMutex.unlock();
|
||||
|
||||
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) {
|
||||
// deconstruct this ping packet to see if it is a public or local reply
|
||||
QDataStream packetStream(packet);
|
||||
|
|
|
@ -129,8 +129,6 @@ public:
|
|||
|
||||
void loadData(QSettings* settings);
|
||||
void saveData(QSettings* settings);
|
||||
|
||||
const HifiSockAddr* getNodeActiveSocketOrPing(const SharedNodePointer& node);
|
||||
public slots:
|
||||
void sendDomainServerCheckIn();
|
||||
void pingInactiveNodes();
|
||||
|
|
|
@ -105,12 +105,12 @@ QUuid uuidFromPacketHeader(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) {
|
||||
return QCryptographicHash::hash(packet.mid(numBytesForPacketHeader(packet))
|
||||
+ connectionUUID.toRfc4122(), QCryptographicHash::Md5);
|
||||
return QCryptographicHash::hash(packet.mid(numBytesForPacketHeader(packet)) + connectionUUID.toRfc4122(),
|
||||
QCryptographicHash::Md5);
|
||||
}
|
||||
|
||||
void replaceHashInPacketGivenConnectionUUID(QByteArray& packet, const QUuid& connectionUUID) {
|
||||
|
|
Loading…
Reference in a new issue