From 2eef07e414854815b17ef8a155ea5dce9939dae9 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Tue, 24 May 2016 15:38:08 -0700 Subject: [PATCH] cleanup and dead code removal --- domain-server/src/DomainGatekeeper.cpp | 26 +------------------ domain-server/src/DomainServer.cpp | 13 +--------- domain-server/src/NodeConnectionData.cpp | 5 ++-- interface/src/Application.cpp | 13 ---------- interface/src/Application.h | 4 +-- .../src/scripting/WindowScriptingInterface.h | 4 +-- libraries/networking/src/DomainHandler.cpp | 24 ----------------- libraries/networking/src/LimitedNodeList.cpp | 4 --- libraries/networking/src/NLPacket.cpp | 1 + libraries/networking/src/NodeList.cpp | 17 ------------ libraries/networking/src/NodeList.h | 13 +++------- libraries/networking/src/PacketReceiver.cpp | 11 -------- 12 files changed, 11 insertions(+), 124 deletions(-) diff --git a/domain-server/src/DomainGatekeeper.cpp b/domain-server/src/DomainGatekeeper.cpp index 80137935ca..bc89b99e8a 100644 --- a/domain-server/src/DomainGatekeeper.cpp +++ b/domain-server/src/DomainGatekeeper.cpp @@ -55,10 +55,6 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointergetSize() == 0) { return; } - - //qDebug() << __FUNCTION__ << "packetVersion:" << message->getVersion(); - - QDataStream packetStream(message->getMessage()); // read a NodeConnectionData object from the packet so we can pass around this data while we're inspecting it @@ -72,8 +68,6 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointergetSenderSockAddr(); @@ -548,27 +537,14 @@ void DomainGatekeeper::sendConnectionDeniedPacket(const QString& reason, const H quint16 payloadSize = utfString.size(); // setup the DomainConnectionDenied packet - auto connectionDeniedPacket = NLPacket::create(PacketType::DomainConnectionDenied); // , payloadSize + sizeof(payloadSize) + auto connectionDeniedPacket = NLPacket::create(PacketType::DomainConnectionDenied); // pack in the reason the connection was denied (the client displays this) if (payloadSize > 0) { - qDebug() << __FUNCTION__ << "line:" << __LINE__ << "connectionDeniedPacket->getDataSize():" << connectionDeniedPacket->getDataSize(); - qDebug() << __FUNCTION__ << "about to write reasonCode:" << (int)reasonCode; uint8_t reasonCodeWire = (uint8_t)reasonCode; - qDebug() << __FUNCTION__ << "about to write reasonCodeWire:" << (int)reasonCodeWire; - qDebug() << __FUNCTION__ << "line:" << __LINE__ << "connectionDeniedPacket->getDataSize():" << connectionDeniedPacket->getDataSize(); connectionDeniedPacket->writePrimitive(reasonCodeWire); - qDebug() << __FUNCTION__ << "line:" << __LINE__ << "connectionDeniedPacket->getDataSize():" << connectionDeniedPacket->getDataSize(); - qDebug() << __FUNCTION__ << "about to write payloadSize:" << payloadSize; - qDebug() << __FUNCTION__ << "line:" << __LINE__ << "connectionDeniedPacket->getDataSize():" << connectionDeniedPacket->getDataSize(); connectionDeniedPacket->writePrimitive(payloadSize); - qDebug() << __FUNCTION__ << "line:" << __LINE__ << "connectionDeniedPacket->getDataSize():" << connectionDeniedPacket->getDataSize(); - qDebug() << __FUNCTION__ << "about to write utfString:" << utfString; - qDebug() << __FUNCTION__ << "about to write utfString.size():" << utfString.size(); - qDebug() << __FUNCTION__ << "line:" << __LINE__ << "connectionDeniedPacket->getDataSize():" << connectionDeniedPacket->getDataSize(); connectionDeniedPacket->write(utfString); - qDebug() << __FUNCTION__ << "line:" << __LINE__ << "connectionDeniedPacket->getDataSize():" << connectionDeniedPacket->getDataSize(); - } // send the packet off diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 18ca7e2941..f6fbb3f470 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -309,8 +309,6 @@ bool DomainServer::packetVersionMatch(const udt::Packet& packet) { PacketType headerType = NLPacket::typeInHeader(packet); PacketVersion headerVersion = NLPacket::versionInHeader(packet); - //qDebug() << __FUNCTION__ << "type:" << headerType << "version:" << (int)headerVersion; - auto nodeList = DependencyManager::get(); // This implements a special case that handles OLD clients which don't know how to negotiate matching @@ -320,9 +318,6 @@ bool DomainServer::packetVersionMatch(const udt::Packet& packet) { // warn the user that the protocol is not compatible if (headerType == PacketType::DomainConnectRequest && headerVersion < static_cast(DomainConnectRequestVersion::HasProtocolVersions)) { - - //qDebug() << __FUNCTION__ << "OLD VERSION checkin sending an intentional bad packet -------------------------------"; - auto packetWithBadVersion = NLPacket::create(PacketType::EntityData); nodeList->sendPacket(std::move(packetWithBadVersion), packet.getSenderSockAddr()); return false; @@ -407,8 +402,7 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) { // add whatever static assignments that have been parsed to the queue addStaticAssignmentsToQueue(); - // set packetVersionMatch as the verify packet operator for the udt::Socket - //using std::placeholders::_1; + // set a custum packetVersionMatch as the verify packet operator for the udt::Socket nodeList->setPacketFilterOperator(&DomainServer::packetVersionMatch); } @@ -701,8 +695,6 @@ void DomainServer::populateDefaultStaticAssignmentsExcludingTypes(const QSet message, SharedNodePointer sendingNode) { - //qDebug() << __FUNCTION__ << "---------------"; - QDataStream packetStream(message->getMessage()); NodeConnectionData nodeRequestData = NodeConnectionData::fromDataStream(packetStream, message->getSenderSockAddr(), false); @@ -782,9 +774,6 @@ void DomainServer::handleConnectedNode(SharedNodePointer newNode) { } void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const HifiSockAddr &senderSockAddr) { - - //qDebug() << __FUNCTION__ << "---------------"; - 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 diff --git a/domain-server/src/NodeConnectionData.cpp b/domain-server/src/NodeConnectionData.cpp index 5ddcbf1792..13bb9123d8 100644 --- a/domain-server/src/NodeConnectionData.cpp +++ b/domain-server/src/NodeConnectionData.cpp @@ -24,10 +24,11 @@ NodeConnectionData NodeConnectionData::fromDataStream(QDataStream& dataStream, c char* rawBytes; uint length; - // FIXME -- do we need to delete the rawBytes after it's been copied into the QByteArray? dataStream.readBytes(rawBytes, length); newHeader.protocolVersion = QByteArray(rawBytes, length); - //qDebug() << __FUNCTION__ << "...got protocol version from node... version:" << newHeader.protocolVersion; + + // NOTE: QDataStream::readBytes() - The buffer is allocated using new []. Destroy it with the delete [] operator. + delete[] rawBytes; } dataStream >> newHeader.nodeType diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 58a273737c..bf897015f8 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -654,11 +654,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : connect(nodeList.data(), &NodeList::nodeActivated, this, &Application::nodeActivated); connect(nodeList.data(), &NodeList::uuidChanged, getMyAvatar(), &MyAvatar::setSessionUUID); connect(nodeList.data(), &NodeList::uuidChanged, this, &Application::setSessionUUID); - connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, this, &Application::limitOfSilentDomainCheckInsReached); - //connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset); - - connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch); // connect to appropriate slots on AccountManager @@ -1069,16 +1065,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : } void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCode) { - qDebug() << __FUNCTION__ << "message:" << reasonMessage << "code:" << reasonCode; - qDebug() << __FUNCTION__ << "DomainHandler::ConnectionRefusedReason::ProtocolMismatch:" << (int)DomainHandler::ConnectionRefusedReason::ProtocolMismatch; - if (static_cast(reasonCode) == DomainHandler::ConnectionRefusedReason::ProtocolMismatch) { - qDebug() << __FUNCTION__ << " PROTOCOL MISMATCH!!!"; notifyPacketVersionMismatch(); } } - QString Application::getUserAgent() { if (QThread::currentThread() != thread()) { QString userAgent; @@ -4595,12 +4586,8 @@ void Application::setSessionUUID(const QUuid& sessionUUID) const { // We won't actually complete the connection, but if the server responds, we know that it needs to be upgraded (or we // need to be downgraded to talk to it). void Application::limitOfSilentDomainCheckInsReached() { - //qDebug() << __FUNCTION__; - auto nodeList = DependencyManager::get(); - nodeList->downgradeDomainServerCheckInVersion(); // attempt to use an older domain checkin version - nodeList->reset(); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 69f48e9541..a17250a58e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -262,9 +262,7 @@ public slots: void setActiveFaceTracker() const; #if (PR_BUILD || DEV_BUILD) - void sendWrongProtocolVersionsSignature(bool checked) { - ::sendWrongProtocolVersionsSignature(checked); - } + void sendWrongProtocolVersionsSignature(bool checked) { ::sendWrongProtocolVersionsSignature(checked); } #endif #ifdef HAVE_IVIEWHMD diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 72f4ccd866..dfe02a5064 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -16,8 +16,6 @@ #include #include -#include - class WebWindowClass; class WindowScriptingInterface : public QObject, public Dependency { @@ -47,7 +45,7 @@ public slots: signals: void domainChanged(const QString& domainHostname); void svoImportRequested(const QString& url); - void domainConnectionRefused(const QString& reasonMessage, int reason); + void domainConnectionRefused(const QString& reasonMessage, int reasonCode); private slots: WebWindowClass* doCreateWebWindow(const QString& title, const QString& url, int width, int height); diff --git a/libraries/networking/src/DomainHandler.cpp b/libraries/networking/src/DomainHandler.cpp index 67a41c866a..1efcfc7f27 100644 --- a/libraries/networking/src/DomainHandler.cpp +++ b/libraries/networking/src/DomainHandler.cpp @@ -104,9 +104,6 @@ void DomainHandler::hardReset() { _hasCheckedForAccessToken = false; - //qDebug() << __FUNCTION__ << "about to call _domainConnectionRefusals.clear();"; - //_domainConnectionRefusals.clear(); - // clear any pending path we may have wanted to ask the previous DS about _pendingPath.clear(); } @@ -145,7 +142,6 @@ void DomainHandler::setSocketAndID(const QString& hostname, quint16 port, const _hostname = hostname; // FIXME - is this the right place??? - qDebug() << __FUNCTION__ << "about to call _domainConnectionRefusals.clear();"; _domainConnectionRefusals.clear(); qCDebug(networking) << "Updated domain hostname to" << _hostname; @@ -374,40 +370,20 @@ void DomainHandler::processDomainServerConnectionDeniedPacket(QSharedPointergetPosition():" << message->getPosition(); message->readPrimitive(&reasonCodeWire); - qDebug() << __FUNCTION__ << "reasonCodeWire:" << reasonCodeWire; ConnectionRefusedReason reasonCode = static_cast(reasonCodeWire); - qDebug() << __FUNCTION__ << "reasonCode:" << (int)reasonCode; - - qDebug() << __FUNCTION__ << "line:" << __LINE__ << "message->getPosition():" << message->getPosition(); - quint16 reasonSize; message->readPrimitive(&reasonSize); - qDebug() << __FUNCTION__ << "reasonSize:" << reasonSize; - qDebug() << __FUNCTION__ << "line:" << __LINE__ << "message->getPosition():" << message->getPosition(); auto reasonText = message->readWithoutCopy(reasonSize); - qDebug() << __FUNCTION__ << "line:" << __LINE__ << "reasonText:" << reasonText; QString reasonMessage = QString::fromUtf8(reasonText); - qDebug() << __FUNCTION__ << "line:" << __LINE__ << "reasonMessage:" << reasonMessage; - - qDebug() << __FUNCTION__ << "line:" << __LINE__ << "message->getPosition():" << message->getPosition(); // output to the log so the user knows they got a denied connection request // and check and signal for an access token so that we can make sure they are logged in qCWarning(networking) << "The domain-server denied a connection request: " << reasonMessage; - qDebug(networking) << "_domainConnectionRefusals:" << _domainConnectionRefusals; - if (!_domainConnectionRefusals.contains(reasonMessage)) { - qDebug(networking) << "about to call _domainConnectionRefusals.append(reasonMessage);"; _domainConnectionRefusals.append(reasonMessage); - qDebug(networking) << "_domainConnectionRefusals:" << _domainConnectionRefusals; - - emit domainConnectionRefused(reasonMessage, (int)reasonCode); - } else { - qDebug(networking) << "ALREADY EMITTED domainConnectionRefused() ----------------------------"; } auto accountManager = DependencyManager::get(); diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 714b69fd89..2c10d0627e 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -162,17 +162,13 @@ QUdpSocket& LimitedNodeList::getDTLSSocket() { } bool LimitedNodeList::isPacketVerified(const udt::Packet& packet) { - //qDebug() << __FUNCTION__; return packetVersionMatch(packet) && packetSourceAndHashMatch(packet); } bool LimitedNodeList::packetVersionMatch(const udt::Packet& packet) { - PacketType headerType = NLPacket::typeInHeader(packet); PacketVersion headerVersion = NLPacket::versionInHeader(packet); - //qDebug() << __FUNCTION__ << "headerType:" << headerType << "version:" << (int)headerVersion; - if (headerVersion != versionForPacketType(headerType)) { static QMultiHash sourcedVersionDebugSuppressMap; diff --git a/libraries/networking/src/NLPacket.cpp b/libraries/networking/src/NLPacket.cpp index 93f8659663..34a159ae6c 100644 --- a/libraries/networking/src/NLPacket.cpp +++ b/libraries/networking/src/NLPacket.cpp @@ -67,6 +67,7 @@ NLPacket::NLPacket(PacketType type, qint64 size, bool isReliable, bool isPartOfM _version((version == 0) ? versionForPacketType(type) : version) { adjustPayloadStartAndCapacity(NLPacket::localHeaderSize(_type)); + writeTypeAndVersion(); } diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 5f3f34dafb..082200fccc 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -293,7 +293,6 @@ void NodeList::sendDomainServerCheckIn() { } auto packetVersion = (domainPacketType == PacketType::DomainConnectRequest) ? _domainConnectRequestVersion : 0; - //qDebug() << __FUNCTION__ << " NLPacket::create() version:" << (int)packetVersion; auto domainPacket = NLPacket::create(domainPacketType, -1, false, false, packetVersion); QDataStream packetStream(domainPacket.get()); @@ -319,12 +318,7 @@ void NodeList::sendDomainServerCheckIn() { if (_domainConnectRequestVersion >= static_cast(DomainConnectRequestVersion::HasProtocolVersions)) { QByteArray protocolVersionSig = protocolVersionsSignature(); packetStream.writeBytes(protocolVersionSig.constData(), protocolVersionSig.size()); - //qDebug() << __FUNCTION__ << " including protocol version --------------------------"; - } else { - //qDebug() << __FUNCTION__ << "_domainConnectRequestVersion less than HasProtocolVersions - not including protocol version"; } - } else { - //qDebug() << __FUNCTION__ << "NOT a DomainConnnectRequest ----------- not including checkin details -------"; } // pack our data to send to the domain-server including @@ -332,9 +326,6 @@ void NodeList::sendDomainServerCheckIn() { packetStream << _ownerType << _publicSockAddr << _localSockAddr << _nodeTypesOfInterest.toList(); if (_domainConnectRequestVersion >= static_cast(DomainConnectRequestVersion::HasHostname)) { packetStream << DependencyManager::get()->getPlaceName(); - //qDebug() << __FUNCTION__ << " including host name --------------------------"; - } else { - //qDebug() << __FUNCTION__ << "_domainConnectRequestVersion less than HasHostname - not including host name"; } if (!_domainHandler.isConnected()) { @@ -363,7 +354,6 @@ void NodeList::sendDomainServerCheckIn() { // increment the count of un-replied check-ins _numNoReplyDomainCheckIns++; - //qDebug() << __FUNCTION__ << " _numNoReplyDomainCheckIns:" << _numNoReplyDomainCheckIns << " --------------------------"; } if (!_publicSockAddr.isNull() && !_domainHandler.isConnected() && !_domainHandler.getPendingDomainID().isNull()) { @@ -531,22 +521,15 @@ void NodeList::processDomainServerConnectionTokenPacket(QSharedPointer message) { - //qDebug() << __FUNCTION__; - if (_domainHandler.getSockAddr().isNull()) { // refuse to process this packet if we aren't currently connected to the DS return; } - //qDebug() << __FUNCTION__ << "_numNoReplyDomainCheckIns:" << _numNoReplyDomainCheckIns; - // this is a packet from the domain server, reset the count of un-replied check-ins _numNoReplyDomainCheckIns = 0; - //qDebug() << __FUNCTION__ << "RESET.... _numNoReplyDomainCheckIns:" << _numNoReplyDomainCheckIns; - // emit our signal so listeners know we just heard from the DS - //qDebug() << __FUNCTION__ << "about to emit receivedDomainServerList() -----------------------------------------------"; emit receivedDomainServerList(); DependencyManager::get()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::ReceiveDSList); diff --git a/libraries/networking/src/NodeList.h b/libraries/networking/src/NodeList.h index 3158262c87..b269554e77 100644 --- a/libraries/networking/src/NodeList.h +++ b/libraries/networking/src/NodeList.h @@ -69,11 +69,7 @@ public: void setIsShuttingDown(bool isShuttingDown) { _isShuttingDown = isShuttingDown; } /// downgrades the DomainConnnectRequest PacketVersion to attempt to probe for older domain servers - void downgradeDomainServerCheckInVersion() { - qDebug() << __FUNCTION__ << "----------------------------------------------------------"; - _domainConnectRequestVersion--; - - } + void downgradeDomainServerCheckInVersion() { _domainConnectRequestVersion--; } public slots: void reset(); @@ -92,11 +88,8 @@ public slots: void processICEPingPacket(QSharedPointer message); - void resetDomainServerCheckInVersion() - { - qDebug() << __FUNCTION__ << "----------------------------------------------------------"; - _domainConnectRequestVersion = versionForPacketType(PacketType::DomainConnectRequest); - } + void resetDomainServerCheckInVersion() + { _domainConnectRequestVersion = versionForPacketType(PacketType::DomainConnectRequest); } signals: void limitOfSilentDomainCheckInsReached(); diff --git a/libraries/networking/src/PacketReceiver.cpp b/libraries/networking/src/PacketReceiver.cpp index 8df9a1038a..9cbff8abbd 100644 --- a/libraries/networking/src/PacketReceiver.cpp +++ b/libraries/networking/src/PacketReceiver.cpp @@ -309,29 +309,20 @@ void PacketReceiver::handleVerifiedMessage(QSharedPointer recei connectionType, Q_ARG(QSharedPointer, receivedMessage), Q_ARG(SharedNodePointer, matchingNode)); - - //qDebug() << __FUNCTION__ << "line:" << __LINE__ << "success:" << success << "packetType:" << packetType; - } else if (metaMethod.parameterTypes().contains(QSHAREDPOINTER_NODE_NORMALIZED)) { success = metaMethod.invoke(listener.object, connectionType, Q_ARG(QSharedPointer, receivedMessage), Q_ARG(QSharedPointer, matchingNode)); - - //qDebug() << __FUNCTION__ << "line:" << __LINE__ << "success:" << success << "packetType:" << packetType; - } else { success = metaMethod.invoke(listener.object, connectionType, Q_ARG(QSharedPointer, receivedMessage)); - //qDebug() << __FUNCTION__ << "line:" << __LINE__ << "success:" << success << "packetType:" << packetType; } } else { listenerIsDead = true; } } else { - //qDebug() << __FUNCTION__ << "line:" << __LINE__ << "Got verified unsourced packet list." << "packetType:" << packetType; - // qDebug() << "Got verified unsourced packet list: " << QString(nlPacketList->getMessage()); emit dataReceived(NodeType::Unassigned, receivedMessage->getSize()); @@ -339,8 +330,6 @@ void PacketReceiver::handleVerifiedMessage(QSharedPointer recei if (listener.object) { success = listener.method.invoke(listener.object, Q_ARG(QSharedPointer, receivedMessage)); - - //qDebug() << __FUNCTION__ << "line:" << __LINE__ << "success:" << success << "packetType:" << packetType; } else { listenerIsDead = true; }