amnezia-client/client/vpnconnection.h
dartsyms 814b66c04a
Various fixes for iOS (#126)
* Readme update, solution for wireguard make in M1 machines,
* import file and restore enabled.
* xcode_patcher.rb fixed, Now no need to add openVPN framewrok in Embed frameworks manually.
* Now xcode_patcher.rb will add OpenVPN Framework to Embed Frameworks in main target, instead of Network extension.
* Update iosvpnprotocol.swift
* Protocol wasn't detected because it is working on localized description of tunnel, fixed cases.
* Code cleanup
* Speed issue fixed for wireguard.
* GetDeviceIp and bytes(speed of OpenVPN) fixed.
*Device IP method wasn't working as expected, so I replaced. and for speed in OpenVPN we need to handle message seperately for bytes.
*QR progress added with progressbar and text.
2022-12-12 13:16:12 +01:00

102 lines
2.8 KiB
C++

#ifndef VPNCONNECTION_H
#define VPNCONNECTION_H
#include <QObject>
#include <QString>
#include <QScopedPointer>
#include <QRemoteObjectNode>
#include "protocols/vpnprotocol.h"
#include "core/defs.h"
#include "settings.h"
#include "protocols/ios_vpnprotocol.h"
#ifdef AMNEZIA_DESKTOP
#include "core/ipcclient.h"
#endif
class VpnConfigurator;
class ServerController;
using namespace amnezia;
class VpnConnection : public QObject
{
Q_OBJECT
public:
explicit VpnConnection(std::shared_ptr<Settings> settings,
std::shared_ptr<VpnConfigurator> configurator,
std::shared_ptr<ServerController> serverController, QObject* parent = nullptr);
~VpnConnection() override;
static QString bytesPerSecToText(quint64 bytes);
ErrorCode lastError() const;
static QMap<Proto, QString> getLastVpnConfig(const QJsonObject &containerConfig);
QString createVpnConfigurationForProto(int serverIndex,
const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig, Proto proto,
ErrorCode *errorCode = nullptr);
QJsonObject createVpnConfiguration(int serverIndex,
const ServerCredentials &credentials, DockerContainer container,
const QJsonObject &containerConfig, ErrorCode *errorCode = nullptr);
bool isConnected() const;
bool isDisconnected() const;
VpnProtocol::VpnConnectionState connectionState();
QSharedPointer<VpnProtocol> vpnProtocol() const;
void addRoutes(const QStringList &ips);
void deleteRoutes(const QStringList &ips);
void flushDns();
const QString &remoteAddress() const;
void addSitesRoutes(const QString &gw, Settings::RouteMode mode);
public slots:
void connectToVpn(int serverIndex,
const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig);
void disconnectFromVpn();
signals:
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
void connectionStateChanged(VpnProtocol::VpnConnectionState state);
void vpnProtocolError(amnezia::ErrorCode error);
void serviceIsNotReady();
protected slots:
void onBytesChanged(quint64 receivedBytes, quint64 sentBytes);
void onConnectionStateChanged(VpnProtocol::VpnConnectionState state);
void checkIOSStatus();
protected:
QSharedPointer<VpnProtocol> m_vpnProtocol;
private:
std::shared_ptr<Settings> m_settings;
std::shared_ptr<VpnConfigurator> m_configurator;
std::shared_ptr<ServerController> m_serverController;
QJsonObject m_vpnConfiguration;
QJsonObject m_routeMode;
QString m_remoteAddress;
quint64 m_receivedBytes;
quint64 m_sentBytes;
bool m_isIOSConnected; //remove later move to isConnected,
#ifdef AMNEZIA_DESKTOP
IpcClient *m_IpcClient {nullptr};
#endif
#ifdef Q_OS_IOS
IOSVpnProtocol * iosVpnProtocol{nullptr};
#endif
};
#endif // VPNCONNECTION_H