2020-12-26 15:03:51 +03:00
|
|
|
#ifndef VPNCONNECTION_H
|
|
|
|
|
#define VPNCONNECTION_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QScopedPointer>
|
|
|
|
|
|
2021-01-06 17:12:24 +03:00
|
|
|
#include "protocols/vpnprotocol.h"
|
|
|
|
|
#include "core/defs.h"
|
|
|
|
|
|
|
|
|
|
using namespace amnezia;
|
2020-12-26 15:03:51 +03:00
|
|
|
|
|
|
|
|
class VpnConnection : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit VpnConnection(QObject* parent = nullptr);
|
2021-01-06 17:12:24 +03:00
|
|
|
~VpnConnection() override = default;
|
2020-12-26 15:03:51 +03:00
|
|
|
|
2021-01-09 19:55:16 +03:00
|
|
|
static QString bytesPerSecToText(quint64 bytes);
|
2020-12-26 15:03:51 +03:00
|
|
|
|
2021-01-06 17:12:24 +03:00
|
|
|
ErrorCode lastError() const;
|
|
|
|
|
ErrorCode requestVpnConfig(const ServerCredentials &credentials, Protocol protocol);
|
|
|
|
|
ErrorCode connectToVpn(const ServerCredentials &credentials, Protocol protocol = Protocol::Any);
|
2021-01-08 16:51:58 +03:00
|
|
|
bool onConnected() const;
|
|
|
|
|
bool onDisconnected() const;
|
2020-12-26 15:03:51 +03:00
|
|
|
void disconnectFromVpn();
|
|
|
|
|
|
2021-01-15 23:36:35 +03:00
|
|
|
VpnProtocol::ConnectionState connectionState();
|
|
|
|
|
|
2020-12-26 15:03:51 +03:00
|
|
|
signals:
|
|
|
|
|
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
|
|
|
|
void connectionStateChanged(VpnProtocol::ConnectionState state);
|
2021-01-08 16:51:58 +03:00
|
|
|
void vpnProtocolError(amnezia::ErrorCode error);
|
2020-12-26 15:03:51 +03:00
|
|
|
|
|
|
|
|
protected slots:
|
|
|
|
|
void onBytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
|
|
|
|
void onConnectionStateChanged(VpnProtocol::ConnectionState state);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
QScopedPointer<VpnProtocol> m_vpnProtocol;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // VPNCONNECTION_H
|