refactoring: improved the performance of secure_settings
This commit is contained in:
parent
956dd6e37a
commit
4869429eb6
2 changed files with 8 additions and 6 deletions
|
@ -15,6 +15,12 @@
|
||||||
|
|
||||||
using namespace QKeychain;
|
using namespace QKeychain;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr const char *settingsKeyTag = "settingsKeyTag";
|
||||||
|
constexpr const char *settingsIvTag = "settingsIvTag";
|
||||||
|
constexpr const char *keyChainName = "AmneziaVPN-Keychain";
|
||||||
|
}
|
||||||
|
|
||||||
SecureQSettings::SecureQSettings(const QString &organization, const QString &application, QObject *parent)
|
SecureQSettings::SecureQSettings(const QString &organization, const QString &application, QObject *parent)
|
||||||
: QObject { parent }, m_settings(organization, application, parent), encryptedKeys({ "Servers/serversList" })
|
: QObject { parent }, m_settings(organization, application, parent), encryptedKeys({ "Servers/serversList" })
|
||||||
{
|
{
|
||||||
|
@ -49,7 +55,7 @@ QVariant SecureQSettings::value(const QString &key, const QVariant &defaultValue
|
||||||
// check if value is not encrypted, v. < 2.0.x
|
// check if value is not encrypted, v. < 2.0.x
|
||||||
retVal = m_settings.value(key);
|
retVal = m_settings.value(key);
|
||||||
if (retVal.isValid()) {
|
if (retVal.isValid()) {
|
||||||
if (retVal.userType() == QVariant::ByteArray && retVal.toByteArray().mid(0, magicString.size()) == magicString) {
|
if (retVal.userType() == QMetaType::QByteArray && retVal.toByteArray().mid(0, magicString.size()) == magicString) {
|
||||||
|
|
||||||
if (getEncKey().isEmpty() || getEncIv().isEmpty()) {
|
if (getEncKey().isEmpty() || getEncIv().isEmpty()) {
|
||||||
qCritical() << "SecureQSettings::setValue Decryption requested, but key is empty";
|
qCritical() << "SecureQSettings::setValue Decryption requested, but key is empty";
|
||||||
|
|
|
@ -8,10 +8,6 @@
|
||||||
|
|
||||||
#include "keychain.h"
|
#include "keychain.h"
|
||||||
|
|
||||||
constexpr const char *settingsKeyTag = "settingsKeyTag";
|
|
||||||
constexpr const char *settingsIvTag = "settingsIvTag";
|
|
||||||
constexpr const char *keyChainName = "AmneziaVPN-Keychain";
|
|
||||||
|
|
||||||
class SecureQSettings : public QObject
|
class SecureQSettings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -44,7 +40,7 @@ public:
|
||||||
private:
|
private:
|
||||||
QSettings m_settings;
|
QSettings m_settings;
|
||||||
|
|
||||||
mutable QMap<QString, QVariant> m_cache;
|
mutable QHash<QString, QVariant> m_cache;
|
||||||
|
|
||||||
QStringList encryptedKeys; // encode only key listed here
|
QStringList encryptedKeys; // encode only key listed here
|
||||||
// only this fields need for backup
|
// only this fields need for backup
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue