refactor: move tlsEnabled to Settings
newkey: security/tlsEnabled <= General/cryptoEnabled remove tlsEnabled from appconfig
This commit is contained in:
parent
4c6195cc5d
commit
2721de220a
11 changed files with 25 additions and 41 deletions
|
|
@ -157,7 +157,7 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
|
|||
updateSize();
|
||||
|
||||
// Force generation of SHA256 for the localhost
|
||||
if (m_appConfig.tlsEnabled()) {
|
||||
if (Settings::value(Settings::Security::TlsEnabled).toBool()) {
|
||||
if (!QFile::exists(localFingerprintDb())) {
|
||||
regenerateLocalFingerprints();
|
||||
return;
|
||||
|
|
@ -591,7 +591,7 @@ void MainWindow::updateSecurityIcon(bool visible)
|
|||
if (!visible)
|
||||
return;
|
||||
|
||||
bool secureSocket = m_appConfig.tlsEnabled();
|
||||
bool secureSocket = Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||
|
||||
const auto txt =
|
||||
secureSocket ? tr("%1 Encryption Enabled").arg(m_coreProcess.secureSocketVersion()) : tr("Encryption Disabled");
|
||||
|
|
@ -1018,7 +1018,8 @@ QString MainWindow::getIPAddresses() const
|
|||
|
||||
void MainWindow::updateLocalFingerprint()
|
||||
{
|
||||
m_btnFingerprint->setVisible(m_appConfig.tlsEnabled() && QFile::exists(localFingerprintDb()));
|
||||
const bool tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||
m_btnFingerprint->setVisible(tlsEnabled && QFile::exists(localFingerprintDb()));
|
||||
}
|
||||
|
||||
void MainWindow::autoAddScreen(const QString name)
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ void SettingsDialog::accept()
|
|||
m_appConfig.setPreventSleep(ui->cbPreventSleep->isChecked());
|
||||
m_appConfig.setTlsCertPath(ui->lineTlsCertPath->text());
|
||||
m_appConfig.setTlsKeyLength(ui->comboTlsKeyLength->currentText().toInt());
|
||||
m_appConfig.setTlsEnabled(ui->groupSecurity->isChecked());
|
||||
Settings::setValue(Settings::Security::TlsEnabled, ui->groupSecurity->isChecked());
|
||||
m_appConfig.setLanguageSync(ui->cbLanguageSync->isChecked());
|
||||
m_appConfig.setInvertScrollDirection(ui->cbScrollDirection->isChecked());
|
||||
m_appConfig.setEnableService(ui->cbServiceEnabled->isChecked());
|
||||
|
|
@ -218,7 +218,7 @@ void SettingsDialog::updateTlsControls()
|
|||
ui->comboTlsKeyLength->setCurrentIndex(ui->comboTlsKeyLength->findText(keyLengthText));
|
||||
}
|
||||
|
||||
const auto tlsEnabled = m_tlsUtility.isEnabled();
|
||||
const auto tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||
const auto writable = m_appConfig.isActiveScopeWritable();
|
||||
const auto enabled = writable && tlsEnabled;
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ QVariant Settings::defaultValue(const QString &key)
|
|||
}
|
||||
|
||||
if ((key == Gui::CloseToTray) || (key == Gui::LogExpanded) || (key == Gui::SymbolicTrayIcon)
|
||||
|| (key == Gui::CloseReminder)) {
|
||||
|| (key == Gui::CloseReminder) || (key == Security::TlsEnabled)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ public:
|
|||
inline static const auto SymbolicTrayIcon = QStringLiteral("gui/symbolicTrayIcon");
|
||||
inline static const auto WindowGeometry = QStringLiteral("gui/windowGeometry");
|
||||
};
|
||||
struct Security
|
||||
{
|
||||
inline static const auto TlsEnabled = QStringLiteral("security/tlsEnabled");
|
||||
};
|
||||
|
||||
static Settings *instance();
|
||||
static void setSettingFile(const QString &settingsFile = QString());
|
||||
|
|
@ -85,6 +89,7 @@ private:
|
|||
, Gui::LogExpanded
|
||||
, Gui::SymbolicTrayIcon
|
||||
, Gui::WindowGeometry
|
||||
, Security::TlsEnabled
|
||||
};
|
||||
// clang-format on
|
||||
};
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ const char *const AppConfig::m_SettingsName[] = {
|
|||
"elevateMode",
|
||||
"elevateModeEnum",
|
||||
"", // 10 = edition, obsolete (using serial key instead)
|
||||
"cryptoEnabled", // 11 = kTlsEnabled (retain legacy string value)
|
||||
"", // 11 = kTlsEnabled (retain legacy string value) Moved to Settings
|
||||
"", // 12 AutoHide, moved to Settings
|
||||
"", // 13 = serialKey, obsolete
|
||||
"lastVersion",
|
||||
|
|
@ -131,7 +131,6 @@ void AppConfig::recallFromCurrentScope()
|
|||
m_LanguageSync = getFromCurrentScope(kLanguageSync, m_LanguageSync).toBool();
|
||||
m_InvertScrollDirection = getFromCurrentScope(kInvertScrollDirection, m_InvertScrollDirection).toBool();
|
||||
m_EnableService = getFromCurrentScope(kEnableService, m_EnableService).toBool();
|
||||
m_TlsEnabled = getFromCurrentScope(kTlsEnabled, m_TlsEnabled).toBool();
|
||||
m_TlsCertPath = getFromCurrentScope(kTlsCertPath, m_TlsCertPath).toString();
|
||||
m_TlsKeyLength = getFromCurrentScope(kTlsKeyLength, m_TlsKeyLength).toInt();
|
||||
m_RequireClientCert = getFromCurrentScope(kRequireClientCert, m_RequireClientCert).toBool();
|
||||
|
|
@ -173,7 +172,6 @@ void AppConfig::commit()
|
|||
setInCurrentScope(kLogFilename, m_LogFilename);
|
||||
setInCurrentScope(kElevateMode, static_cast<int>(m_ElevateMode));
|
||||
setInCurrentScope(kElevateModeLegacy, m_ElevateMode == ElevateMode::kAlways);
|
||||
setInCurrentScope(kTlsEnabled, m_TlsEnabled);
|
||||
setInCurrentScope(kLastVersion, m_LastVersion);
|
||||
setInCurrentScope(kUseExternalConfig, m_UseExternalConfig);
|
||||
setInCurrentScope(kConfigFile, m_ConfigFile);
|
||||
|
|
@ -450,11 +448,6 @@ ElevateMode AppConfig::elevateMode() const
|
|||
return m_ElevateMode;
|
||||
}
|
||||
|
||||
bool AppConfig::tlsEnabled() const
|
||||
{
|
||||
return m_TlsEnabled;
|
||||
}
|
||||
|
||||
bool AppConfig::invertScrollDirection() const
|
||||
{
|
||||
return m_InvertScrollDirection;
|
||||
|
|
@ -528,15 +521,6 @@ const QString &AppConfig::serverHostname() const
|
|||
// Begin setters
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void AppConfig::setTlsEnabled(bool value)
|
||||
{
|
||||
// we purposefully do not set the 'tls changed' flag when enabling/disabling
|
||||
// tls, since that would cause the certificate to regenerate, which could get
|
||||
// pretty annoying.
|
||||
|
||||
m_TlsEnabled = value;
|
||||
}
|
||||
|
||||
void AppConfig::setTlsCertPath(const QString &value)
|
||||
{
|
||||
if (m_TlsCertPath != value) {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ private:
|
|||
kElevateModeLegacy = 8,
|
||||
kElevateMode = 9,
|
||||
// 10 = edition, obsolete (related to obsolete licensing)
|
||||
kTlsEnabled = 11,
|
||||
// 11 = tlsEnagled moved to Settigns
|
||||
// 12 = auto hide, Moved to Settings
|
||||
// 13 = serial key, obsolete
|
||||
kLastVersion = 14,
|
||||
|
|
@ -135,7 +135,6 @@ public:
|
|||
IConfigScopes &scopes() const override;
|
||||
ProcessMode processMode() const override;
|
||||
ElevateMode elevateMode() const override;
|
||||
bool tlsEnabled() const override;
|
||||
QString tlsCertPath() const override;
|
||||
int tlsKeyLength() const override;
|
||||
QString logLevelText() const override;
|
||||
|
|
@ -180,7 +179,6 @@ public:
|
|||
void setLogToFile(bool b) override;
|
||||
void setLogFilename(const QString &s) override;
|
||||
void setElevateMode(ElevateMode em) override;
|
||||
void setTlsEnabled(bool e) override;
|
||||
void setInvertScrollDirection(bool b) override;
|
||||
void setLanguageSync(bool b) override;
|
||||
void setPreventSleep(bool b) override;
|
||||
|
|
@ -282,7 +280,6 @@ private:
|
|||
bool m_LogToFile = false;
|
||||
QString m_LogFilename = logDir() + deskflow::gui::kDefaultLogFile;
|
||||
ElevateMode m_ElevateMode = deskflow::gui::kDefaultElevateMode;
|
||||
bool m_TlsEnabled = true;
|
||||
QString m_LastVersion = "";
|
||||
bool m_InvertScrollDirection = false;
|
||||
bool m_LanguageSync = true;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ public:
|
|||
virtual IConfigScopes &scopes() const = 0;
|
||||
virtual QString tlsCertPath() const = 0;
|
||||
virtual int tlsKeyLength() const = 0;
|
||||
virtual bool tlsEnabled() const = 0;
|
||||
virtual ProcessMode processMode() const = 0;
|
||||
virtual ElevateMode elevateMode() const = 0;
|
||||
virtual QString logLevelText() const = 0;
|
||||
|
|
@ -74,7 +73,6 @@ public:
|
|||
virtual void setPreventSleep(bool preventSleep) = 0;
|
||||
virtual void setTlsCertPath(const QString &tlsCertPath) = 0;
|
||||
virtual void setTlsKeyLength(int tlsKeyLength) = 0;
|
||||
virtual void setTlsEnabled(bool tlsEnabled) = 0;
|
||||
virtual void setLanguageSync(bool languageSync) = 0;
|
||||
virtual void setInvertScrollDirection(bool invertScrollDirection) = 0;
|
||||
virtual void setEnableService(bool enableService) = 0;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "CoreProcess.h"
|
||||
|
||||
#include "common/constants.h"
|
||||
#include "common/Settings.h"
|
||||
#include "gui/config/IAppConfig.h"
|
||||
#include "gui/core/CoreTool.h"
|
||||
#include "gui/ipc/DaemonIpcClient.h"
|
||||
|
|
@ -500,7 +500,7 @@ bool CoreProcess::addGenericArgs(QStringList &args, const ProcessMode processMod
|
|||
|
||||
#endif
|
||||
|
||||
if (m_appConfig.tlsEnabled()) {
|
||||
if (Settings::value(Settings::Security::TlsEnabled).toBool()) {
|
||||
args << "--enable-crypto";
|
||||
}
|
||||
|
||||
|
|
@ -555,7 +555,7 @@ bool CoreProcess::addServerArgs(QStringList &args, QString &app)
|
|||
// bizarrely, the tls cert path arg was being given to the core client.
|
||||
// since it's not clear why (it is only needed for the server), this has now
|
||||
// been moved to server args.
|
||||
if (m_appConfig.tlsEnabled()) {
|
||||
if (Settings::value(Settings::Security::TlsEnabled).toBool()) {
|
||||
TlsUtility tlsUtility(m_appConfig);
|
||||
if (!tlsUtility.persistCertificate()) {
|
||||
qCritical("failed to persist tls certificate");
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "ServerConnection.h"
|
||||
|
||||
#include "ServerMessage.h"
|
||||
#include "common/Settings.h"
|
||||
#include "gui/config/ServerConfigDialogState.h"
|
||||
#include "messages.h"
|
||||
|
||||
|
|
@ -94,8 +95,9 @@ void ServerConnection::handleNewClient(const QString &clientName)
|
|||
Q_EMIT messageShowing();
|
||||
|
||||
m_messageShowing = true;
|
||||
const bool tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||
const auto result =
|
||||
m_pDeps->showNewClientPrompt(m_pParent, clientName, m_appConfig.tlsEnabled() && m_appConfig.requireClientCerts());
|
||||
m_pDeps->showNewClientPrompt(m_pParent, clientName, tlsEnabled && m_appConfig.requireClientCerts());
|
||||
m_messageShowing = false;
|
||||
|
||||
if (result == Add) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "TlsUtility.h"
|
||||
|
||||
#include "TlsCertificate.h"
|
||||
|
||||
#include "common/Settings.h"
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
|
||||
|
|
@ -19,8 +19,7 @@ TlsUtility::TlsUtility(const IAppConfig &appConfig) : m_appConfig(appConfig)
|
|||
|
||||
bool TlsUtility::isEnabled() const
|
||||
{
|
||||
const auto &config = m_appConfig;
|
||||
return config.tlsEnabled();
|
||||
return Settings::value(Settings::Security::TlsEnabled).toBool();
|
||||
}
|
||||
|
||||
bool TlsUtility::generateCertificate()
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ public:
|
|||
MOCK_METHOD(deskflow::gui::IConfigScopes &, scopes, (), (const, override));
|
||||
MOCK_METHOD(QString, tlsCertPath, (), (const, override));
|
||||
MOCK_METHOD(int, tlsKeyLength, (), (const, override));
|
||||
MOCK_METHOD(bool, tlsEnabled, (), (const, override));
|
||||
MOCK_METHOD(ProcessMode, processMode, (), (const, override));
|
||||
MOCK_METHOD(ElevateMode, elevateMode, (), (const, override));
|
||||
MOCK_METHOD(QString, logLevelText, (), (const, override));
|
||||
|
|
@ -75,7 +74,6 @@ public:
|
|||
MOCK_METHOD(void, setPreventSleep, (bool preventSleep), (override));
|
||||
MOCK_METHOD(void, setTlsCertPath, (const QString &tlsCertPath), (override));
|
||||
MOCK_METHOD(void, setTlsKeyLength, (int tlsKeyLength), (override));
|
||||
MOCK_METHOD(void, setTlsEnabled, (bool tlsEnabled), (override));
|
||||
MOCK_METHOD(void, setLanguageSync, (bool languageSync), (override));
|
||||
MOCK_METHOD(void, setInvertScrollDirection, (bool invertScrollDirection), (override));
|
||||
MOCK_METHOD(void, setEnableService, (bool enableService), (override));
|
||||
|
|
|
|||
Loading…
Reference in a new issue