Merge branch 'dev' of github.com:amnezia-vpn/desktop-client into feature/qt6-client-management-panel

This commit is contained in:
vladimir.kuznetsov 2023-01-29 09:52:12 +03:00
commit 25829451c8
39 changed files with 1279 additions and 585 deletions

View file

@ -7,11 +7,7 @@
#include <QTextCodec>
#include <QTimer>
#include <QtCore/private/qandroidextras_p.h>
#include "android_vpnprotocol.h"
#include "core/errorstrings.h"
#include "platforms/android/android_controller.h"
@ -19,9 +15,7 @@
AndroidVpnProtocol::AndroidVpnProtocol(Proto protocol, const QJsonObject &configuration, QObject* parent)
: VpnProtocol(configuration, parent),
m_protocol(protocol)
{
}
{ }
ErrorCode AndroidVpnProtocol::start()
{
@ -35,3 +29,11 @@ void AndroidVpnProtocol::stop()
AndroidController::instance()->stop();
}
void AndroidVpnProtocol::connectionDataUpdated(QString totalRx, QString totalTx, QString endpoint, QString deviceIPv4)
{
quint64 rxBytes = totalRx.toLongLong();
quint64 txBytes = totalTx.toLongLong();
setBytesChanged(rxBytes, txBytes);
}

View file

@ -1,16 +1,11 @@
#ifndef ANDROID_VPNPROTOCOL_H
#define ANDROID_VPNPROTOCOL_H
#include <QAndroidBinder>
#include <QAndroidServiceConnection>
#include "vpnprotocol.h"
#include "protocols/protocols_defs.h"
using namespace amnezia;
class AndroidVpnProtocol : public VpnProtocol
{
Q_OBJECT
@ -25,6 +20,9 @@ public:
signals:
public slots:
void connectionDataUpdated(QString totalRx, QString totalTx, QString endpoint, QString deviceIPv4);
protected slots:
protected:
@ -32,7 +30,6 @@ protected:
private:
Proto m_protocol;
};
#endif // ANDROID_VPNPROTOCOL_H

View file

@ -36,6 +36,7 @@ public:
void cleanupBackendLogs();
signals:
void newTransmitedDataCount(quint64 rxBytes, quint64 txBytes);
protected slots:

View file

@ -25,8 +25,10 @@ Proto currentProto = amnezia::Proto::Any;
}
IOSVpnProtocol::IOSVpnProtocol(Proto proto, const QJsonObject &configuration, QObject* parent)
: VpnProtocol(configuration, parent),
m_protocol(proto) {}
: VpnProtocol(configuration, parent), m_protocol(proto)
{
connect(this, &IOSVpnProtocol::newTransmitedDataCount, this, &IOSVpnProtocol::setBytesChanged);
}
IOSVpnProtocol* IOSVpnProtocol::instance() {
return s_instance;
@ -207,8 +209,7 @@ void IOSVpnProtocol::checkStatus()
qDebug() << "ServerIpv4Gateway:" << QString::fromNSString(serverIpv4Gateway)
<< "DeviceIpv4Address:" << QString::fromNSString(deviceIpv4Address)
<< "RxBytes:" << rxBytes << "TxBytes:" << txBytes;
emit bytesChanged(rxBytes, txBytes);
emit newTransmitedDataCount(rxBytes, txBytes);
}];
}

View file

@ -67,7 +67,10 @@ VpnProtocol::VpnConnectionState VpnProtocol::connectionState() const
void VpnProtocol::setBytesChanged(quint64 receivedBytes, quint64 sentBytes)
{
emit bytesChanged(receivedBytes - m_receivedBytes, sentBytes - m_sentBytes);
quint64 rxDiff = receivedBytes - m_receivedBytes;
quint64 txDiff = sentBytes - m_sentBytes;
emit bytesChanged(rxDiff, txDiff);
m_receivedBytes = receivedBytes;
m_sentBytes = sentBytes;