allow socket owner to specify unfiltered packets

This commit is contained in:
Stephen Birarda 2015-07-21 12:00:16 -07:00
parent ed6867e1a0
commit a61c04aa92
5 changed files with 9 additions and 3 deletions

View file

@ -452,8 +452,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
connect(nodeList.data(), &NodeList::uuidChanged, _myAvatar, &MyAvatar::setSessionUUID);
connect(nodeList.data(), &NodeList::uuidChanged, this, &Application::setSessionUUID);
connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset);
connect(&nodeList->getPacketReceiver(), &PacketReceiver::packetVersionMismatch,
this, &Application::notifyPacketVersionMismatch);
connect(&nodeList.data(), &NodeList::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch);
// connect to appropriate slots on AccountManager
AccountManager& accountManager = AccountManager::getInstance();

View file

@ -710,6 +710,7 @@ void LimitedNodeList::startSTUNPublicSocketUpdate() {
// if we don't know the STUN IP yet we need to have ourselves be called once it is known
if (_stunSockAddr.getAddress().isNull()) {
connect(&_stunSockAddr, &HifiSockAddr::lookupCompleted, this, &LimitedNodeList::startSTUNPublicSocketUpdate);
connect(&_stunSockAddr, &HifiSockAddr::lookupCompleted, this, &LimitedNodeList::addSTUNSockAddrToUnfiltered);
// in case we just completely fail to lookup the stun socket - add a 10s timeout that will trigger the fail case
const quint64 STUN_DNS_LOOKUP_TIMEOUT_MSECS = 10 * 1000;

View file

@ -310,9 +310,11 @@ protected:
functor(it);
}
}
private slots:
void flagTimeForConnectionStep(ConnectionStep connectionStep, quint64 timestamp);
void possiblyTimeoutSTUNAddressLookup();
void addSTUNSockAddrToUnfiltered() { _nodeSocket.addUnfilteredSockAddr(_stunSockAddr); } // called once STUN socket known
};
#endif // hifi_LimitedNodeList_h

View file

@ -85,7 +85,7 @@ void Socket::readPendingDatagrams() {
auto packet = Packet::fromReceivedPacket(std::move(buffer), packetSizeWithHeader, senderSockAddr);
// call our verification operator to see if this packet is verified
if (!_verifyPacketOperator || _verifyPacketOperator(*packet)) {
if (_unfilteredSockAddrs.contains(senderSockAddr) || !_verifyPacketOperator || _verifyPacketOperator(*packet)) {
// call the verified packet callback to let it handle this packet
return _verifiedPacketCallback(std::move(packet));

View file

@ -46,6 +46,8 @@ public:
{ _verifiedPacketCallback = verifiedPacketCallback; }
void setBufferSizes(int numBytes);
void addUnfilteredSockAddr(const HifiSockAddr& senderSockAddr) { _unfilteredSockAddrs.insert(senderSockAddr); }
private slots:
void readPendingDatagrams();
@ -54,6 +56,8 @@ private:
QUdpSocket _udpSocket { this };
VerifyPacketOperator _verifyPacketOperator;
VerifiedPacketCallback _verifiedPacketCallback;
QSet<HifiSockAddr> _unfilteredSockAddrs;
};
}