mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-19 02:00:45 +07:00
f9b106cf5b
* fix: fixed country model update * fix: fixed context menu crush on ios * fix: fixed passphrase dialog freeze * fix: fixed country switch * fix: fixed start minimized * fix: fixed black screen after remove container * refactor: return cloak and ss only for view * fix: fixed default server change after improt while connected * fix: divider visibility * fix: fixed revoke admin user * fix: fixed language restore after backup * fix: link hover for tor settings page * fix: fixed openvpn connecntion status * fix: fixed free color status * fix: fixed client config update * chore: bump version
86 lines
2.8 KiB
C++
86 lines
2.8 KiB
C++
#ifndef CONNECTIONCONTROLLER_H
|
|
#define CONNECTIONCONTROLLER_H
|
|
|
|
#include <QObject>
|
|
#include <QJsonObject>
|
|
#include <QPair>
|
|
#include <memory>
|
|
|
|
#include "core/utils/containerEnum.h"
|
|
#include "core/utils/containers/containerUtils.h"
|
|
#include "core/utils/protocolEnum.h"
|
|
#include "core/utils/errorCodes.h"
|
|
#include "core/utils/routeModes.h"
|
|
#include "core/utils/commonStructs.h"
|
|
#include "core/repositories/secureServersRepository.h"
|
|
#include "core/repositories/secureAppSettingsRepository.h"
|
|
#include "core/protocols/vpnProtocol.h"
|
|
#include "vpnConnection.h"
|
|
|
|
using namespace amnezia;
|
|
|
|
class ConnectionController : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ConnectionController(SecureServersRepository* serversRepository,
|
|
SecureAppSettingsRepository* appSettingsRepository,
|
|
VpnConnection* vpnConnection,
|
|
QObject* parent = nullptr);
|
|
~ConnectionController() = default;
|
|
|
|
ErrorCode prepareConnection(const QString &serverId,
|
|
QJsonObject& vpnConfiguration,
|
|
DockerContainer& container);
|
|
|
|
ErrorCode isConnectionSupported(const QString &serverId) const;
|
|
|
|
ErrorCode openConnection(const QString &serverId);
|
|
|
|
void closeConnection();
|
|
|
|
#ifdef Q_OS_ANDROID
|
|
void restoreConnection();
|
|
#endif
|
|
|
|
void onKillSwitchModeChanged(bool enabled);
|
|
|
|
ErrorCode lastConnectionError() const;
|
|
|
|
bool isConnected() const;
|
|
void setConnectionState(Vpn::ConnectionState state);
|
|
|
|
QJsonObject createConnectionConfiguration(const QPair<QString, QString> &dns,
|
|
bool isApiConfig,
|
|
const QString &hostName,
|
|
const QString &description,
|
|
int configVersion,
|
|
const ContainerConfig &containerConfig,
|
|
DockerContainer container);
|
|
|
|
bool isServiceReady() const;
|
|
|
|
bool isContainerSupported(DockerContainer container) const;
|
|
|
|
signals:
|
|
void connectionStateChanged(Vpn::ConnectionState state);
|
|
void openConnectionRequested(const QString &serverId, DockerContainer container, const QJsonObject &vpnConfiguration);
|
|
void closeConnectionRequested();
|
|
void setConnectionStateRequested(Vpn::ConnectionState state);
|
|
void killSwitchModeChangedRequested(bool enabled);
|
|
|
|
#ifdef Q_OS_ANDROID
|
|
void restoreConnectionRequested();
|
|
#endif
|
|
|
|
private:
|
|
ErrorCode defaultContainerForServer(const QString &serverId, DockerContainer &container) const;
|
|
|
|
SecureServersRepository* m_serversRepository;
|
|
SecureAppSettingsRepository* m_appSettingsRepository;
|
|
VpnConnection* m_vpnConnection;
|
|
};
|
|
|
|
#endif
|