Check protocol compatibility on handshake

This commit is contained in:
Patrick Nicolas
2025-06-17 09:31:30 +02:00
parent 7e3b6d001e
commit 169e8bf206
3 changed files with 18 additions and 2 deletions
+6
View File
@@ -19,6 +19,7 @@
#include "wivrn_client.h"
#include "hardware.h"
#include "protocol_version.h"
#include "secrets.h"
#include "smp.h"
#include "spdlog/common.h"
@@ -99,6 +100,7 @@ void wivrn_session::handshake(T address, bool tcp_only, crypto::key & headset_ke
};
send_control(from_headset::crypto_handshake{
.protocol_version = wivrn::protocol_version,
.public_key = headset_keypair.public_key(),
.name = model_name(),
});
@@ -178,6 +180,10 @@ void wivrn_session::handshake(T address, bool tcp_only, crypto::key & headset_ke
case to_headset::crypto_handshake::crypto_state::pairing_disabled:
spdlog::info("Pairing is disabled on server");
throw std::runtime_error(_("Pairing is disabled on server"));
case to_headset::crypto_handshake::crypto_state::incompatible_version:
spdlog::error("Incompatible protocol versions");
throw std::runtime_error(_("Incompatible server version"));
}
// may be on control socket if forced TCP