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

This commit is contained in:
sithlord48
2025-02-26 12:06:22 -05:00
committed by Nick Bolton
parent 1003de21b5
commit 4f2ef7174a
2 changed files with 18 additions and 11 deletions

View File

@ -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);
}
}

View File

@ -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;