mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 18:26:26 +02:00
add protocol version signature to metaverse heartbeat
This commit is contained in:
parent
2cd38064a5
commit
1a66574adb
3 changed files with 15 additions and 4 deletions
|
@ -1083,9 +1083,11 @@ void DomainServer::sendHeartbeatToMetaverse(const QString& networkAddress) {
|
||||||
// Setup the domain object to send to the data server
|
// Setup the domain object to send to the data server
|
||||||
QJsonObject domainObject;
|
QJsonObject domainObject;
|
||||||
|
|
||||||
// add the version
|
// add the versions
|
||||||
static const QString VERSION_KEY = "version";
|
static const QString VERSION_KEY = "version";
|
||||||
domainObject[VERSION_KEY] = BuildInfo::VERSION;
|
domainObject[VERSION_KEY] = BuildInfo::VERSION;
|
||||||
|
static const QString PROTOCOL_KEY = "protocol";
|
||||||
|
domainObject[PROTOCOL_KEY] = protocolVersionsSignatureBase64();
|
||||||
|
|
||||||
// add networking
|
// add networking
|
||||||
if (!networkAddress.isEmpty()) {
|
if (!networkAddress.isEmpty()) {
|
||||||
|
|
|
@ -99,8 +99,9 @@ void sendWrongProtocolVersionsSignature(bool sendWrongVersion) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QByteArray protocolVersionsSignature() {
|
static QByteArray protocolVersionSignature;
|
||||||
static QByteArray protocolVersionSignature;
|
static QString protocolVersionSignatureBase64;
|
||||||
|
static void ensureProtocolVersionsSignature() {
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
std::call_once(once, [&] {
|
std::call_once(once, [&] {
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
|
@ -114,8 +115,11 @@ QByteArray protocolVersionsSignature() {
|
||||||
QCryptographicHash hash(QCryptographicHash::Md5);
|
QCryptographicHash hash(QCryptographicHash::Md5);
|
||||||
hash.addData(buffer);
|
hash.addData(buffer);
|
||||||
protocolVersionSignature = hash.result();
|
protocolVersionSignature = hash.result();
|
||||||
|
protocolVersionSignatureBase64 = protocolVersionSignature.toBase64();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
QByteArray protocolVersionsSignature() {
|
||||||
|
ensureProtocolVersionsSignature();
|
||||||
#if (PR_BUILD || DEV_BUILD)
|
#if (PR_BUILD || DEV_BUILD)
|
||||||
if (sendWrongProtocolVersion) {
|
if (sendWrongProtocolVersion) {
|
||||||
return QByteArray("INCORRECTVERSION"); // only for debugging version checking
|
return QByteArray("INCORRECTVERSION"); // only for debugging version checking
|
||||||
|
@ -124,3 +128,7 @@ QByteArray protocolVersionsSignature() {
|
||||||
|
|
||||||
return protocolVersionSignature;
|
return protocolVersionSignature;
|
||||||
}
|
}
|
||||||
|
QString protocolVersionsSignatureBase64() {
|
||||||
|
ensureProtocolVersionsSignature();
|
||||||
|
return protocolVersionSignatureBase64;
|
||||||
|
}
|
||||||
|
|
|
@ -113,6 +113,7 @@ extern const QSet<PacketType> NON_SOURCED_PACKETS;
|
||||||
|
|
||||||
PacketVersion versionForPacketType(PacketType packetType);
|
PacketVersion versionForPacketType(PacketType packetType);
|
||||||
QByteArray protocolVersionsSignature(); /// returns a unqiue signature for all the current protocols
|
QByteArray protocolVersionsSignature(); /// returns a unqiue signature for all the current protocols
|
||||||
|
QString protocolVersionsSignatureBase64();
|
||||||
|
|
||||||
#if (PR_BUILD || DEV_BUILD)
|
#if (PR_BUILD || DEV_BUILD)
|
||||||
void sendWrongProtocolVersionsSignature(bool sendWrongVersion); /// for debugging version negotiation
|
void sendWrongProtocolVersionsSignature(bool sendWrongVersion); /// for debugging version negotiation
|
||||||
|
|
Loading…
Reference in a new issue