From 7cc8aad8764b618292569ccda063981cdfed0b01 Mon Sep 17 00:00:00 2001 From: Mykola Baibuz Date: Thu, 24 Apr 2025 18:31:26 +0300 Subject: [PATCH] buildfix and naming --- client/core/controllers/gatewayController.cpp | 13 ++++++++----- client/protocols/openvpnprotocol.cpp | 2 +- ipc/ipc_interface.rep | 4 ++-- ipc/ipcserver.cpp | 4 ++-- ipc/ipcserver.h | 4 ++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/client/core/controllers/gatewayController.cpp b/client/core/controllers/gatewayController.cpp index 23fa4933..0d86b9d5 100644 --- a/client/core/controllers/gatewayController.cpp +++ b/client/core/controllers/gatewayController.cpp @@ -15,9 +15,12 @@ #include "amnezia_application.h" #include "core/api/apiUtils.h" #include "utilities.h" -#include "core/ipcclient.h" #include "core/networkUtilities.h" +#ifdef AMNEZIA_DESKTOP + #include "core/ipcclient.h" +#endif + namespace { namespace configKey @@ -54,12 +57,12 @@ ErrorCode GatewayController::get(const QString &endpoint, QByteArray &responseBo request.setUrl(QString(endpoint).arg(m_gatewayEndpoint)); // bypass killSwitch exceptions for API-gateway -#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) || defined(Q_OS_WIN) +#ifdef AMNEZIA_DESKTOP { QString host = QUrl(request.url()).host(); QString ip = NetworkUtilities::getIPAddress(host); if (!ip.isEmpty()) { - IpcClient::Interface()->addKillSwitchExceptions(QStringList{ip}); + IpcClient::Interface()->addKillSwitchAllowedRange(QStringList{ip}); } } #endif @@ -116,12 +119,12 @@ ErrorCode GatewayController::post(const QString &endpoint, const QJsonObject api request.setUrl(endpoint.arg(m_gatewayEndpoint)); // bypass killSwitch exceptions for API-gateway -#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) || defined(Q_OS_WIN) +#ifdef AMNEZIA_DESKTOP { QString host = QUrl(request.url()).host(); QString ip = NetworkUtilities::getIPAddress(host); if (!ip.isEmpty()) { - IpcClient::Interface()->addKillSwitchExceptions(QStringList{ip}); + IpcClient::Interface()->addKillSwitchAllowedRange(QStringList{ip}); } } #endif diff --git a/client/protocols/openvpnprotocol.cpp b/client/protocols/openvpnprotocol.cpp index 5ede4c42..0c8f5907 100644 --- a/client/protocols/openvpnprotocol.cpp +++ b/client/protocols/openvpnprotocol.cpp @@ -172,7 +172,7 @@ ErrorCode OpenVpnProtocol::start() } #if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) - IpcClient::Interface()->addKillSwitchExceptions(QStringList(NetworkUtilities::getIPAddress( + IpcClient::Interface()->addKillSwitchAllowedRange(QStringList(NetworkUtilities::getIPAddress( m_configData.value(amnezia::config_key::hostName).toString()))); #endif diff --git a/ipc/ipc_interface.rep b/ipc/ipc_interface.rep index 489f860f..4ecae9bc 100644 --- a/ipc/ipc_interface.rep +++ b/ipc/ipc_interface.rep @@ -31,8 +31,8 @@ class IpcInterface SLOT( bool disableKillSwitch() ); SLOT( bool disableAllTraffic() ); SLOT( bool refreshKillSwitch( bool enabled ) ); - SLOT( bool allowTrafficTo( const QStringList ranges ) ); - SLOT( bool addKillSwitchExceptions( const QStringList ranges ) ); + SLOT( bool addKillSwitchAllowedRange( const QStringList ranges ) ); + SLOT( bool resetKillSwitchAllowedRange( const QStringList ranges ) ); SLOT( bool enablePeerTraffic( const QJsonObject &configStr) ); SLOT( bool enableKillSwitch( const QJsonObject &excludeAddr, int vpnAdapterIndex) ); SLOT( bool updateResolvers(const QString& ifname, const QList& resolvers) ); diff --git a/ipc/ipcserver.cpp b/ipc/ipcserver.cpp index f8a25eb6..0c7f5295 100644 --- a/ipc/ipcserver.cpp +++ b/ipc/ipcserver.cpp @@ -179,12 +179,12 @@ void IpcServer::setLogsEnabled(bool enabled) } } -bool IpcServer::allowTrafficTo(QStringList ranges) +bool IpcServer::resetKillSwitchAllowedRange(QStringList ranges) { return KillSwitch::instance()->resetAllowedRange(ranges); } -bool IpcServer::addKillSwitchExceptions(QStringList ranges) +bool IpcServer::addKillSwitchAllowedRange(QStringList ranges) { return KillSwitch::instance()->addAllowedRange(ranges); } diff --git a/ipc/ipcserver.h b/ipc/ipcserver.h index bbd11830..00d36354 100644 --- a/ipc/ipcserver.h +++ b/ipc/ipcserver.h @@ -35,13 +35,13 @@ public: virtual void StartRoutingIpv6() override; virtual void StopRoutingIpv6() override; virtual bool disableAllTraffic() override; - virtual bool allowTrafficTo(QStringList ranges) override; + virtual bool addKillSwitchAllowedRange(QStringList ranges) override; + virtual bool resetKillSwitchAllowedRange(QStringList ranges) override; virtual bool enablePeerTraffic(const QJsonObject &configStr) override; virtual bool enableKillSwitch(const QJsonObject &excludeAddr, int vpnAdapterIndex) override; virtual bool disableKillSwitch() override; virtual bool refreshKillSwitch( bool enabled ) override; virtual bool updateResolvers(const QString& ifname, const QList& resolvers) override; - virtual bool addKillSwitchExceptions(QStringList ranges) override; private: int m_localpid = 0;