mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 12206cdb52 | |||
| 93aebf5256 | |||
| 502e815a9f | |||
| 8bc69bdc62 | |||
| b3ae687feb | |||
| d6d11d6e60 | |||
| b90bf16945 | |||
| b162147a89 | |||
| faaf5973b4 | |||
| aa4bfc70b9 | |||
| ef674d1e4f | |||
| 23633e8fa7 | |||
| 3cc846678e | |||
| 84e8667e57 | |||
| b500a1f09d | |||
| 2399d45bab | |||
| 77e82fbf40 | |||
| a6467dd0f0 | |||
| 2e11cc56ab | |||
| c2d204b362 | |||
| 77a83e4fc3 | |||
| 8617896c7a | |||
| 97c6b217f2 | |||
| efde0c99a3 | |||
| 2dccfce468 | |||
| eaa603684c | |||
| 7ef41bfe75 | |||
| e5c25e8a0c | |||
| c9af9f34fc | |||
| acfe19b914 | |||
| 81242b405f | |||
| 61092259ba |
@@ -25,7 +25,7 @@ jobs:
|
|||||||
host: 'linux'
|
host: 'linux'
|
||||||
target: 'desktop'
|
target: 'desktop'
|
||||||
arch: 'gcc_64'
|
arch: 'gcc_64'
|
||||||
modules: 'qtremoteobjects qt5compat qtshadertools'
|
modules: 'qtremoteobjects qt5compat qtshadertools qtcharts'
|
||||||
dir: ${{ runner.temp }}
|
dir: ${{ runner.temp }}
|
||||||
setup-python: 'true'
|
setup-python: 'true'
|
||||||
tools: 'tools_ifw'
|
tools: 'tools_ifw'
|
||||||
@@ -93,7 +93,7 @@ jobs:
|
|||||||
host: 'windows'
|
host: 'windows'
|
||||||
target: 'desktop'
|
target: 'desktop'
|
||||||
arch: 'win64_msvc2019_64'
|
arch: 'win64_msvc2019_64'
|
||||||
modules: 'qtremoteobjects qt5compat qtshadertools'
|
modules: 'qtremoteobjects qt5compat qtshadertools qtcharts'
|
||||||
dir: ${{ runner.temp }}
|
dir: ${{ runner.temp }}
|
||||||
setup-python: 'true'
|
setup-python: 'true'
|
||||||
tools: 'tools_ifw'
|
tools: 'tools_ifw'
|
||||||
@@ -150,7 +150,7 @@ jobs:
|
|||||||
version: ${{ env.QT_VERSION }}
|
version: ${{ env.QT_VERSION }}
|
||||||
host: 'mac'
|
host: 'mac'
|
||||||
target: 'desktop'
|
target: 'desktop'
|
||||||
modules: 'qtremoteobjects qt5compat qtshadertools qtmultimedia'
|
modules: 'qtremoteobjects qt5compat qtshadertools qtmultimedia qtcharts'
|
||||||
arch: 'clang_64'
|
arch: 'clang_64'
|
||||||
dir: ${{ runner.temp }}
|
dir: ${{ runner.temp }}
|
||||||
set-env: 'true'
|
set-env: 'true'
|
||||||
@@ -162,7 +162,7 @@ jobs:
|
|||||||
version: ${{ env.QT_VERSION }}
|
version: ${{ env.QT_VERSION }}
|
||||||
host: 'mac'
|
host: 'mac'
|
||||||
target: 'ios'
|
target: 'ios'
|
||||||
modules: 'qtremoteobjects qt5compat qtshadertools qtmultimedia'
|
modules: 'qtremoteobjects qt5compat qtshadertools qtmultimedia qtcharts'
|
||||||
dir: ${{ runner.temp }}
|
dir: ${{ runner.temp }}
|
||||||
setup-python: 'true'
|
setup-python: 'true'
|
||||||
set-env: 'true'
|
set-env: 'true'
|
||||||
@@ -242,7 +242,7 @@ jobs:
|
|||||||
host: 'mac'
|
host: 'mac'
|
||||||
target: 'desktop'
|
target: 'desktop'
|
||||||
arch: 'clang_64'
|
arch: 'clang_64'
|
||||||
modules: 'qtremoteobjects qt5compat qtshadertools'
|
modules: 'qtremoteobjects qt5compat qtshadertools qtcharts'
|
||||||
dir: ${{ runner.temp }}
|
dir: ${{ runner.temp }}
|
||||||
setup-python: 'true'
|
setup-python: 'true'
|
||||||
set-env: 'true'
|
set-env: 'true'
|
||||||
@@ -292,7 +292,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
ANDROID_BUILD_PLATFORM: android-34
|
ANDROID_BUILD_PLATFORM: android-34
|
||||||
QT_VERSION: 6.6.2
|
QT_VERSION: 6.6.2
|
||||||
QT_MODULES: 'qtremoteobjects qt5compat qtimageformats qtshadertools'
|
QT_MODULES: 'qtremoteobjects qt5compat qtimageformats qtshadertools qtcharts'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 'Install desktop Qt'
|
- name: 'Install desktop Qt'
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ Check deploy folder for build scripts.
|
|||||||
- Qt 5 Compatibility Module
|
- Qt 5 Compatibility Module
|
||||||
- Qt Shader Tools
|
- Qt Shader Tools
|
||||||
- Additional Libraries:
|
- Additional Libraries:
|
||||||
|
- Qt Charts
|
||||||
- Qt Image Formats
|
- Qt Image Formats
|
||||||
- Qt Multimedia
|
- Qt Multimedia
|
||||||
- Qt Remote Objects
|
- Qt Remote Objects
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "Autogen")
|
|||||||
set(PACKAGES
|
set(PACKAGES
|
||||||
Core Gui Network Xml
|
Core Gui Network Xml
|
||||||
RemoteObjects Quick Svg QuickControls2
|
RemoteObjects Quick Svg QuickControls2
|
||||||
Core5Compat Concurrent LinguistTools
|
Core5Compat Concurrent LinguistTools Charts
|
||||||
)
|
)
|
||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
@@ -38,7 +38,7 @@ set(LIBS ${LIBS}
|
|||||||
Qt6::Core Qt6::Gui
|
Qt6::Core Qt6::Gui
|
||||||
Qt6::Network Qt6::Xml Qt6::RemoteObjects
|
Qt6::Network Qt6::Xml Qt6::RemoteObjects
|
||||||
Qt6::Quick Qt6::Svg Qt6::QuickControls2
|
Qt6::Quick Qt6::Svg Qt6::QuickControls2
|
||||||
Qt6::Core5Compat Qt6::Concurrent
|
Qt6::Core5Compat Qt6::Concurrent Qt6::Charts
|
||||||
)
|
)
|
||||||
|
|
||||||
if(IOS)
|
if(IOS)
|
||||||
|
|||||||
@@ -195,8 +195,8 @@ void AmneziaApplication::init()
|
|||||||
// /qt/6.6.1/Src/qtbase/src/plugins/platforms/android/androidjniclipboard.cpp:46
|
// /qt/6.6.1/Src/qtbase/src/plugins/platforms/android/androidjniclipboard.cpp:46
|
||||||
// So we catch all the copies to the clipboard and clear them from "text/html"
|
// So we catch all the copies to the clipboard and clear them from "text/html"
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
connect(QGuiApplication::clipboard(), &QClipboard::dataChanged, []() {
|
connect(QApplication::clipboard(), &QClipboard::dataChanged, []() {
|
||||||
auto clipboard = QGuiApplication::clipboard();
|
auto clipboard = QApplication::clipboard();
|
||||||
if (clipboard->mimeData()->hasHtml()) {
|
if (clipboard->mimeData()->hasHtml()) {
|
||||||
clipboard->setText(clipboard->text());
|
clipboard->setText(clipboard->text());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,7 @@
|
|||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
#include <QApplication>
|
||||||
#include <QGuiApplication>
|
|
||||||
#else
|
|
||||||
#include <QApplication>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "vpnconnection.h"
|
#include "vpnconnection.h"
|
||||||
@@ -47,7 +43,7 @@
|
|||||||
#define amnApp (static_cast<AmneziaApplication *>(QCoreApplication::instance()))
|
#define amnApp (static_cast<AmneziaApplication *>(QCoreApplication::instance()))
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
||||||
#define AMNEZIA_BASE_CLASS QGuiApplication
|
#define AMNEZIA_BASE_CLASS QApplication
|
||||||
#else
|
#else
|
||||||
#define AMNEZIA_BASE_CLASS SingleApplication
|
#define AMNEZIA_BASE_CLASS SingleApplication
|
||||||
#define QAPPLICATION_CLASS QApplication
|
#define QAPPLICATION_CLASS QApplication
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class AmneziaActivity : QtActivity() {
|
|||||||
object : Handler(Looper.getMainLooper()) {
|
object : Handler(Looper.getMainLooper()) {
|
||||||
override fun handleMessage(msg: Message) {
|
override fun handleMessage(msg: Message) {
|
||||||
val event = msg.extractIpcMessage<ServiceEvent>()
|
val event = msg.extractIpcMessage<ServiceEvent>()
|
||||||
Log.d(TAG, "Handle event: $event")
|
if (event != ServiceEvent.STATISTICS_UPDATE) Log.d(TAG, "Handle event: $event")
|
||||||
when (event) {
|
when (event) {
|
||||||
ServiceEvent.STATUS_CHANGED -> {
|
ServiceEvent.STATUS_CHANGED -> {
|
||||||
msg.data?.getStatus()?.let { (state) ->
|
msg.data?.getStatus()?.let { (state) ->
|
||||||
|
|||||||
@@ -528,7 +528,6 @@ bool Daemon::switchServer(const InterfaceConfig& config) {
|
|||||||
QJsonObject Daemon::getStatus() {
|
QJsonObject Daemon::getStatus() {
|
||||||
Q_ASSERT(wgutils() != nullptr);
|
Q_ASSERT(wgutils() != nullptr);
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
logger.debug() << "Status request";
|
|
||||||
|
|
||||||
if (!wgutils()->interfaceExists() || m_connections.isEmpty()) {
|
if (!wgutils()->interfaceExists() || m_connections.isEmpty()) {
|
||||||
json.insert("connected", QJsonValue(false));
|
json.insert("connected", QJsonValue(false));
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ DaemonLocalServerConnection::~DaemonLocalServerConnection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DaemonLocalServerConnection::readData() {
|
void DaemonLocalServerConnection::readData() {
|
||||||
logger.debug() << "Read Data";
|
|
||||||
|
|
||||||
Q_ASSERT(m_socket);
|
Q_ASSERT(m_socket);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -90,8 +88,6 @@ void DaemonLocalServerConnection::parseCommand(const QByteArray& data) {
|
|||||||
}
|
}
|
||||||
QString type = typeValue.toString();
|
QString type = typeValue.toString();
|
||||||
|
|
||||||
logger.debug() << "Command received:" << type;
|
|
||||||
|
|
||||||
if (type == "activate") {
|
if (type == "activate") {
|
||||||
InterfaceConfig config;
|
InterfaceConfig config;
|
||||||
if (!Daemon::parseConfig(obj, config)) {
|
if (!Daemon::parseConfig(obj, config)) {
|
||||||
|
|||||||
@@ -273,8 +273,6 @@ void LocalSocketController::deactivate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LocalSocketController::checkStatus() {
|
void LocalSocketController::checkStatus() {
|
||||||
logger.debug() << "Check status";
|
|
||||||
|
|
||||||
if (m_daemonState == eReady || m_daemonState == eInitializing) {
|
if (m_daemonState == eReady || m_daemonState == eInitializing) {
|
||||||
Q_ASSERT(m_socket);
|
Q_ASSERT(m_socket);
|
||||||
|
|
||||||
@@ -324,7 +322,6 @@ void LocalSocketController::cleanupBackendLogs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LocalSocketController::readData() {
|
void LocalSocketController::readData() {
|
||||||
logger.debug() << "Reading";
|
|
||||||
|
|
||||||
Q_ASSERT(m_socket);
|
Q_ASSERT(m_socket);
|
||||||
Q_ASSERT(m_daemonState == eInitializing || m_daemonState == eReady);
|
Q_ASSERT(m_daemonState == eInitializing || m_daemonState == eReady);
|
||||||
@@ -366,8 +363,6 @@ void LocalSocketController::parseCommand(const QByteArray& command) {
|
|||||||
}
|
}
|
||||||
QString type = typeValue.toString();
|
QString type = typeValue.toString();
|
||||||
|
|
||||||
logger.debug() << "Parse command:" << type;
|
|
||||||
|
|
||||||
if (m_daemonState == eInitializing && type == "status") {
|
if (m_daemonState == eInitializing && type == "status") {
|
||||||
m_daemonState = eReady;
|
m_daemonState = eReady;
|
||||||
|
|
||||||
@@ -393,6 +388,7 @@ void LocalSocketController::parseCommand(const QByteArray& command) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit initialized(true, connected.toBool(), datetime);
|
emit initialized(true, connected.toBool(), datetime);
|
||||||
|
checkStatus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,20 @@ WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject *
|
|||||||
});
|
});
|
||||||
connect(m_impl.get(), &ControllerImpl::disconnected, this,
|
connect(m_impl.get(), &ControllerImpl::disconnected, this,
|
||||||
[this]() { emit connectionStateChanged(Vpn::ConnectionState::Disconnected); });
|
[this]() { emit connectionStateChanged(Vpn::ConnectionState::Disconnected); });
|
||||||
|
|
||||||
|
connect(m_impl.get(), &ControllerImpl::statusUpdated, this,
|
||||||
|
&WireguardProtocol::statusUpdated);
|
||||||
|
|
||||||
m_impl->initialize(nullptr, nullptr);
|
m_impl->initialize(nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WireguardProtocol::statusUpdated(const QString& serverIpv4Gateway, const QString& deviceIpv4Address,
|
||||||
|
uint64_t txBytes, uint64_t rxBytes) {
|
||||||
|
setBytesChanged(rxBytes, txBytes);
|
||||||
|
QThread::msleep(1000);
|
||||||
|
m_impl->checkStatus();
|
||||||
|
}
|
||||||
|
|
||||||
WireguardProtocol::~WireguardProtocol()
|
WireguardProtocol::~WireguardProtocol()
|
||||||
{
|
{
|
||||||
WireguardProtocol::stop();
|
WireguardProtocol::stop();
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ public:
|
|||||||
|
|
||||||
ErrorCode start() override;
|
ErrorCode start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
void statusUpdated(const QString& serverIpv4Gateway, const QString& deviceIpv4Address,
|
||||||
|
uint64_t txBytes, uint64_t rxBytes);
|
||||||
ErrorCode startMzImpl();
|
ErrorCode startMzImpl();
|
||||||
ErrorCode stopMzImpl();
|
ErrorCode stopMzImpl();
|
||||||
|
|
||||||
|
|||||||
@@ -225,6 +225,7 @@
|
|||||||
<file>ui/qml/Pages2/PageShareFullAccess.qml</file>
|
<file>ui/qml/Pages2/PageShareFullAccess.qml</file>
|
||||||
<file>images/controls/close.svg</file>
|
<file>images/controls/close.svg</file>
|
||||||
<file>images/controls/search.svg</file>
|
<file>images/controls/search.svg</file>
|
||||||
|
<file>ui/qml/Controls2/GraphViewType.qml</file>
|
||||||
<file>server_scripts/xray/configure_container.sh</file>
|
<file>server_scripts/xray/configure_container.sh</file>
|
||||||
<file>server_scripts/xray/Dockerfile</file>
|
<file>server_scripts/xray/Dockerfile</file>
|
||||||
<file>server_scripts/xray/run_container.sh</file>
|
<file>server_scripts/xray/run_container.sh</file>
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
|
|
||||||
#include "utilities.h"
|
|
||||||
#include "core/controllers/apiController.h"
|
#include "core/controllers/apiController.h"
|
||||||
#include "core/controllers/vpnConfigurationController.h"
|
#include "core/controllers/vpnConfigurationController.h"
|
||||||
#include "core/errorstrings.h"
|
#include "core/errorstrings.h"
|
||||||
|
#include "utilities.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
ConnectionController::ConnectionController(const QSharedPointer<ServersModel> &serversModel,
|
ConnectionController::ConnectionController(const QSharedPointer<ServersModel> &serversModel,
|
||||||
@@ -29,14 +29,30 @@ ConnectionController::ConnectionController(const QSharedPointer<ServersModel> &s
|
|||||||
connect(this, &ConnectionController::connectToVpn, m_vpnConnection.get(), &VpnConnection::connectToVpn, Qt::QueuedConnection);
|
connect(this, &ConnectionController::connectToVpn, m_vpnConnection.get(), &VpnConnection::connectToVpn, Qt::QueuedConnection);
|
||||||
connect(this, &ConnectionController::disconnectFromVpn, m_vpnConnection.get(), &VpnConnection::disconnectFromVpn, Qt::QueuedConnection);
|
connect(this, &ConnectionController::disconnectFromVpn, m_vpnConnection.get(), &VpnConnection::disconnectFromVpn, Qt::QueuedConnection);
|
||||||
|
|
||||||
|
connect(m_vpnConnection.get(), &VpnConnection::bytesChanged, this, [this](quint64 rx, quint64 tx) {
|
||||||
|
m_rxBytes = rx;
|
||||||
|
m_txBytes = tx;
|
||||||
|
});
|
||||||
|
connect(&m_tick, &QTimer::timeout, this, [this]() {
|
||||||
|
quint64 time = QDateTime::currentSecsSinceEpoch();
|
||||||
|
if (m_times.length() > viewSize) {
|
||||||
|
m_times.removeFirst();
|
||||||
|
m_rxView.removeFirst();
|
||||||
|
m_txView.removeFirst();
|
||||||
|
}
|
||||||
|
m_times.append(time);
|
||||||
|
m_rxView.append(m_rxBytes);
|
||||||
|
m_txView.append(m_txBytes);
|
||||||
|
emit bytesChanged();
|
||||||
|
});
|
||||||
|
|
||||||
m_state = Vpn::ConnectionState::Disconnected;
|
m_state = Vpn::ConnectionState::Disconnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionController::openConnection()
|
void ConnectionController::openConnection()
|
||||||
{
|
{
|
||||||
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||||
if (!Utils::processIsRunning(Utils::executable(SERVICE_NAME, false), true))
|
if (!Utils::processIsRunning(Utils::executable(SERVICE_NAME, false), true)) {
|
||||||
{
|
|
||||||
emit connectionErrorOccurred(errorString(ErrorCode::AmneziaServiceNotRunning));
|
emit connectionErrorOccurred(errorString(ErrorCode::AmneziaServiceNotRunning));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -124,6 +140,7 @@ void ConnectionController::onConnectionStateChanged(Vpn::ConnectionState state)
|
|||||||
m_isConnectionInProgress = false;
|
m_isConnectionInProgress = false;
|
||||||
m_isConnected = true;
|
m_isConnected = true;
|
||||||
m_connectionStateText = tr("Connected");
|
m_connectionStateText = tr("Connected");
|
||||||
|
m_tick.start(1000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Vpn::ConnectionState::Connecting: {
|
case Vpn::ConnectionState::Connecting: {
|
||||||
@@ -143,6 +160,7 @@ void ConnectionController::onConnectionStateChanged(Vpn::ConnectionState state)
|
|||||||
case Vpn::ConnectionState::Disconnecting: {
|
case Vpn::ConnectionState::Disconnecting: {
|
||||||
m_isConnectionInProgress = true;
|
m_isConnectionInProgress = true;
|
||||||
m_connectionStateText = tr("Disconnecting...");
|
m_connectionStateText = tr("Disconnecting...");
|
||||||
|
m_tick.stop();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Vpn::ConnectionState::Preparing: {
|
case Vpn::ConnectionState::Preparing: {
|
||||||
@@ -192,6 +210,30 @@ QString ConnectionController::connectionStateText() const
|
|||||||
return m_connectionStateText;
|
return m_connectionStateText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quint64 ConnectionController::rxBytes() const
|
||||||
|
{
|
||||||
|
return m_rxBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint64 ConnectionController::txBytes() const
|
||||||
|
{
|
||||||
|
return m_txBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<quint64> ConnectionController::getRxView() const
|
||||||
|
{
|
||||||
|
return m_rxView;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<quint64> ConnectionController::getTxView() const
|
||||||
|
{
|
||||||
|
return m_txView;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<quint64> ConnectionController::getTimes() const
|
||||||
|
{
|
||||||
|
return m_times;
|
||||||
|
}
|
||||||
void ConnectionController::toggleConnection()
|
void ConnectionController::toggleConnection()
|
||||||
{
|
{
|
||||||
if (m_state == Vpn::ConnectionState::Preparing) {
|
if (m_state == Vpn::ConnectionState::Preparing) {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ public:
|
|||||||
Q_PROPERTY(bool isConnected READ isConnected NOTIFY connectionStateChanged)
|
Q_PROPERTY(bool isConnected READ isConnected NOTIFY connectionStateChanged)
|
||||||
Q_PROPERTY(bool isConnectionInProgress READ isConnectionInProgress NOTIFY connectionStateChanged)
|
Q_PROPERTY(bool isConnectionInProgress READ isConnectionInProgress NOTIFY connectionStateChanged)
|
||||||
Q_PROPERTY(QString connectionStateText READ connectionStateText NOTIFY connectionStateChanged)
|
Q_PROPERTY(QString connectionStateText READ connectionStateText NOTIFY connectionStateChanged)
|
||||||
|
Q_PROPERTY(quint64 rxBytes READ rxBytes NOTIFY bytesChanged)
|
||||||
|
Q_PROPERTY(quint64 txBytes READ txBytes NOTIFY bytesChanged)
|
||||||
|
|
||||||
explicit ConnectionController(const QSharedPointer<ServersModel> &serversModel, const QSharedPointer<ContainersModel> &containersModel,
|
explicit ConnectionController(const QSharedPointer<ServersModel> &serversModel, const QSharedPointer<ContainersModel> &containersModel,
|
||||||
const QSharedPointer<ClientManagementModel> &clientManagementModel,
|
const QSharedPointer<ClientManagementModel> &clientManagementModel,
|
||||||
@@ -26,6 +28,12 @@ public:
|
|||||||
bool isConnected() const;
|
bool isConnected() const;
|
||||||
bool isConnectionInProgress() const;
|
bool isConnectionInProgress() const;
|
||||||
QString connectionStateText() const;
|
QString connectionStateText() const;
|
||||||
|
quint64 rxBytes() const;
|
||||||
|
quint64 txBytes() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE QVector<quint64> getRxView() const;
|
||||||
|
Q_INVOKABLE QVector<quint64> getTxView() const;
|
||||||
|
Q_INVOKABLE QVector<quint64> getTimes() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void toggleConnection();
|
void toggleConnection();
|
||||||
@@ -50,6 +58,7 @@ signals:
|
|||||||
|
|
||||||
void connectionErrorOccurred(const QString &errorMessage);
|
void connectionErrorOccurred(const QString &errorMessage);
|
||||||
void reconnectWithUpdatedContainer(const QString &message);
|
void reconnectWithUpdatedContainer(const QString &message);
|
||||||
|
void bytesChanged();
|
||||||
|
|
||||||
void noInstalledContainers();
|
void noInstalledContainers();
|
||||||
|
|
||||||
@@ -71,8 +80,17 @@ private:
|
|||||||
bool m_isConnected = false;
|
bool m_isConnected = false;
|
||||||
bool m_isConnectionInProgress = false;
|
bool m_isConnectionInProgress = false;
|
||||||
QString m_connectionStateText = tr("Connect");
|
QString m_connectionStateText = tr("Connect");
|
||||||
|
quint64 m_rxBytes = 0;
|
||||||
|
quint64 m_txBytes = 0;
|
||||||
|
QVector<quint64> m_rxView{};
|
||||||
|
QVector<quint64> m_txView{};
|
||||||
|
QVector<quint64> m_times{};
|
||||||
|
|
||||||
|
QTimer m_tick{};
|
||||||
|
|
||||||
Vpn::ConnectionState m_state;
|
Vpn::ConnectionState m_state;
|
||||||
|
|
||||||
|
const static quint8 viewSize{60};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONNECTIONCONTROLLER_H
|
#endif // CONNECTIONCONTROLLER_H
|
||||||
|
|||||||
@@ -24,6 +24,20 @@ SystemController::SystemController(const std::shared_ptr<Settings> &settings, QO
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SystemController::setAppHasFocus(bool appHasFocus)
|
||||||
|
{
|
||||||
|
if (m_appHasFocus != appHasFocus)
|
||||||
|
{
|
||||||
|
m_appHasFocus = appHasFocus;
|
||||||
|
emit appHasFocusChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SystemController::appHasFocus() const
|
||||||
|
{
|
||||||
|
return m_appHasFocus;
|
||||||
|
}
|
||||||
|
|
||||||
void SystemController::saveFile(QString fileName, const QString &data)
|
void SystemController::saveFile(QString fileName, const QString &data)
|
||||||
{
|
{
|
||||||
#if defined Q_OS_ANDROID
|
#if defined Q_OS_ANDROID
|
||||||
|
|||||||
@@ -8,9 +8,13 @@
|
|||||||
class SystemController : public QObject
|
class SystemController : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool appHasFocus READ appHasFocus WRITE setAppHasFocus NOTIFY appHasFocusChanged)
|
||||||
public:
|
public:
|
||||||
explicit SystemController(const std::shared_ptr<Settings> &setting, QObject *parent = nullptr);
|
explicit SystemController(const std::shared_ptr<Settings> &setting, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
void setAppHasFocus(bool isActive);
|
||||||
|
bool appHasFocus() const;
|
||||||
|
|
||||||
static void saveFile(QString fileName, const QString &data);
|
static void saveFile(QString fileName, const QString &data);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -21,11 +25,13 @@ public slots:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void fileDialogClosed(const bool isAccepted);
|
void fileDialogClosed(const bool isAccepted);
|
||||||
|
void appHasFocusChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Settings> m_settings;
|
std::shared_ptr<Settings> m_settings;
|
||||||
|
|
||||||
QObject *m_qmlRoot;
|
QObject *m_qmlRoot;
|
||||||
|
bool m_appHasFocus{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SYSTEMCONTROLLER_H
|
#endif // SYSTEMCONTROLLER_H
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtCharts
|
||||||
|
|
||||||
|
ChartView {
|
||||||
|
id: chartView
|
||||||
|
legend.visible: false
|
||||||
|
animationOptions: ChartView.AllAnimations
|
||||||
|
animationDuration: 2000.0
|
||||||
|
|
||||||
|
backgroundColor: "#1C1D21"
|
||||||
|
plotAreaColor: "#1C1D21"
|
||||||
|
margins.top: 0
|
||||||
|
margins.bottom: 0
|
||||||
|
margins.left: 0
|
||||||
|
margins.right: 0
|
||||||
|
antialiasing: true
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
property bool shouldUpdate: SystemController.appHasFocus
|
||||||
|
|
||||||
|
function getUTCSeconds() {
|
||||||
|
return new Date().setMilliseconds(0) / 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
function addValues(rx, tx) {
|
||||||
|
let currentTime = getUTCSeconds()
|
||||||
|
|
||||||
|
xAxis.min = currentTime - 60
|
||||||
|
xAxis.max = currentTime
|
||||||
|
|
||||||
|
if (rx > yAxis.max) yAxis.max = rx * 1.1
|
||||||
|
if (tx > yAxis.max) yAxis.max = tx * 1.1
|
||||||
|
|
||||||
|
rxLine.append(currentTime, rx)
|
||||||
|
txLine.append(currentTime, tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
function printAll() {
|
||||||
|
var rxValues = ConnectionController.getRxView()
|
||||||
|
var txValues = ConnectionController.getTxView()
|
||||||
|
var times = ConnectionController.getTimes()
|
||||||
|
|
||||||
|
let currentTime = getUTCSeconds()
|
||||||
|
xAxis.min = currentTime - 60
|
||||||
|
xAxis.max = currentTime
|
||||||
|
|
||||||
|
|
||||||
|
rxLine.clear()
|
||||||
|
txLine.clear()
|
||||||
|
|
||||||
|
if (times.length === 0) return
|
||||||
|
|
||||||
|
xAxis.min = times[0]
|
||||||
|
xAxis.max = times[times.length - 1]
|
||||||
|
|
||||||
|
for (let i = 0; i < times.length; i++)
|
||||||
|
{
|
||||||
|
if (rxValues[i] > yAxis.max) yAxis.max = rxValues[i]
|
||||||
|
if (txValues[i] > yAxis.max) yAxis.max = txValues[i]
|
||||||
|
|
||||||
|
rxLine.append(times[i], rxValues[i])
|
||||||
|
txLine.append(times[i], txValues[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
printAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: ConnectionController
|
||||||
|
function onBytesChanged() {
|
||||||
|
if (shouldUpdate) {
|
||||||
|
addValues(ConnectionController.rxBytes, ConnectionController.txBytes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: SystemController
|
||||||
|
function onAppHasFocusChanged() {
|
||||||
|
if (shouldUpdate) { printAll() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueAxis {
|
||||||
|
id: yAxis
|
||||||
|
min: -100
|
||||||
|
max: 1000
|
||||||
|
visible: false
|
||||||
|
labelsVisible: false
|
||||||
|
gridLineColor: "transparent"
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueAxis {
|
||||||
|
id: xAxis
|
||||||
|
visible: false
|
||||||
|
labelsVisible: false
|
||||||
|
gridLineColor: "transparent"
|
||||||
|
}
|
||||||
|
|
||||||
|
SplineSeries {
|
||||||
|
id: rxLine
|
||||||
|
name: "Received Bytes"
|
||||||
|
//width: 2
|
||||||
|
axisX: xAxis
|
||||||
|
axisY: yAxis
|
||||||
|
capStyle: Qt.RoundCap
|
||||||
|
useOpenGL: true
|
||||||
|
color: "#70553c"
|
||||||
|
XYPoint { x: getUTCSeconds(); y: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
SplineSeries {
|
||||||
|
id: txLine
|
||||||
|
name: "Transmitted Bytes"
|
||||||
|
//width: 2
|
||||||
|
axisX: xAxis
|
||||||
|
axisY: yAxis
|
||||||
|
capStyle: Qt.RoundCap
|
||||||
|
useOpenGL: true
|
||||||
|
color: "#737274"
|
||||||
|
XYPoint { x: getUTCSeconds(); y: 0 }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -261,10 +261,15 @@ PageType {
|
|||||||
|
|
||||||
LabelTextType {
|
LabelTextType {
|
||||||
id: collapsedServerMenuDescription
|
id: collapsedServerMenuDescription
|
||||||
Layout.bottomMargin: drawer.isCollapsed ? 44 : ServersModel.isDefaultServerFromApi ? 89 : 44
|
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||||
text: drawer.isCollapsed ? ServersModel.defaultServerDescriptionCollapsed : ServersModel.defaultServerDescriptionExpanded
|
text: drawer.isCollapsed ? ServersModel.defaultServerDescriptionCollapsed : ServersModel.defaultServerDescriptionExpanded
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GraphViewType {
|
||||||
|
Layout.minimumHeight: 50
|
||||||
|
Layout.bottomMargin: drawer.isCollapsed ? 24 : ServersModel.isDefaultServerFromApi ? 69 : 24
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ Window {
|
|||||||
PageController.closeWindow()
|
PageController.closeWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onActiveChanged: {
|
||||||
|
SystemController.appHasFocus = active
|
||||||
|
}
|
||||||
|
|
||||||
title: "AmneziaVPN"
|
title: "AmneziaVPN"
|
||||||
|
|
||||||
StackViewType {
|
StackViewType {
|
||||||
|
|||||||
Reference in New Issue
Block a user