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, _myAvatar, &MyAvatar::setSessionUUID);
connect(nodeList.data(), &NodeList::uuidChanged, this, &Application::setSessionUUID); connect(nodeList.data(), &NodeList::uuidChanged, this, &Application::setSessionUUID);
connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset); connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset);
connect(&nodeList->getPacketReceiver(), &PacketReceiver::packetVersionMismatch, connect(&nodeList.data(), &NodeList::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch);
this, &Application::notifyPacketVersionMismatch);
// connect to appropriate slots on AccountManager // connect to appropriate slots on AccountManager
AccountManager& accountManager = AccountManager::getInstance(); 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 we don't know the STUN IP yet we need to have ourselves be called once it is known
if (_stunSockAddr.getAddress().isNull()) { if (_stunSockAddr.getAddress().isNull()) {
connect(&_stunSockAddr, &HifiSockAddr::lookupCompleted, this, &LimitedNodeList::startSTUNPublicSocketUpdate); 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 // 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; const quint64 STUN_DNS_LOOKUP_TIMEOUT_MSECS = 10 * 1000;

View file

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

View file

@ -85,7 +85,7 @@ void Socket::readPendingDatagrams() {
auto packet = Packet::fromReceivedPacket(std::move(buffer), packetSizeWithHeader, senderSockAddr); auto packet = Packet::fromReceivedPacket(std::move(buffer), packetSizeWithHeader, senderSockAddr);
// call our verification operator to see if this packet is verified // 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 // call the verified packet callback to let it handle this packet
return _verifiedPacketCallback(std::move(packet)); return _verifiedPacketCallback(std::move(packet));

View file

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