mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-05-08 14:33:23 +00:00
Compare commits
2 Commits
4.8.15.0
...
fix/backup
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
211850c236 | ||
|
|
a2e0128c98 |
@@ -3,22 +3,34 @@
|
||||
#include "../client/3rd/QSimpleCrypto/src/include/QAead.h"
|
||||
#include "../client/3rd/QSimpleCrypto/src/include/QBlockCipher.h"
|
||||
#include "utilities.h"
|
||||
#include "core/api/apiDefs.h"
|
||||
#include "protocols/protocols_defs.h"
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
#include <QEventLoop>
|
||||
#include <QIODevice>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QRandomGenerator>
|
||||
#include <QSharedPointer>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace QKeychain;
|
||||
using namespace amnezia;
|
||||
using namespace apiDefs;
|
||||
|
||||
namespace {
|
||||
constexpr const char *settingsKeyTag = "settingsKeyTag";
|
||||
constexpr const char *settingsIvTag = "settingsIvTag";
|
||||
constexpr const char *keyChainName = "AmneziaVPN-Keychain";
|
||||
|
||||
namespace configKey {
|
||||
constexpr char apiConfig[] = "api_config";
|
||||
constexpr char userCountryCode[] = "user_country_code";
|
||||
constexpr char serviceType[] = "service_type";
|
||||
constexpr char serviceProtocol[] = "service_protocol";
|
||||
}
|
||||
}
|
||||
|
||||
SecureQSettings::SecureQSettings(const QString &organization, const QString &application, QObject *parent)
|
||||
@@ -153,6 +165,40 @@ QByteArray SecureQSettings::backupAppConfig() const
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key == QLatin1String("Servers/serversList")) {
|
||||
QJsonArray serversArray = QJsonDocument::fromJson(value(key).toByteArray()).array();
|
||||
QJsonArray sanitizedServersArray;
|
||||
|
||||
for (const QJsonValue &serverValue : serversArray) {
|
||||
QJsonObject serverObject = serverValue.toObject();
|
||||
|
||||
if (serverObject.contains(QLatin1String("api_config"))) {
|
||||
QJsonObject apiConfig = serverObject.value(configKey::apiConfig).toObject();
|
||||
|
||||
serverObject.remove(config_key::dns1);
|
||||
serverObject.remove(config_key::dns2);
|
||||
serverObject.remove(config_key::hostName);
|
||||
serverObject.remove(config_key::containers);
|
||||
|
||||
const QSet<QString> allowedKeys = { QLatin1String(configKey::userCountryCode),
|
||||
QLatin1String(configKey::serviceType),
|
||||
QLatin1String(configKey::serviceProtocol) };
|
||||
|
||||
for (const QString &key : apiConfig.keys())
|
||||
if (!allowedKeys.contains(key))
|
||||
apiConfig.remove(key);
|
||||
|
||||
serverObject.insert(QLatin1String(configKey::apiConfig), apiConfig);
|
||||
}
|
||||
|
||||
sanitizedServersArray.append(serverObject);
|
||||
}
|
||||
|
||||
const QByteArray sanitizedJson = QJsonDocument(sanitizedServersArray).toJson(QJsonDocument::Compact);
|
||||
cfg.insert(key, QJsonValue::fromVariant(sanitizedJson));
|
||||
continue;
|
||||
}
|
||||
|
||||
cfg.insert(key, QJsonValue::fromVariant(value(key)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user