mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-24 02:00:24 +07:00
Statistic for WG/AWG protocol
This commit is contained in:
@@ -500,7 +500,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)) {
|
||||||
|
|||||||
@@ -250,8 +250,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);
|
||||||
|
|
||||||
@@ -301,7 +299,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);
|
||||||
@@ -343,8 +340,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;
|
||||||
|
|
||||||
@@ -370,6 +365,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();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user