From 4f2ef7174a45862df11e5188ef83d3276006e953 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Wed, 26 Feb 2025 12:06:22 -0500 Subject: [PATCH] refactor: do not stop sever on new client fingerprint, track the last print we checked and if we are chekcing it do not show a new box --- src/apps/deskflow-gui/MainWindow.cpp | 21 ++++++++++++++------- src/apps/deskflow-gui/MainWindow.h | 8 ++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/apps/deskflow-gui/MainWindow.cpp b/src/apps/deskflow-gui/MainWindow.cpp index 96fd7dd8d..25c969fa1 100644 --- a/src/apps/deskflow-gui/MainWindow.cpp +++ b/src/apps/deskflow-gui/MainWindow.cpp @@ -790,19 +790,26 @@ void MainWindow::checkFingerprint(const QString &line) deskflow::string::fromHex(match.captured(1).toStdString()) }; + const auto sha256Text = match.captured(2); + const deskflow::FingerprintData sha256 = { deskflow::fingerprintTypeToString(deskflow::FingerprintType::SHA256), - deskflow::string::fromHex(match.captured(2).toStdString()) + deskflow::string::fromHex(sha256Text.toStdString()) }; - // Only Save the sha256 - deskflow::FingerprintDatabase db; - db.read(trustedFingerprintDb().toStdString()); - if (db.isTrusted(sha256)) { + if (m_checkedPeers.contains(sha256Text)) { + qDebug("ignoring fingerprint, already handled"); return; } + m_checkedPeers.append(sha256Text); - m_coreProcess.stop(); + deskflow::FingerprintDatabase db; + db.read(trustedFingerprintDb().toStdString()); + + if (db.isTrusted(sha256)) { + qDebug("fingerprint is trusted"); + return; + } const bool isClient = m_coreProcess.mode() == CoreMode::Client; auto dialogMode = isClient ? FingerprintDialogMode::Client : FingerprintDialogMode::Server; @@ -813,7 +820,7 @@ void MainWindow::checkFingerprint(const QString &line) if (fingerprintDialog.exec() == QDialog::Accepted) { db.addTrusted(sha256); db.write(trustedFingerprintDb().toStdString()); - m_coreProcess.start(); + m_checkedPeers.removeAll(sha256Text); } } diff --git a/src/apps/deskflow-gui/MainWindow.h b/src/apps/deskflow-gui/MainWindow.h index 4de4ef55d..8aa4d36bc 100644 --- a/src/apps/deskflow-gui/MainWindow.h +++ b/src/apps/deskflow-gui/MainWindow.h @@ -188,12 +188,14 @@ private: // Returns true if successful bool regenerateLocalFingerprints(); + inline static const auto m_guiSocketName = QStringLiteral("deskflow-gui"); + inline static const auto m_nameRegEx = QRegularExpression(QStringLiteral("^[\\w\\-_\\.]{0,255}$")); + VersionChecker m_versionChecker; bool m_secureSocket = false; deskflow::gui::config::ServerConfigDialogState m_serverConfigDialogState; bool m_saveOnExit = true; deskflow::gui::core::WaylandWarnings m_waylandWarnings; - deskflow::gui::ConfigScopes &m_configScopes; AppConfig &m_appConfig; ServerConfig m_serverConfig; @@ -202,11 +204,9 @@ private: deskflow::gui::ClientConnection m_clientConnection; deskflow::gui::TlsUtility m_tlsUtility; QSize m_expandedSize = QSize(); - + QStringList m_checkedPeers; QSystemTrayIcon *m_trayIcon = nullptr; QLocalServer *m_guiDupeChecker = nullptr; - inline static const auto m_guiSocketName = QStringLiteral("deskflow-gui"); - inline static const auto m_nameRegEx = QRegularExpression(QStringLiteral("^[\\w\\-_\\.]{0,255}$")); QLabel *m_lblSecurityStatus = nullptr; QLabel *m_lblStatus = nullptr;