add protocol version signature to metaverse heartbeat

This commit is contained in:
howard-stearns 2016-07-18 14:29:49 -07:00
parent 2cd38064a5
commit 1a66574adb
3 changed files with 15 additions and 4 deletions

View file

@ -1083,9 +1083,11 @@ void DomainServer::sendHeartbeatToMetaverse(const QString& networkAddress) {
// Setup the domain object to send to the data server
QJsonObject domainObject;
// add the version
// add the versions
static const QString VERSION_KEY = "version";
domainObject[VERSION_KEY] = BuildInfo::VERSION;
static const QString PROTOCOL_KEY = "protocol";
domainObject[PROTOCOL_KEY] = protocolVersionsSignatureBase64();
// add networking
if (!networkAddress.isEmpty()) {

View file

@ -99,8 +99,9 @@ void sendWrongProtocolVersionsSignature(bool sendWrongVersion) {
}
#endif
QByteArray protocolVersionsSignature() {
static QByteArray protocolVersionSignature;
static QByteArray protocolVersionSignature;
static QString protocolVersionSignatureBase64;
static void ensureProtocolVersionsSignature() {
static std::once_flag once;
std::call_once(once, [&] {
QByteArray buffer;
@ -114,8 +115,11 @@ QByteArray protocolVersionsSignature() {
QCryptographicHash hash(QCryptographicHash::Md5);
hash.addData(buffer);
protocolVersionSignature = hash.result();
protocolVersionSignatureBase64 = protocolVersionSignature.toBase64();
});
}
QByteArray protocolVersionsSignature() {
ensureProtocolVersionsSignature();
#if (PR_BUILD || DEV_BUILD)
if (sendWrongProtocolVersion) {
return QByteArray("INCORRECTVERSION"); // only for debugging version checking
@ -124,3 +128,7 @@ QByteArray protocolVersionsSignature() {
return protocolVersionSignature;
}
QString protocolVersionsSignatureBase64() {
ensureProtocolVersionsSignature();
return protocolVersionSignatureBase64;
}

View file

@ -113,6 +113,7 @@ extern const QSet<PacketType> NON_SOURCED_PACKETS;
PacketVersion versionForPacketType(PacketType packetType);
QByteArray protocolVersionsSignature(); /// returns a unqiue signature for all the current protocols
QString protocolVersionsSignatureBase64();
#if (PR_BUILD || DEV_BUILD)
void sendWrongProtocolVersionsSignature(bool sendWrongVersion); /// for debugging version negotiation