refactor: MainWindow new localFingerprint method to read the local fingerprint from the db, this is split from showMyFingerprint
This commit is contained in:
committed by
Chris Rizzitello
parent
9eede5470c
commit
2c6c65f71e
@ -525,28 +525,7 @@ void MainWindow::updateSize()
|
||||
|
||||
void MainWindow::showMyFingerprint()
|
||||
{
|
||||
if (!QFile::exists(Settings::tlsLocalDb())) {
|
||||
if (regenerateLocalFingerprints())
|
||||
showMyFingerprint();
|
||||
return;
|
||||
}
|
||||
|
||||
FingerprintDatabase db;
|
||||
db.read(Settings::tlsLocalDb());
|
||||
if (db.fingerprints().isEmpty()) {
|
||||
if (regenerateLocalFingerprints())
|
||||
showMyFingerprint();
|
||||
return;
|
||||
}
|
||||
|
||||
Fingerprint sha256Print;
|
||||
for (const auto &f : std::as_const(db.fingerprints())) {
|
||||
if (f.type == Fingerprint::Type::SHA256) {
|
||||
sha256Print = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Fingerprint sha256Print = localFingerprint();
|
||||
FingerprintDialog fingerprintDialog(this, sha256Print);
|
||||
fingerprintDialog.exec();
|
||||
}
|
||||
@ -1208,6 +1187,30 @@ bool MainWindow::regenerateLocalFingerprints()
|
||||
return true;
|
||||
}
|
||||
|
||||
Fingerprint MainWindow::localFingerprint()
|
||||
{
|
||||
if (!QFile::exists(Settings::tlsLocalDb())) {
|
||||
if (regenerateLocalFingerprints())
|
||||
return localFingerprint();
|
||||
}
|
||||
|
||||
FingerprintDatabase db;
|
||||
db.read(Settings::tlsLocalDb());
|
||||
if (db.fingerprints().isEmpty()) {
|
||||
if (regenerateLocalFingerprints())
|
||||
return localFingerprint();
|
||||
}
|
||||
|
||||
Fingerprint sha256Print;
|
||||
for (const auto &f : std::as_const(db.fingerprints())) {
|
||||
if (f.type == Fingerprint::Type::SHA256) {
|
||||
sha256Print = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sha256Print;
|
||||
}
|
||||
|
||||
void MainWindow::serverClientsChanged(const QStringList &clients)
|
||||
{
|
||||
if (m_coreProcess.mode() != CoreMode::Server || !m_coreProcess.isStarted())
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include "gui/core/ServerConnection.h"
|
||||
#include "gui/core/WaylandWarnings.h"
|
||||
#include "gui/tls/TlsUtility.h"
|
||||
#include "net/Fingerprint.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "gui/OSXHelpers.h"
|
||||
@ -159,6 +160,8 @@ private:
|
||||
// Returns true if successful
|
||||
bool regenerateLocalFingerprints();
|
||||
|
||||
Fingerprint localFingerprint();
|
||||
|
||||
void serverClientsChanged(const QStringList &clients);
|
||||
|
||||
inline static const auto m_guiSocketName = QStringLiteral("deskflow-gui");
|
||||
|
||||
Reference in New Issue
Block a user