mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-20 09:20:23 +02:00
verify packet versions at ice-server
This commit is contained in:
parent
4604bc5a3a
commit
086e4efe44
5 changed files with 34 additions and 13 deletions
|
@ -38,6 +38,9 @@ IceServer::IceServer(int argc, char* argv[]) :
|
||||||
using std::placeholders::_1;
|
using std::placeholders::_1;
|
||||||
_serverSocket.setVerifiedPacketCallback(std::bind(&IceServer::processPacket, this, _1));
|
_serverSocket.setVerifiedPacketCallback(std::bind(&IceServer::processPacket, this, _1));
|
||||||
|
|
||||||
|
// set packetVersionMatch as the verify packet operator for the udt::Socket
|
||||||
|
_serverSocket.setVerifyPacketOperator(std::bind(&IceServer::packetVersionMatch, this, _1));
|
||||||
|
|
||||||
// setup our timer to clear inactive peers
|
// setup our timer to clear inactive peers
|
||||||
QTimer* inactivePeerTimer = new QTimer(this);
|
QTimer* inactivePeerTimer = new QTimer(this);
|
||||||
connect(inactivePeerTimer, &QTimer::timeout, this, &IceServer::clearInactivePeers);
|
connect(inactivePeerTimer, &QTimer::timeout, this, &IceServer::clearInactivePeers);
|
||||||
|
@ -45,6 +48,17 @@ IceServer::IceServer(int argc, char* argv[]) :
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IceServer::packetVersionMatch(const udt::Packet& packet) {
|
||||||
|
if (packet.getVersion() == versionForPacketType(packet.getType())) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
qDebug() << "Packet version mismatch for packet" << packet.getType()
|
||||||
|
<< "(" << nameForPacketType(packet.getType()) << ") from" << packet.getSenderSockAddr();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void IceServer::processPacket(std::unique_ptr<udt::Packet> packet) {
|
void IceServer::processPacket(std::unique_ptr<udt::Packet> packet) {
|
||||||
PacketType::Value packetType = packet->getType();
|
PacketType::Value packetType = packet->getType();
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
private slots:
|
private slots:
|
||||||
void clearInactivePeers();
|
void clearInactivePeers();
|
||||||
private:
|
private:
|
||||||
|
bool packetVersionMatch(const udt::Packet& packet);
|
||||||
void processPacket(std::unique_ptr<udt::Packet> packet);
|
void processPacket(std::unique_ptr<udt::Packet> packet);
|
||||||
|
|
||||||
SharedNetworkPeer addOrUpdateHeartbeatingPeer(udt::Packet& incomingPacket);
|
SharedNetworkPeer addOrUpdateHeartbeatingPeer(udt::Packet& incomingPacket);
|
||||||
|
|
|
@ -452,7 +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.data(), &NodeList::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch);
|
connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch);
|
||||||
|
|
||||||
// connect to appropriate slots on AccountManager
|
// connect to appropriate slots on AccountManager
|
||||||
AccountManager& accountManager = AccountManager::getInstance();
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
|
|
|
@ -55,11 +55,13 @@ void NetworkPeer::setPublicSocket(const HifiSockAddr& publicSocket) {
|
||||||
_activeSocket = NULL;
|
_activeSocket = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_publicSocket.isNull()) {
|
bool wasOldSocketNull = _publicSocket.isNull();
|
||||||
qCDebug(networking) << "Public socket change for node" << *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
_publicSocket = publicSocket;
|
_publicSocket = publicSocket;
|
||||||
|
|
||||||
|
if (!wasOldSocketNull) {
|
||||||
|
qCDebug(networking) << "Public socket change for node" << *this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,11 +72,13 @@ void NetworkPeer::setLocalSocket(const HifiSockAddr& localSocket) {
|
||||||
_activeSocket = NULL;
|
_activeSocket = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_localSocket.isNull()) {
|
bool wasOldSocketNull = _localSocket.isNull();
|
||||||
qCDebug(networking) << "Local socket change for node" << *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
_localSocket = localSocket;
|
_localSocket = localSocket;
|
||||||
|
|
||||||
|
if (!wasOldSocketNull) {
|
||||||
|
qCDebug(networking) << "Local socket change for node" << *this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,11 +89,13 @@ void NetworkPeer::setSymmetricSocket(const HifiSockAddr& symmetricSocket) {
|
||||||
_activeSocket = NULL;
|
_activeSocket = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_symmetricSocket.isNull()) {
|
bool wasOldSocketNull = _symmetricSocket.isNull();
|
||||||
qCDebug(networking) << "Symmetric socket change for node" << *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
_symmetricSocket = symmetricSocket;
|
_symmetricSocket = symmetricSocket;
|
||||||
|
|
||||||
|
if (!wasOldSocketNull) {
|
||||||
|
qCDebug(networking) << "Symmetric socket change for node" << *this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
namespace udt {
|
namespace udt {
|
||||||
|
|
||||||
using VerifyPacketOperator = std::function<bool(Packet&)>;
|
using VerifyPacketOperator = std::function<bool(const Packet&)>;
|
||||||
using VerifiedPacketCallback = std::function<void(std::unique_ptr<Packet>)>;
|
using VerifiedPacketCallback = std::function<void(std::unique_ptr<Packet>)>;
|
||||||
|
|
||||||
class Socket : public QObject {
|
class Socket : public QObject {
|
||||||
|
|
Loading…
Reference in a new issue