mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-05-08 14:33:23 +00:00
* fix: add linux reconnection * fix: Dbus error, fix race conditional * fix: improve reeconnection * fix: add dns load/unload * feat: catch state changed via check gateway * revert: restore linuxfirewall.cpp * fix: restore reconnect time * fix: add NM_STATE_DISABLED and check getGatewayAndIface more carefully * fix: reconnect * fix: revert wireguardutilslinux * fix: revert
64 lines
1.8 KiB
C++
64 lines
1.8 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "linuxnetworkwatcher.h"
|
|
|
|
#include <QTimer>
|
|
|
|
#include "leakdetector.h"
|
|
#include "linuxnetworkwatcherworker.h"
|
|
#include "logger.h"
|
|
|
|
namespace {
|
|
Logger logger("LinuxNetworkWatcher");
|
|
}
|
|
|
|
LinuxNetworkWatcher::LinuxNetworkWatcher(QObject* parent)
|
|
: NetworkWatcherImpl(parent) {
|
|
MZ_COUNT_CTOR(LinuxNetworkWatcher);
|
|
|
|
m_thread.start();
|
|
}
|
|
|
|
LinuxNetworkWatcher::~LinuxNetworkWatcher() {
|
|
MZ_COUNT_DTOR(LinuxNetworkWatcher);
|
|
|
|
delete m_worker;
|
|
|
|
m_thread.quit();
|
|
m_thread.wait();
|
|
}
|
|
|
|
void LinuxNetworkWatcher::initialize() {
|
|
logger.debug() << "initialize";
|
|
|
|
m_worker = new LinuxNetworkWatcherWorker(&m_thread);
|
|
|
|
connect(this, &LinuxNetworkWatcher::checkDevicesInThread, m_worker,
|
|
&LinuxNetworkWatcherWorker::checkDevices);
|
|
|
|
connect(m_worker, &LinuxNetworkWatcherWorker::unsecuredNetwork, this,
|
|
&LinuxNetworkWatcher::unsecuredNetwork);
|
|
|
|
connect(m_worker, &LinuxNetworkWatcherWorker::wakeup, this,
|
|
&NetworkWatcherImpl::wakeup);
|
|
|
|
connect(m_worker, &LinuxNetworkWatcherWorker::networkChanged, this,
|
|
[this]() { emit networkChanged(""); });
|
|
|
|
// Let's wait a few seconds to allow the UI to be fully loaded and shown.
|
|
// This is not strictly needed, but it's better for user experience because
|
|
// it makes the UI faster to appear, plus it gives a bit of delay between the
|
|
// UI to appear and the first notification.
|
|
QTimer::singleShot(2000, this, [this]() {
|
|
QMetaObject::invokeMethod(m_worker, "initialize", Qt::QueuedConnection);
|
|
});
|
|
}
|
|
|
|
void LinuxNetworkWatcher::start() {
|
|
logger.debug() << "actived";
|
|
NetworkWatcherImpl::start();
|
|
emit checkDevicesInThread();
|
|
}
|