Android manifest fix, IPC refactoring
This commit is contained in:
parent
c233f767f4
commit
912051637a
11 changed files with 58 additions and 31 deletions
|
@ -84,8 +84,9 @@
|
|||
<action android:name="android.net.VpnService"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service android:name="org.mozilla.firefox.vpn.qt.VPNPermissionHelper"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||
|
||||
<service android:name="org.amnezia.vpn.qt.VPNPermissionHelper"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||
</service>
|
||||
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
||||
</application>
|
||||
|
|
|
@ -31,9 +31,7 @@ HEADERS += \
|
|||
containers/containers_defs.h \
|
||||
core/defs.h \
|
||||
core/errorstrings.h \
|
||||
core/ipcclient.h \
|
||||
configurators/openvpn_configurator.h \
|
||||
core/privileged_process.h \
|
||||
core/scripts_registry.h \
|
||||
core/server_defs.h \
|
||||
core/servercontroller.h \
|
||||
|
@ -88,9 +86,7 @@ SOURCES += \
|
|||
configurators/wireguard_configurator.cpp \
|
||||
containers/containers_defs.cpp \
|
||||
core/errorstrings.cpp \
|
||||
core/ipcclient.cpp \
|
||||
configurators/openvpn_configurator.cpp \
|
||||
core/privileged_process.cpp \
|
||||
core/scripts_registry.cpp \
|
||||
core/server_defs.cpp \
|
||||
core/servercontroller.cpp \
|
||||
|
@ -203,6 +199,8 @@ win32|macx|linux:!android {
|
|||
DEFINES += AMNEZIA_DESKTOP
|
||||
|
||||
HEADERS += \
|
||||
core/ipcclient.h \
|
||||
core/privileged_process.h \
|
||||
ui/systemtray_notificationhandler.h \
|
||||
protocols/openvpnprotocol.h \
|
||||
protocols/openvpnovercloakprotocol.h \
|
||||
|
@ -210,11 +208,16 @@ win32|macx|linux:!android {
|
|||
protocols/wireguardprotocol.h \
|
||||
|
||||
SOURCES += \
|
||||
core/ipcclient.cpp \
|
||||
core/privileged_process.cpp \
|
||||
ui/systemtray_notificationhandler.cpp \
|
||||
protocols/openvpnprotocol.cpp \
|
||||
protocols/openvpnovercloakprotocol.cpp \
|
||||
protocols/shadowsocksvpnprotocol.cpp \
|
||||
protocols/wireguardprotocol.cpp \
|
||||
|
||||
REPC_REPLICA += ../ipc/ipc_interface.rep
|
||||
REPC_REPLICA += ../ipc/ipc_process_interface.rep
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -365,6 +368,4 @@ ios {
|
|||
}
|
||||
|
||||
|
||||
REPC_REPLICA += ../ipc/ipc_interface.rep
|
||||
!ios: REPC_REPLICA += ../ipc/ipc_process_interface.rep
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ bool IpcClient::init(IpcClient *instance)
|
|||
|
||||
QSharedPointer<PrivilegedProcess> IpcClient::CreatePrivilegedProcess()
|
||||
{
|
||||
#ifndef Q_OS_IOS
|
||||
if (! Instance()->m_ipcClient || ! Instance()->m_ipcClient->isReplicaValid()) {
|
||||
qWarning() << "IpcClient::createPrivilegedProcess : IpcClient IpcClient replica is not valid";
|
||||
return nullptr;
|
||||
|
@ -107,9 +106,6 @@ QSharedPointer<PrivilegedProcess> IpcClient::CreatePrivilegedProcess()
|
|||
|
||||
auto proccessReplica = QSharedPointer<PrivilegedProcess>(pd->ipcProcess);
|
||||
return proccessReplica;
|
||||
#else
|
||||
return QSharedPointer<PrivilegedProcess>();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "privileged_process.h"
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
PrivilegedProcess::PrivilegedProcess() :
|
||||
IpcProcessInterfaceReplica()
|
||||
{
|
||||
|
@ -26,4 +25,3 @@ void PrivilegedProcess::waitForFinished(int msecs)
|
|||
|
||||
loop->exec();
|
||||
}
|
||||
#endif // Q_OS_IOS
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
#include "rep_ipc_process_interface_replica.h"
|
||||
// This class is dangerous - instance of this class casted from base class,
|
||||
// so it support only functions
|
||||
|
@ -20,11 +19,6 @@ public:
|
|||
|
||||
};
|
||||
|
||||
#else // defined Q_OS_IOS
|
||||
class IpcProcessInterfaceReplica {};
|
||||
class PrivilegedProcess {};
|
||||
#endif // Q_OS_IOS
|
||||
|
||||
#endif // PRIVILEGED_PROCESS_H
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
|
@ -6,12 +7,14 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include <core/ipcclient.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "defines.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
#include <core/ipcclient.h>
|
||||
#endif
|
||||
|
||||
QFile Debug::m_file;
|
||||
QTextStream Debug::m_textStream;
|
||||
QString Debug::m_logFileName = QString("%1.log").arg(APPLICATION_NAME);
|
||||
|
@ -140,6 +143,7 @@ void Debug::clearLogs()
|
|||
|
||||
void Debug::clearServiceLogs()
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
IpcClient *m_IpcClient = new IpcClient;
|
||||
|
||||
if (!m_IpcClient->isSocketConnected()) {
|
||||
|
@ -156,6 +160,7 @@ void Debug::clearServiceLogs()
|
|||
else {
|
||||
qWarning() << "Error occured cleaning up service logs";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Debug::cleanUp()
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "core/errorstrings.h"
|
||||
#include <core/servercontroller.h>
|
||||
#include <QTimer>
|
||||
|
||||
ServerSettingsLogic::ServerSettingsLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#include <QApplication>
|
||||
|
||||
#include "VpnLogic.h"
|
||||
|
||||
#include "core/errorstrings.h"
|
||||
#include "vpnconnection.h"
|
||||
#include <QTimer>
|
||||
#include <functional>
|
||||
#include "../uilogic.h"
|
||||
#include "defines.h"
|
||||
|
@ -239,6 +242,6 @@ void VpnLogic::onConnectWorker(int serverIndex, const ServerCredentials &credent
|
|||
|
||||
void VpnLogic::onDisconnect()
|
||||
{
|
||||
set_pushButtonConnectChecked(false);
|
||||
onConnectionStateChanged(VpnProtocol::Disconnected);
|
||||
emit disconnectFromVpn();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "core/errorstrings.h"
|
||||
|
||||
#include "containers/containers_defs.h"
|
||||
#include "protocols/shadowsocksvpnprotocol.h"
|
||||
|
||||
#include "ui/qautostart.h"
|
||||
|
||||
|
@ -136,6 +135,11 @@ UiLogic::~UiLogic()
|
|||
void UiLogic::initalizeUiLogic()
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
connect(AndroidController::instance(), &AndroidController::initialized, [this](bool status, bool connected, const QDateTime& connectionDate) {
|
||||
if (connected) {
|
||||
vpnLogic()->onConnectionStateChanged(VpnProtocol::Connected);
|
||||
}
|
||||
});
|
||||
if (!AndroidController::instance()->initialize()) {
|
||||
qDebug() << QString("Init failed") ;
|
||||
emit VpnProtocol::Error;
|
||||
|
|
|
@ -10,7 +10,12 @@
|
|||
#include <configurators/wireguard_configurator.h>
|
||||
#include <configurators/vpn_configurator.h>
|
||||
#include <core/servercontroller.h>
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
#include "ipc.h"
|
||||
#include "core/ipcclient.h"
|
||||
#include <protocols/wireguardprotocol.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "android_controller.h"
|
||||
|
@ -21,9 +26,6 @@
|
|||
#include <protocols/ios_vpnprotocol.h>
|
||||
#endif
|
||||
|
||||
#include "ipc.h"
|
||||
#include "core/ipcclient.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "vpnconnection.h"
|
||||
|
||||
|
@ -46,6 +48,7 @@ void VpnConnection::onBytesChanged(quint64 receivedBytes, quint64 sentBytes)
|
|||
|
||||
void VpnConnection::onConnectionStateChanged(VpnProtocol::VpnConnectionState state)
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (IpcClient::Interface()) {
|
||||
if (state == VpnProtocol::Connected){
|
||||
IpcClient::Interface()->resetIpStack();
|
||||
|
@ -85,7 +88,7 @@ void VpnConnection::onConnectionStateChanged(VpnProtocol::VpnConnectionState sta
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
emit connectionStateChanged(state);
|
||||
}
|
||||
|
||||
|
@ -96,6 +99,7 @@ const QString &VpnConnection::remoteAddress() const
|
|||
|
||||
void VpnConnection::addSitesRoutes(const QString &gw, Settings::RouteMode mode)
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
QStringList ips;
|
||||
QStringList sites;
|
||||
const QVariantMap &m = m_settings.vpnSites(mode);
|
||||
|
@ -135,6 +139,7 @@ void VpnConnection::addSitesRoutes(const QString &gw, Settings::RouteMode mode)
|
|||
};
|
||||
QHostInfo::lookupHost(site, this, cbResolv);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QSharedPointer<VpnProtocol> VpnConnection::vpnProtocol() const
|
||||
|
@ -144,6 +149,7 @@ QSharedPointer<VpnProtocol> VpnConnection::vpnProtocol() const
|
|||
|
||||
void VpnConnection::addRoutes(const QStringList &ips)
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (connectionState() == VpnProtocol::Connected && IpcClient::Interface()) {
|
||||
if (m_settings.routeMode() == Settings::VpnOnlyForwardSites) {
|
||||
IpcClient::Interface()->routeAddList(m_vpnProtocol->vpnGateway(), ips);
|
||||
|
@ -152,10 +158,12 @@ void VpnConnection::addRoutes(const QStringList &ips)
|
|||
IpcClient::Interface()->routeAddList(m_vpnProtocol->routeGateway(), ips);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void VpnConnection::deleteRoutes(const QStringList &ips)
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (connectionState() == VpnProtocol::Connected && IpcClient::Interface()) {
|
||||
if (m_settings.routeMode() == Settings::VpnOnlyForwardSites) {
|
||||
IpcClient::Interface()->routeDeleteList(vpnProtocol()->vpnGateway(), ips);
|
||||
|
@ -164,11 +172,14 @@ void VpnConnection::deleteRoutes(const QStringList &ips)
|
|||
IpcClient::Interface()->routeDeleteList(m_vpnProtocol->routeGateway(), ips);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void VpnConnection::flushDns()
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (IpcClient::Interface()) IpcClient::Interface()->flushDns();
|
||||
#endif
|
||||
}
|
||||
|
||||
ErrorCode VpnConnection::lastError() const
|
||||
|
@ -349,6 +360,7 @@ void VpnConnection::disconnectFromVpn()
|
|||
{
|
||||
// qDebug() << "Disconnect from VPN 1";
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (IpcClient::Interface()) {
|
||||
IpcClient::Interface()->flushDns();
|
||||
|
||||
|
@ -356,8 +368,15 @@ void VpnConnection::disconnectFromVpn()
|
|||
QRemoteObjectPendingReply<bool> response = IpcClient::Interface()->clearSavedRoutes();
|
||||
response.waitForFinished(1000);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (!m_vpnProtocol.data()) {
|
||||
emit connectionStateChanged(VpnProtocol::Disconnected);
|
||||
#ifdef Q_OS_ANDROID
|
||||
AndroidController::instance()->stop();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
m_vpnProtocol.data()->stop();
|
||||
|
|
|
@ -8,9 +8,12 @@
|
|||
|
||||
#include "protocols/vpnprotocol.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/ipcclient.h"
|
||||
#include "settings.h"
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
#include "core/ipcclient.h"
|
||||
#endif
|
||||
|
||||
using namespace amnezia;
|
||||
|
||||
class VpnConnection : public QObject
|
||||
|
@ -74,8 +77,10 @@ private:
|
|||
QJsonObject m_vpnConfiguration;
|
||||
QJsonObject m_routeMode;
|
||||
QString m_remoteAddress;
|
||||
IpcClient *m_IpcClient {nullptr};
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
IpcClient *m_IpcClient {nullptr};
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // VPNCONNECTION_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue