added getting cloud config for cloak
This commit is contained in:
parent
4ae9cddcce
commit
3e03002ead
2 changed files with 30 additions and 4 deletions
|
@ -31,8 +31,8 @@ QString CloudController::genCertificateRequest(ServiceTypeId serviceTypeId)
|
|||
{
|
||||
case ServiceTypeId::AmneziaFreeRuWG: return "";
|
||||
case ServiceTypeId::AmneziaFreeRuCloak: {
|
||||
auto data = OpenVpnConfigurator::createCertRequest();
|
||||
return data.request;
|
||||
m_certRequest = OpenVpnConfigurator::createCertRequest();
|
||||
return m_certRequest.request;
|
||||
}
|
||||
case ServiceTypeId::AmneziaFreeRuAWG: return "";
|
||||
case ServiceTypeId::AmneziaFreeRuReverseWG: return "";
|
||||
|
@ -41,6 +41,23 @@ QString CloudController::genCertificateRequest(ServiceTypeId serviceTypeId)
|
|||
}
|
||||
}
|
||||
|
||||
void CloudController::processCloudConfig(ServiceTypeId serviceTypeId, QString &config)
|
||||
{
|
||||
switch (serviceTypeId)
|
||||
{
|
||||
case ServiceTypeId::AmneziaFreeRuWG: return;
|
||||
case ServiceTypeId::AmneziaFreeRuCloak: {
|
||||
config.replace("<key>", "<key>\n");
|
||||
config.replace("$OPENVPN_PRIV_KEY", m_certRequest.privKey);
|
||||
return;
|
||||
}
|
||||
case ServiceTypeId::AmneziaFreeRuAWG: return;
|
||||
case ServiceTypeId::AmneziaFreeRuReverseWG: return;
|
||||
case ServiceTypeId::AmneziaFreeRuReverseCloak: return;
|
||||
case ServiceTypeId::AmneziaFreeRuReverseAWG: return;
|
||||
}
|
||||
}
|
||||
|
||||
bool CloudController::updateServerConfigFromCloud()
|
||||
{
|
||||
auto serverConfig = m_serversModel->getDefaultServerConfig();
|
||||
|
@ -53,7 +70,7 @@ bool CloudController::updateServerConfigFromCloud()
|
|||
QNetworkRequest request;
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
QString endpoint = serverConfig.value(config_key::apiEdnpoint).toString();
|
||||
request.setUrl(endpoint.replace("https", "http")); //
|
||||
request.setUrl(endpoint.replace("https", "http")); // todo remove
|
||||
|
||||
ServiceTypeId serviceTypeId = static_cast<ServiceTypeId>(serverConfig.value(config_key::serviceTypeId).toInt());
|
||||
|
||||
|
@ -85,7 +102,11 @@ bool CloudController::updateServerConfigFromCloud()
|
|||
ba = ba_uncompressed;
|
||||
}
|
||||
|
||||
QJsonObject cloudConfig = QJsonDocument::fromJson(ba).object();
|
||||
QString configStr = ba;
|
||||
processCloudConfig(serviceTypeId, configStr);
|
||||
|
||||
QJsonObject cloudConfig = QJsonDocument::fromJson(configStr.toUtf8()).object();
|
||||
|
||||
serverConfig.insert("cloudConfig", cloudConfig);
|
||||
serverConfig.insert(config_key::dns1, cloudConfig.value(config_key::dns1));
|
||||
serverConfig.insert(config_key::dns2, cloudConfig.value(config_key::dns2));
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "ui/models/containers_model.h"
|
||||
#include "ui/models/servers_model.h"
|
||||
#include "configurators/openvpn_configurator.h"
|
||||
|
||||
class CloudController : public QObject
|
||||
{
|
||||
|
@ -36,8 +37,12 @@ private:
|
|||
QString genPublicKey(ServiceTypeId serviceTypeId);
|
||||
QString genCertificateRequest(ServiceTypeId serviceTypeId);
|
||||
|
||||
void processCloudConfig(ServiceTypeId serviceTypeId, QString &config);
|
||||
|
||||
QSharedPointer<ServersModel> m_serversModel;
|
||||
QSharedPointer<ContainersModel> m_containersModel;
|
||||
|
||||
OpenVpnConfigurator::ConnectionData m_certRequest;
|
||||
};
|
||||
|
||||
#endif // CLOUDCONTROLLER_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue