Statistic for WG/AWG protocol

This commit is contained in:
Mykola Baibuz
2024-02-23 20:31:59 +02:00
parent 3cc846678e
commit 23633e8fa7
5 changed files with 14 additions and 11 deletions
-1
View File
@@ -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)) {
+1 -5
View File
@@ -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;
}
+11
View File
@@ -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();
+2 -1
View File
@@ -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();