mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-21 02:01:03 +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() {
|
||||
Q_ASSERT(wgutils() != nullptr);
|
||||
QJsonObject json;
|
||||
logger.debug() << "Status request";
|
||||
|
||||
if (!wgutils()->interfaceExists() || m_connections.isEmpty()) {
|
||||
json.insert("connected", QJsonValue(false));
|
||||
|
||||
@@ -46,8 +46,6 @@ DaemonLocalServerConnection::~DaemonLocalServerConnection() {
|
||||
}
|
||||
|
||||
void DaemonLocalServerConnection::readData() {
|
||||
logger.debug() << "Read Data";
|
||||
|
||||
Q_ASSERT(m_socket);
|
||||
|
||||
while (true) {
|
||||
@@ -90,8 +88,6 @@ void DaemonLocalServerConnection::parseCommand(const QByteArray& data) {
|
||||
}
|
||||
QString type = typeValue.toString();
|
||||
|
||||
logger.debug() << "Command received:" << type;
|
||||
|
||||
if (type == "activate") {
|
||||
InterfaceConfig config;
|
||||
if (!Daemon::parseConfig(obj, config)) {
|
||||
|
||||
@@ -250,8 +250,6 @@ void LocalSocketController::deactivate() {
|
||||
}
|
||||
|
||||
void LocalSocketController::checkStatus() {
|
||||
logger.debug() << "Check status";
|
||||
|
||||
if (m_daemonState == eReady || m_daemonState == eInitializing) {
|
||||
Q_ASSERT(m_socket);
|
||||
|
||||
@@ -301,7 +299,6 @@ void LocalSocketController::cleanupBackendLogs() {
|
||||
}
|
||||
|
||||
void LocalSocketController::readData() {
|
||||
logger.debug() << "Reading";
|
||||
|
||||
Q_ASSERT(m_socket);
|
||||
Q_ASSERT(m_daemonState == eInitializing || m_daemonState == eReady);
|
||||
@@ -343,8 +340,6 @@ void LocalSocketController::parseCommand(const QByteArray& command) {
|
||||
}
|
||||
QString type = typeValue.toString();
|
||||
|
||||
logger.debug() << "Parse command:" << type;
|
||||
|
||||
if (m_daemonState == eInitializing && type == "status") {
|
||||
m_daemonState = eReady;
|
||||
|
||||
@@ -370,6 +365,7 @@ void LocalSocketController::parseCommand(const QByteArray& command) {
|
||||
}
|
||||
|
||||
emit initialized(true, connected.toBool(), datetime);
|
||||
checkStatus();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,20 @@ WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject *
|
||||
});
|
||||
connect(m_impl.get(), &ControllerImpl::disconnected, this,
|
||||
[this]() { emit connectionStateChanged(Vpn::ConnectionState::Disconnected); });
|
||||
|
||||
connect(m_impl.get(), &ControllerImpl::statusUpdated, this,
|
||||
&WireguardProtocol::statusUpdated);
|
||||
|
||||
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::stop();
|
||||
|
||||
@@ -21,7 +21,8 @@ public:
|
||||
|
||||
ErrorCode start() override;
|
||||
void stop() override;
|
||||
|
||||
void statusUpdated(const QString& serverIpv4Gateway, const QString& deviceIpv4Address,
|
||||
uint64_t txBytes, uint64_t rxBytes);
|
||||
ErrorCode startMzImpl();
|
||||
ErrorCode stopMzImpl();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user