mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Fix comparison for glare algorithm
This commit is contained in:
parent
00740a7e65
commit
62b3b461ec
2 changed files with 9 additions and 5 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
static constexpr int TIMEOUT = 2 * 60 * 1000; // 2 minutes
|
static constexpr int TIMEOUT = 2 * 60 * 1000; // 2 minutes
|
||||||
|
|
||||||
|
@ -569,10 +570,10 @@ DeviceVerificationFlow::handleStartMessage(const mtx::events::msg::KeyVerificati
|
||||||
this->canonical_json = nlohmann::json(msg);
|
this->canonical_json = nlohmann::json(msg);
|
||||||
else {
|
else {
|
||||||
// resolve glare
|
// resolve glare
|
||||||
if (utils::localUser().toStdString() > this->toClient.to_string() &&
|
if (std::tuple(this->toClient.to_string(), this->deviceId.toStdString()) <
|
||||||
http::client()->device_id() > this->deviceId.toStdString()) {
|
std::tuple(utils::localUser().toStdString(), http::client()->device_id())) {
|
||||||
// treat this as if the user with the smaller mxid and deviceid was the sender of
|
// treat this as if the user with the smaller mxid or smaller deviceid (if the mxid
|
||||||
// "start"
|
// was the same) was the sender of "start"
|
||||||
this->canonical_json = nlohmann::json(msg);
|
this->canonical_json = nlohmann::json(msg);
|
||||||
this->sender = false;
|
this->sender = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ using sas_ptr = std::unique_ptr<mtx::crypto::SAS>;
|
||||||
* && | n | | |
|
* && | n | | |
|
||||||
* no canonical_json | a | (m.key.verification.start) | | waitingForKeys
|
* no canonical_json | a | (m.key.verification.start) | | waitingForKeys
|
||||||
* | l |<--------------------------------| Not sending to prevent the glare resolve| && no commitment
|
* | l |<--------------------------------| Not sending to prevent the glare resolve| && no commitment
|
||||||
* | | | | && no canonical_json
|
* | | | (1) | && no canonical_json
|
||||||
* | | m.key.verification.start | |
|
* | | m.key.verification.start | |
|
||||||
* waitForOtherAccept | |-------------------------------->| (IF NOT ALREADY ASKED, |
|
* waitForOtherAccept | |-------------------------------->| (IF NOT ALREADY ASKED, |
|
||||||
* && | | | ASK FOR VERIFICATION REQUEST) | promptStartVerify, if not accepted
|
* && | | | ASK FOR VERIFICATION REQUEST) | promptStartVerify, if not accepted
|
||||||
|
@ -57,6 +57,9 @@ using sas_ptr = std::unique_ptr<mtx::crypto::SAS>;
|
||||||
* | | | |
|
* | | | |
|
||||||
* success/fail | | m.key.verification.done | | success/fail
|
* success/fail | | m.key.verification.done | | success/fail
|
||||||
* | |<------------------------------->| |
|
* | |<------------------------------->| |
|
||||||
|
*
|
||||||
|
* (1) Sometimes the other side does send this start. In this case we run the glare algorithm and send an accept only if
|
||||||
|
* We are the bigger mxid and deviceid (since we discard our start message). <- GLARE RESOLUTION
|
||||||
*/
|
*/
|
||||||
// clang-format on
|
// clang-format on
|
||||||
class DeviceVerificationFlow : public QObject
|
class DeviceVerificationFlow : public QObject
|
||||||
|
|
Loading…
Reference in a new issue