cleanup and dead code removal

This commit is contained in:
Brad Hefta-Gaub 2016-05-24 15:38:08 -07:00
parent 12a1857280
commit 2eef07e414
12 changed files with 11 additions and 124 deletions

View file

@ -55,10 +55,6 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointer<ReceivedMessag
if (message->getSize() == 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(QSharedPointer<ReceivedMessag
DomainHandler::ConnectionRefusedReason::ProtocolMismatch);
return;
}
//qDebug() << __FUNCTION__ << "Protocol Version MATCH - continue with processing connection.";
if (nodeConnection.localSockAddr.isNull() || nodeConnection.publicSockAddr.isNull()) {
qDebug() << "Unexpected data received for node local socket or public socket. Will not allow connection.";
@ -111,9 +105,7 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointer<ReceivedMessag
}
}
//qDebug() << __FUNCTION__ << " about to processAgentConnectRequest() ---------------------";
node = processAgentConnectRequest(nodeConnection, username, usernameSignature);
//qDebug() << __FUNCTION__ << " AFTER processAgentConnectRequest() node: " << node << " ---------------------";
}
if (node) {
@ -125,9 +117,6 @@ void DomainGatekeeper::processConnectRequestPacket(QSharedPointer<ReceivedMessag
// signal that we just connected a node so the DomainServer can get it a list
// and broadcast its presence right away
//qDebug() << __FUNCTION__ << " about to connectedNode(node) ---------------------";
emit connectedNode(node);
} else {
qDebug() << "Refusing connection from node at" << message->getSenderSockAddr();
@ -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

View file

@ -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<LimitedNodeList>();
// 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<PacketVersion>(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<Ass
void DomainServer::processListRequestPacket(QSharedPointer<ReceivedMessage> 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

View file

@ -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

View file

@ -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<DomainHandler::ConnectionRefusedReason>(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>();
nodeList->downgradeDomainServerCheckInVersion(); // attempt to use an older domain checkin version
nodeList->reset();
}

View file

@ -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

View file

@ -16,8 +16,6 @@
#include <QtCore/QString>
#include <QtScript/QScriptValue>
#include <DomainHandler.h>
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);

View file

@ -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(QSharedPointer<Rec
// Read deny reason from packet
uint8_t reasonCodeWire;
qDebug() << __FUNCTION__ << "line:" << __LINE__ << "message->getPosition():" << message->getPosition();
message->readPrimitive(&reasonCodeWire);
qDebug() << __FUNCTION__ << "reasonCodeWire:" << reasonCodeWire;
ConnectionRefusedReason reasonCode = static_cast<ConnectionRefusedReason>(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<AccountManager>();

View file

@ -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<QUuid, PacketType> sourcedVersionDebugSuppressMap;

View file

@ -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();
}

View file

@ -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<PacketVersion>(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<PacketVersion>(DomainConnectRequestVersion::HasHostname)) {
packetStream << DependencyManager::get<AddressManager>()->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<ReceivedM
}
void NodeList::processDomainServerList(QSharedPointer<ReceivedMessage> 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<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::ReceiveDSList);

View file

@ -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<ReceivedMessage> message);
void resetDomainServerCheckInVersion()
{
qDebug() << __FUNCTION__ << "----------------------------------------------------------";
_domainConnectRequestVersion = versionForPacketType(PacketType::DomainConnectRequest);
}
void resetDomainServerCheckInVersion()
{ _domainConnectRequestVersion = versionForPacketType(PacketType::DomainConnectRequest); }
signals:
void limitOfSilentDomainCheckInsReached();

View file

@ -309,29 +309,20 @@ void PacketReceiver::handleVerifiedMessage(QSharedPointer<ReceivedMessage> recei
connectionType,
Q_ARG(QSharedPointer<ReceivedMessage>, 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>, receivedMessage),
Q_ARG(QSharedPointer<Node>, matchingNode));
//qDebug() << __FUNCTION__ << "line:" << __LINE__ << "success:" << success << "packetType:" << packetType;
} else {
success = metaMethod.invoke(listener.object,
connectionType,
Q_ARG(QSharedPointer<ReceivedMessage>, 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<ReceivedMessage> recei
if (listener.object) {
success = listener.method.invoke(listener.object,
Q_ARG(QSharedPointer<ReceivedMessage>, receivedMessage));
//qDebug() << __FUNCTION__ << "line:" << __LINE__ << "success:" << success << "packetType:" << packetType;
} else {
listenerIsDead = true;
}