Refactoring/ios (#300)
iOS app refactoring (native part): - connection bugs fixed - improved stability - logs from network extension
This commit is contained in:
parent
3ce1e40b43
commit
ece15c7394
32 changed files with 935 additions and 3191 deletions
84
client/platforms/ios/ios_controller.h
Normal file
84
client/platforms/ios/ios_controller.h
Normal file
|
@ -0,0 +1,84 @@
|
|||
#ifndef IOS_CONTROLLER_H
|
||||
#define IOS_CONTROLLER_H
|
||||
|
||||
#include "protocols/vpnprotocol.h"
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Foundation/Foundation.h>
|
||||
@class NETunnelProviderManager;
|
||||
#endif
|
||||
|
||||
using namespace amnezia;
|
||||
|
||||
struct Action {
|
||||
static const char* start;
|
||||
static const char* restart;
|
||||
static const char* stop;
|
||||
static const char* getTunnelId;
|
||||
static const char* getStatus;
|
||||
};
|
||||
|
||||
struct MessageKey {
|
||||
static const char* action;
|
||||
static const char* tunnelId;
|
||||
static const char* config;
|
||||
static const char* errorCode;
|
||||
static const char* host;
|
||||
static const char* port;
|
||||
static const char* isOnDemand;
|
||||
};
|
||||
|
||||
class IosController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static IosController* Instance();
|
||||
|
||||
virtual ~IosController() override = default;
|
||||
|
||||
bool initialize();
|
||||
bool connectVpn(amnezia::Proto proto, const QJsonObject& configuration);
|
||||
void disconnectVpn();
|
||||
|
||||
void vpnStatusDidChange(void *pNotification);
|
||||
void vpnConfigurationDidChange(void *pNotification);
|
||||
|
||||
void getBackendLogs(std::function<void (const QString &)> &&callback);
|
||||
void checkStatus();
|
||||
signals:
|
||||
void connectionStateChanged(VpnProtocol::VpnConnectionState state);
|
||||
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
||||
|
||||
protected slots:
|
||||
|
||||
|
||||
private:
|
||||
explicit IosController();
|
||||
|
||||
bool setupOpenVPN();
|
||||
bool setupCloak();
|
||||
bool setupWireGuard();
|
||||
|
||||
bool startOpenVPN(const QString &config);
|
||||
bool startWireGuard(const QString &jsonConfig);
|
||||
|
||||
void startTunnel();
|
||||
|
||||
private:
|
||||
void *m_iosControllerWrapper{};
|
||||
#ifdef __OBJC__
|
||||
NETunnelProviderManager *m_currentTunnel{};
|
||||
NSString *m_serverAddress{};
|
||||
bool isOurManager(NETunnelProviderManager* manager);
|
||||
void sendVpnExtensionMessage(NSDictionary* message, std::function<void(NSDictionary*)> callback);
|
||||
#endif
|
||||
|
||||
amnezia::Proto m_proto;
|
||||
QJsonObject m_rawConfig;
|
||||
QString m_tunnelId;
|
||||
uint64_t m_txBytes;
|
||||
uint64_t m_rxBytes;
|
||||
};
|
||||
|
||||
#endif // IOS_CONTROLLER_H
|
Loading…
Add table
Add a link
Reference in a new issue