refactor: new private MainWindow method localhostFingerprintDb
This commit is contained in:
parent
8d0491f1ad
commit
2f8b78e2a6
2 changed files with 11 additions and 20 deletions
|
|
@ -160,14 +160,13 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
|
||||||
|
|
||||||
// Force generation of SHA256 for the localhost
|
// Force generation of SHA256 for the localhost
|
||||||
if (m_appConfig.tlsEnabled()) {
|
if (m_appConfig.tlsEnabled()) {
|
||||||
auto localPath = QStringLiteral("%1/%2").arg(getTlsPath(), kFingerprintLocalFilename);
|
if (!QFile::exists(localFingerPrintDb())) {
|
||||||
if (!QFile::exists(localPath)) {
|
|
||||||
regenerateLocalFingerprints();
|
regenerateLocalFingerprints();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
deskflow::FingerprintDatabase db;
|
deskflow::FingerprintDatabase db;
|
||||||
db.read(localPath.toStdString());
|
db.read(localFingerPrintDb().toStdString());
|
||||||
if (db.fingerprints().size() != kTlsDbSize) {
|
if (db.fingerprints().size() != kTlsDbSize) {
|
||||||
regenerateLocalFingerprints();
|
regenerateLocalFingerprints();
|
||||||
}
|
}
|
||||||
|
|
@ -486,15 +485,14 @@ void MainWindow::updateSize()
|
||||||
|
|
||||||
void MainWindow::showMyFingerprint()
|
void MainWindow::showMyFingerprint()
|
||||||
{
|
{
|
||||||
auto localPath = QStringLiteral("%1/%2").arg(getTlsPath(), kFingerprintLocalFilename);
|
if (!QFile::exists(localFingerPrintDb())) {
|
||||||
if (!QFile::exists(localPath)) {
|
|
||||||
if (regenerateLocalFingerprints())
|
if (regenerateLocalFingerprints())
|
||||||
showMyFingerprint();
|
showMyFingerprint();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
deskflow::FingerprintDatabase db;
|
deskflow::FingerprintDatabase db;
|
||||||
db.read(localPath.toStdString());
|
db.read(localFingerPrintDb().toStdString());
|
||||||
if (db.fingerprints().size() != kTlsDbSize) {
|
if (db.fingerprints().size() != kTlsDbSize) {
|
||||||
if (regenerateLocalFingerprints())
|
if (regenerateLocalFingerprints())
|
||||||
showMyFingerprint();
|
showMyFingerprint();
|
||||||
|
|
@ -952,20 +950,7 @@ QString MainWindow::getIPAddresses() const
|
||||||
|
|
||||||
void MainWindow::updateLocalFingerprint()
|
void MainWindow::updateLocalFingerprint()
|
||||||
{
|
{
|
||||||
bool fingerprintExists = false;
|
ui->lblMyFingerprint->setVisible(m_appConfig.tlsEnabled() && QFile::exists(localFingerPrintDb()));
|
||||||
try {
|
|
||||||
auto localPath = QStringLiteral("%1/%2").arg(getTlsPath(), kFingerprintLocalFilename);
|
|
||||||
fingerprintExists = QFile::exists(localPath);
|
|
||||||
} catch (const std::exception &e) {
|
|
||||||
qDebug() << e.what();
|
|
||||||
qFatal() << "failed to check if fingerprint exists";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_appConfig.tlsEnabled() && fingerprintExists) {
|
|
||||||
ui->lblMyFingerprint->setVisible(true);
|
|
||||||
} else {
|
|
||||||
ui->lblMyFingerprint->setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::autoAddScreen(const QString name)
|
void MainWindow::autoAddScreen(const QString name)
|
||||||
|
|
@ -1086,6 +1071,11 @@ QString MainWindow::getTlsPath()
|
||||||
return QStringLiteral("%1/%2").arg(coreTool.getProfileDir(), kSslDir);
|
return QStringLiteral("%1/%2").arg(coreTool.getProfileDir(), kSslDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MainWindow::localFingerPrintDb()
|
||||||
|
{
|
||||||
|
return QStringLiteral("%1/%2").arg(getTlsPath(), kFingerprintLocalFilename);
|
||||||
|
}
|
||||||
|
|
||||||
bool MainWindow::regenerateLocalFingerprints()
|
bool MainWindow::regenerateLocalFingerprints()
|
||||||
{
|
{
|
||||||
TlsCertificate tls;
|
TlsCertificate tls;
|
||||||
|
|
|
||||||
|
|
@ -166,6 +166,7 @@ private:
|
||||||
void showAndActivate();
|
void showAndActivate();
|
||||||
|
|
||||||
QString getTlsPath();
|
QString getTlsPath();
|
||||||
|
QString localFingerPrintDb();
|
||||||
|
|
||||||
// Generate prints if they are missing
|
// Generate prints if they are missing
|
||||||
// Returns true if successful
|
// Returns true if successful
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue