From f637f5a4a61025f023670cab103a53a653a25e5d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 9 Oct 2014 17:07:32 -0700 Subject: [PATCH] =?UTF-8?q?always=C2=A0allow=20connection=20from=20localho?= =?UTF-8?q?st=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- domain-server/src/DomainServer.cpp | 19 +++++++++++-------- domain-server/src/DomainServer.h | 2 -- libraries/networking/src/LimitedNodeList.cpp | 1 - libraries/networking/src/LimitedNodeList.h | 2 ++ 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 25428ca4b3..d8e381c58c 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -556,14 +556,17 @@ void DomainServer::handleConnectRequest(const QByteArray& packet, const HifiSock static QVariantList allowedUsers = allowedUsersVariant ? allowedUsersVariant->toList() : QVariantList(); if (!isAssignment && allowedUsers.count() > 0) { - // this is an agent, we need to ask them to provide us with their signed username to see if they are allowed in - - QByteArray usernameRequestByteArray = byteArrayWithPopulatedHeader(PacketTypeDomainUsernameRequest); - - // send this oauth request datagram back to the client - LimitedNodeList::getInstance()->writeUnverifiedDatagram(usernameRequestByteArray, senderSockAddr); - - return; + // this is an agent, we need to ask them to provide us with their signed username to see if they are allowed in + // we always let in a user who is sending a packet from our local socket or from the localhost address + if (senderSockAddr.getAddress() != LimitedNodeList::getInstance()->getLocalSockAddr().getAddress() + && senderSockAddr.getAddress() != QHostAddress::LocalHost) { + QByteArray usernameRequestByteArray = byteArrayWithPopulatedHeader(PacketTypeDomainUsernameRequest); + + // send this oauth request datagram back to the client + LimitedNodeList::getInstance()->writeUnverifiedDatagram(usernameRequestByteArray, senderSockAddr); + + return; + } } if ((!isAssignment && !STATICALLY_ASSIGNED_NODES.contains(nodeType)) diff --git a/domain-server/src/DomainServer.h b/domain-server/src/DomainServer.h index 913d66cc32..a06f5fa35b 100644 --- a/domain-server/src/DomainServer.h +++ b/domain-server/src/DomainServer.h @@ -135,8 +135,6 @@ private: QSet _webAuthenticationStateSet; QHash _cookieSessionHash; - HifiSockAddr _localSockAddr; - QHash _connectingICEPeers; QHash _connectedICEPeers; diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index dd33c96d74..919dc75c23 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -679,7 +679,6 @@ void LimitedNodeList::updateLocalSockAddr() { qDebug() << "Local socket has changed from" << _localSockAddr << "to" << newSockAddr; } - _localSockAddr = newSockAddr; emit localSockAddrChanged(_localSockAddr); diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index c416773201..73381d01a5 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -101,6 +101,8 @@ public: const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket); SharedNodePointer updateSocketsForNode(const QUuid& uuid, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket); + + const HifiSockAddr& getLocalSockAddr() const { return _localSockAddr; } void processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet); void processKillNode(const QByteArray& datagram);