mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 211850c236 | |||
| a2e0128c98 |
@@ -3,22 +3,34 @@
|
|||||||
#include "../client/3rd/QSimpleCrypto/src/include/QAead.h"
|
#include "../client/3rd/QSimpleCrypto/src/include/QAead.h"
|
||||||
#include "../client/3rd/QSimpleCrypto/src/include/QBlockCipher.h"
|
#include "../client/3rd/QSimpleCrypto/src/include/QBlockCipher.h"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
|
#include "core/api/apiDefs.h"
|
||||||
|
#include "protocols/protocols_defs.h"
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QJsonArray>
|
||||||
#include <QRandomGenerator>
|
#include <QRandomGenerator>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
using namespace QKeychain;
|
using namespace QKeychain;
|
||||||
|
using namespace amnezia;
|
||||||
|
using namespace apiDefs;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr const char *settingsKeyTag = "settingsKeyTag";
|
constexpr const char *settingsKeyTag = "settingsKeyTag";
|
||||||
constexpr const char *settingsIvTag = "settingsIvTag";
|
constexpr const char *settingsIvTag = "settingsIvTag";
|
||||||
constexpr const char *keyChainName = "AmneziaVPN-Keychain";
|
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)
|
SecureQSettings::SecureQSettings(const QString &organization, const QString &application, QObject *parent)
|
||||||
@@ -153,6 +165,40 @@ QByteArray SecureQSettings::backupAppConfig() const
|
|||||||
continue;
|
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)));
|
cfg.insert(key, QJsonValue::fromVariant(value(key)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user