Files
DefaultVPN/client/secure_qsettings.h

59 lines
1.6 KiB
C
Raw Permalink Normal View History

2022-08-05 14:31:12 +03:00
#ifndef SECUREQSETTINGS_H
#define SECUREQSETTINGS_H
2022-08-26 00:35:03 +03:00
#include <QMutex>
#include <QMutexLocker>
#include <QObject>
#include <QSettings>
2022-08-26 00:35:03 +03:00
feature: fillswitch strict mode (#1333) * Add allowed DNS list for killswitch * Windows killswitch strict mode backend part * Killswitch strict mode for Linux and MacOS * Windows fixes * feature: Add Kill Switch settings page with strict mode option * fix windows build after merge * Refresh killswitch mode when it toggled * Use HLM to store strictMode flag * Some Linux updates * feat: Enhance VerticalRadioButton with improved styling and disabled states * Refresh killSwitch state update * Fix build * refactor: Modularize header components * Change kill switch radio button styling * Fix strict kill switch mode handling * Refactor: Replace HeaderType with new Types for headers in QML pages * Remove deprecated HeaderType QML component * Refresh strict mode killswitch after global toggle change * Implement model, controller and UI for killswitch dns exceptions * Connect backend part and UI * Change label text to DNS exceptions * Remove HeaderType from PageSettingsApiDevices * Some pretty fixes * Fix problem with definition sequence of PageSettingsKillSwitchExceptions.pml elements * Add exclusion method for Windows firewall * Change ubuntu version in deploy script * Update ubuntu version in GH actions * Add confirmation popup for strict killswitch mode * Add qt standard path for build script * Add method to killswitch for expanding strickt mode exceptions list and fix allowTrafficTo() for Windows. Also Added cache in KillSwitch class for exceptions * Add insertion of gateway address to strict killswitch exceptions * Review fixes * buildfix and naming --------- Co-authored-by: aiamnezia <ai@amnezia.org>
2025-05-02 23:54:36 -07:00
#include "../client/3rd/qtkeychain/qtkeychain/keychain.h"
2022-08-27 17:35:43 +03:00
2022-08-05 14:31:12 +03:00
class SecureQSettings : public QObject
{
Q_OBJECT
2022-08-05 14:31:12 +03:00
public:
explicit SecureQSettings(const QString &organization, const QString &application = QString(),
QObject *parent = nullptr);
2022-08-05 14:31:12 +03:00
QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
void setValue(const QString &key, const QVariant &value);
2022-08-05 18:59:47 +03:00
void remove(const QString &key);
QByteArray backupAppConfig() const;
2022-08-27 17:35:43 +03:00
bool restoreAppConfig(const QByteArray &json);
2022-08-05 14:31:12 +03:00
void clearSettings();
private:
2022-08-06 19:47:29 +03:00
QByteArray encryptText(const QByteArray &value) const;
QByteArray decryptText(const QByteArray &ba) const;
2022-08-06 19:47:29 +03:00
bool encryptionRequired() const;
2022-08-24 07:38:13 -07:00
QByteArray getEncKey() const;
QByteArray getEncIv() const;
2022-08-27 17:35:43 +03:00
static QByteArray getSecTag(const QString &tag);
static void setSecTag(const QString &tag, const QByteArray &data);
2022-08-23 22:47:23 +03:00
QSettings m_settings;
2022-08-05 18:59:47 +03:00
mutable QHash<QString, QVariant> m_cache;
2022-08-05 18:59:47 +03:00
QStringList encryptedKeys; // encode only key listed here
2024-05-09 00:06:23 +03:00
// only this fields need for backup
QStringList m_fieldsToBackup = {
"Conf/", "Servers/",
};
2022-08-06 19:47:29 +03:00
2022-08-24 07:38:13 -07:00
mutable QByteArray m_key;
mutable QByteArray m_iv;
2022-08-23 22:47:23 +03:00
const QByteArray magicString { "EncData" }; // Magic keyword used for mark encrypted QByteArray
mutable QRecursiveMutex m_mutex;
2022-08-05 14:31:12 +03:00
};
#endif // SECUREQSETTINGS_H