diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 0f3ae7a0f..16ab21dde 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -33,6 +33,10 @@ add_definitions(-DDEV_S3_ENDPOINT="$ENV{DEV_S3_ENDPOINT}") add_definitions(-DFREE_V2_ENDPOINT="$ENV{FREE_V2_ENDPOINT}") add_definitions(-DPREM_V1_ENDPOINT="$ENV{PREM_V1_ENDPOINT}") +if(AMNEZIA_LOCAL_GATEWAY) + add_definitions(-DAMNEZIA_LOCAL_GATEWAY="$ENV{AMNEZIA_LOCAL_GATEWAY}") +endif() + if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID)) set(PACKAGES ${PACKAGES} Widgets) endif() diff --git a/client/core/controllers/gatewayController.cpp b/client/core/controllers/gatewayController.cpp index 5430cd7b6..9bc6e675c 100644 --- a/client/core/controllers/gatewayController.cpp +++ b/client/core/controllers/gatewayController.cpp @@ -50,7 +50,7 @@ namespace constexpr QLatin1String unprocessableSubscriptionMessage("Failed to retrieve subscription information. Is it activated?"); -#if AMNEZIA_GATEWAY_PLAINTEXT_MOCK +#ifdef AMNEZIA_LOCAL_GATEWAY bool gatewayUrlIsPlaintextMockTarget(const QString &gatewayEndpoint, const QString &proxyUrl) { const auto hostOf = [](const QString &urlString) -> QString { @@ -88,7 +88,7 @@ GatewayController::EncryptedRequestData GatewayController::prepareRequest(const encRequestData.request.setRawHeader(QString("X-Client-Request-ID").toUtf8(), QUuid::createUuid().toString(QUuid::WithoutBraces).toUtf8()); encRequestData.request.setUrl(endpoint.arg(m_proxyUrl.isEmpty() ? m_gatewayEndpoint : m_proxyUrl)); -#if AMNEZIA_GATEWAY_PLAINTEXT_MOCK +#ifdef AMNEZIA_LOCAL_GATEWAY if (gatewayUrlIsPlaintextMockTarget(m_gatewayEndpoint, m_proxyUrl)) { encRequestData.requestBody = QJsonDocument(apiPayload).toJson(); encRequestData.key.clear(); @@ -203,7 +203,7 @@ ErrorCode GatewayController::post(const QString &endpoint, const QJsonObject api reply->deleteLater(); -#if AMNEZIA_GATEWAY_PLAINTEXT_MOCK +#ifdef AMNEZIA_LOCAL_GATEWAY const bool plaintextMock = encRequestData.key.isEmpty(); DecryptionResult decryptionResult; decryptionResult.decryptedBody = encryptedResponseBody; @@ -284,7 +284,7 @@ QFuture> GatewayController::postAsync(const QString reply->deleteLater(); -#if AMNEZIA_GATEWAY_PLAINTEXT_MOCK +#ifdef AMNEZIA_LOCAL_GATEWAY const bool plaintextMock = encRequestData.key.isEmpty(); DecryptionResult decryptionResult; decryptionResult.decryptedBody = encryptedResponseBody; diff --git a/client/settings.cpp b/client/settings.cpp index 23f826473..c1d209655 100644 --- a/client/settings.cpp +++ b/client/settings.cpp @@ -14,8 +14,8 @@ namespace const char cloudFlareNs1[] = "1.1.1.1"; const char cloudFlareNs2[] = "1.0.0.1"; -#if AMNEZIA_FORCE_DEV_GATEWAY - constexpr char gatewayEndpoint[] = DEFAULT_GATEWAY_ENDPOINT; +#ifdef AMNEZIA_LOCAL_GATEWAY + constexpr char gatewayEndpoint[] = "http://localhost:8080/"; #else constexpr char gatewayEndpoint[] = "http://gw.amnezia.org:80/"; #endif @@ -48,9 +48,8 @@ Settings::Settings(QObject *parent) : QObject(parent), m_settings(ORGANIZATION_N } m_gatewayEndpoint = gatewayEndpoint; -#if AMNEZIA_FORCE_DEV_GATEWAY +#ifdef AMNEZIA_LOCAL_GATEWAY m_settings.setValue(QStringLiteral("Conf/devGatewayEnv"), true); - m_gatewayEndpoint = QString::fromUtf8(DEV_AGW_ENDPOINT); #endif }