From cd1e561fd44c428bf5f68f76f6ec3ceee1b09879 Mon Sep 17 00:00:00 2001 From: Yaroslav Gurov <31506978+ygurov@users.noreply.github.com> Date: Thu, 19 Feb 2026 13:21:49 +0100 Subject: [PATCH] fix: add network watcher back (#2240) * feat: add reconnect in case of changing network * fix: reconnect to VPN on wakeup * fix: linux wakeup build --- client/mozilla/networkwatcher.cpp | 12 +- client/mozilla/networkwatcher.h | 6 +- client/mozilla/networkwatcherimpl.h | 2 +- .../platforms/linux/linuxnetworkwatcher.cpp | 4 +- .../linux/linuxnetworkwatcherworker.cpp | 2 +- .../linux/linuxnetworkwatcherworker.h | 2 +- client/platforms/macos/macosnetworkwatcher.mm | 4 +- .../windows/windowsnetworkwatcher.cpp | 2 +- client/protocols/wireguardprotocol.cpp | 4 +- client/protocols/xrayprotocol.cpp | 2 - client/vpnconnection.cpp | 219 ++++++++---------- client/vpnconnection.h | 16 +- ipc/ipc_interface.rep | 3 +- service/server/localserver.cpp | 4 +- 14 files changed, 122 insertions(+), 160 deletions(-) diff --git a/client/mozilla/networkwatcher.cpp b/client/mozilla/networkwatcher.cpp index c613c1067..e6e25b5ef 100644 --- a/client/mozilla/networkwatcher.cpp +++ b/client/mozilla/networkwatcher.cpp @@ -72,9 +72,9 @@ void NetworkWatcher::initialize() { connect(m_impl, &NetworkWatcherImpl::unsecuredNetwork, this, &NetworkWatcher::unsecuredNetwork); connect(m_impl, &NetworkWatcherImpl::networkChanged, this, - &NetworkWatcher::networkChange); - connect(m_impl, &NetworkWatcherImpl::sleepMode, this, - &NetworkWatcher::onSleepMode); + &NetworkWatcher::networkChanged); + connect(m_impl, &NetworkWatcherImpl::wakeup, this, + &NetworkWatcher::wakeup); m_impl->initialize(); // Enable sleep/wake monitoring for VPN auto-reconnection @@ -97,12 +97,6 @@ void NetworkWatcher::settingsChanged() { logger.debug() << "NetworkWatcher settings changed - keeping sleep monitoring active"; } -void NetworkWatcher::onSleepMode() -{ - logger.debug() << "Resumed from sleep mode"; - emit sleepMode(); -} - void NetworkWatcher::unsecuredNetwork(const QString& networkName, const QString& networkId) { logger.debug() << "Unsecured network:" << logger.sensitive(networkName) diff --git a/client/mozilla/networkwatcher.h b/client/mozilla/networkwatcher.h index f28e74fb7..527e28e28 100644 --- a/client/mozilla/networkwatcher.h +++ b/client/mozilla/networkwatcher.h @@ -29,13 +29,11 @@ public: // false to restore. void simulateDisconnection(bool simulatedDisconnection); - void onSleepMode(); - QNetworkInformation::Reachability getReachability(); signals: - void networkChange(); - void sleepMode(); + void networkChanged(); + void wakeup(); private: void settingsChanged(); diff --git a/client/mozilla/networkwatcherimpl.h b/client/mozilla/networkwatcherimpl.h index 54bd8e87d..a05c08870 100644 --- a/client/mozilla/networkwatcherimpl.h +++ b/client/mozilla/networkwatcherimpl.h @@ -41,7 +41,7 @@ signals: // TODO: Only windows-networkwatcher has this, the other plattforms should // too. void networkChanged(QString newBSSID); - void sleepMode(); + void wakeup(); private: diff --git a/client/platforms/linux/linuxnetworkwatcher.cpp b/client/platforms/linux/linuxnetworkwatcher.cpp index 22eba3c7b..11b31fa5b 100644 --- a/client/platforms/linux/linuxnetworkwatcher.cpp +++ b/client/platforms/linux/linuxnetworkwatcher.cpp @@ -41,8 +41,8 @@ void LinuxNetworkWatcher::initialize() { connect(m_worker, &LinuxNetworkWatcherWorker::unsecuredNetwork, this, &LinuxNetworkWatcher::unsecuredNetwork); - connect(m_worker, &LinuxNetworkWatcherWorker::sleepMode, this, - &NetworkWatcherImpl::sleepMode); + connect(m_worker, &LinuxNetworkWatcherWorker::wakeup, this, + &NetworkWatcherImpl::wakeup); // 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 diff --git a/client/platforms/linux/linuxnetworkwatcherworker.cpp b/client/platforms/linux/linuxnetworkwatcherworker.cpp index 247a1d67f..f7cce6bb6 100644 --- a/client/platforms/linux/linuxnetworkwatcherworker.cpp +++ b/client/platforms/linux/linuxnetworkwatcherworker.cpp @@ -200,7 +200,7 @@ void LinuxNetworkWatcherWorker::checkDevices() { void LinuxNetworkWatcherWorker::NMStateChanged(quint32 state) { if (state == NM_STATE_ASLEEP) { - emit sleepMode(); + emit wakeup(); } logger.debug() << "NMStateChanged " << state; diff --git a/client/platforms/linux/linuxnetworkwatcherworker.h b/client/platforms/linux/linuxnetworkwatcherworker.h index 9579fcefb..7c5ae5407 100644 --- a/client/platforms/linux/linuxnetworkwatcherworker.h +++ b/client/platforms/linux/linuxnetworkwatcherworker.h @@ -23,7 +23,7 @@ class LinuxNetworkWatcherWorker final : public QObject { signals: void unsecuredNetwork(const QString& networkName, const QString& networkId); - void sleepMode(); + void wakeup(); public slots: void initialize(); diff --git a/client/platforms/macos/macosnetworkwatcher.mm b/client/platforms/macos/macosnetworkwatcher.mm index 67f3a9301..c26645664 100644 --- a/client/platforms/macos/macosnetworkwatcher.mm +++ b/client/platforms/macos/macosnetworkwatcher.mm @@ -173,10 +173,10 @@ void PowerNotificationsListener::sleepWakeupCallBack(void *refParam, io_service_ case kIOMessageSystemHasPoweredOn: /* Announces that the system and its devices have woken up. */ - logger.debug() << "System has powered on - emitting sleepMode signal from dedicated CFRunLoop thread"; + logger.debug() << "System has powered on - emitting wakeup signal from dedicated CFRunLoop thread"; if (listener->m_watcher) { // Use QMetaObject::invokeMethod for thread-safe signal emission - QMetaObject::invokeMethod(listener->m_watcher, "sleepMode", Qt::QueuedConnection); + QMetaObject::invokeMethod(listener->m_watcher, "wakeup", Qt::QueuedConnection); } break; diff --git a/client/platforms/windows/windowsnetworkwatcher.cpp b/client/platforms/windows/windowsnetworkwatcher.cpp index f72baa6e2..85eb4276f 100644 --- a/client/platforms/windows/windowsnetworkwatcher.cpp +++ b/client/platforms/windows/windowsnetworkwatcher.cpp @@ -41,7 +41,7 @@ LRESULT WindowsNetworkWatcher::PowerWndProcCallback(HWND hwnd, UINT uMsg, WPARAM switch (uMsg) { case WM_POWERBROADCAST: if (wParam == PBT_APMRESUMESUSPEND) { - emit obj->sleepMode(); + emit obj->wakeup(); } break; default: diff --git a/client/protocols/wireguardprotocol.cpp b/client/protocols/wireguardprotocol.cpp index 1125731d1..2ae7ebcba 100644 --- a/client/protocols/wireguardprotocol.cpp +++ b/client/protocols/wireguardprotocol.cpp @@ -15,7 +15,7 @@ WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject * m_impl.reset(new LocalSocketController()); connect(m_impl.get(), &ControllerImpl::connected, this, [this](const QString &pubkey, const QDateTime &connectionTimestamp) { - emit connectionStateChanged(Vpn::ConnectionState::Connected); + setConnectionState(Vpn::ConnectionState::Connected); }); connect(m_impl.get(), &ControllerImpl::statusUpdated, this, [this](const QString& serverIpv4Gateway, @@ -38,7 +38,7 @@ WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject * }); connect(m_impl.get(), &ControllerImpl::disconnected, this, - [this]() { emit connectionStateChanged(Vpn::ConnectionState::Disconnected); }); + [this]() { setConnectionState(Vpn::ConnectionState::Disconnected); }); m_impl->initialize(nullptr, nullptr); } diff --git a/client/protocols/xrayprotocol.cpp b/client/protocols/xrayprotocol.cpp index 0b6de8baf..50bf829a7 100755 --- a/client/protocols/xrayprotocol.cpp +++ b/client/protocols/xrayprotocol.cpp @@ -52,7 +52,6 @@ XrayProtocol::~XrayProtocol() ErrorCode XrayProtocol::start() { qDebug() << "XrayProtocol::start()"; - setConnectionState(Vpn::ConnectionState::Connecting); return IpcClient::withInterface([&](QSharedPointer iface) { auto xrayStart = iface->xrayStart(QJsonDocument(m_xrayConfig).toJson()); @@ -69,7 +68,6 @@ ErrorCode XrayProtocol::start() void XrayProtocol::stop() { qDebug() << "XrayProtocol::stop()"; - setConnectionState(Vpn::ConnectionState::Disconnecting); IpcClient::withInterface([](QSharedPointer iface) { auto disableKillSwitch = iface->disableKillSwitch(); diff --git a/client/vpnconnection.cpp b/client/vpnconnection.cpp index afb5da7d1..e6db217ff 100644 --- a/client/vpnconnection.cpp +++ b/client/vpnconnection.cpp @@ -41,7 +41,6 @@ VpnConnection::VpnConnection(std::shared_ptr settings, QObject *parent m_checkTimer.setInterval(1000); connect(IosController::Instance(), &IosController::connectionStateChanged, this, &VpnConnection::onConnectionStateChanged); connect(IosController::Instance(), &IosController::bytesChanged, this, &VpnConnection::onBytesChanged); - #endif } @@ -59,7 +58,7 @@ void VpnConnection::onKillSwitchModeChanged(bool enabled) #ifdef AMNEZIA_DESKTOP IpcClient::withInterface([enabled](QSharedPointer iface){ QRemoteObjectPendingReply reply = iface->refreshKillSwitch(enabled); - if (reply.waitForFinished(1000) && reply.returnValue()) + if (reply.waitForFinished() && reply.returnValue()) qDebug() << "VpnConnection::onKillSwitchModeChanged: Killswitch refreshed"; else qWarning() << "VpnConnection::onKillSwitchModeChanged: Failed to execute remote refreshKillSwitch call"; @@ -73,40 +72,57 @@ void VpnConnection::onConnectionStateChanged(Vpn::ConnectionState state) auto container = m_settings->defaultContainer(m_settings->defaultServerIndex()); IpcClient::withInterface([&](QSharedPointer iface) { - if (state == Vpn::ConnectionState::Connected) { - iface->resetIpStack(); - iface->flushDns(); + switch (state) { + case Vpn::ConnectionState::Connected: { + iface->resetIpStack(); - if (!ContainerProps::isAwgContainer(container) && - container != DockerContainer::WireGuard) { - QString dns1 = m_vpnConfiguration.value(config_key::dns1).toString(); - QString dns2 = m_vpnConfiguration.value(config_key::dns2).toString(); + auto flushDns = iface->flushDns(); + if (flushDns.waitForFinished() && flushDns.returnValue()) + qDebug() << "VpnConnection::onConnectionStateChanged: Successfully flushed DNS"; + else + qWarning() << "VpnConnection::onConnectionStateChanged: Failed to clear saved routes"; - iface->routeAddList(m_vpnProtocol->vpnGateway(), QStringList() << dns1 << dns2); - if (m_settings->isSitesSplitTunnelingEnabled()) { - iface->routeDeleteList(m_vpnProtocol->vpnGateway(), QStringList() << "0.0.0.0"); - // qDebug() << "VpnConnection::onConnectionStateChanged :: adding custom routes, count:" << forwardIps.size(); - if (m_settings->routeMode() == Settings::VpnOnlyForwardSites) { - QTimer::singleShot(1000, m_vpnProtocol.data(), - [this]() { addSitesRoutes(m_vpnProtocol->vpnGateway(), m_settings->routeMode()); }); - } else if (m_settings->routeMode() == Settings::VpnAllExceptSites) { - iface->routeAddList(m_vpnProtocol->vpnGateway(), QStringList() << "0.0.0.0/1"); - iface->routeAddList(m_vpnProtocol->vpnGateway(), QStringList() << "128.0.0.0/1"); + if (!ContainerProps::isAwgContainer(container) && + container != DockerContainer::WireGuard) { + QString dns1 = m_vpnConfiguration.value(config_key::dns1).toString(); + QString dns2 = m_vpnConfiguration.value(config_key::dns2).toString(); - iface->routeAddList(m_vpnProtocol->routeGateway(), QStringList() << remoteAddress()); - addSitesRoutes(m_vpnProtocol->routeGateway(), m_settings->routeMode()); + // TODO: add error code handling for all routeAddList (or rework the code below) + iface->routeAddList(m_vpnProtocol->vpnGateway(), QStringList() << dns1 << dns2); + + if (m_settings->isSitesSplitTunnelingEnabled()) { + iface->routeDeleteList(m_vpnProtocol->vpnGateway(), QStringList() << "0.0.0.0"); + // qDebug() << "VpnConnection::onConnectionStateChanged :: adding custom routes, count:" << forwardIps.size(); + if (m_settings->routeMode() == Settings::VpnOnlyForwardSites) { + QTimer::singleShot(1000, m_vpnProtocol.data(), + [this]() { addSitesRoutes(m_vpnProtocol->vpnGateway(), m_settings->routeMode()); }); + } else if (m_settings->routeMode() == Settings::VpnAllExceptSites) { + iface->routeAddList(m_vpnProtocol->vpnGateway(), QStringList() << "0.0.0.0/1"); + iface->routeAddList(m_vpnProtocol->vpnGateway(), QStringList() << "128.0.0.0/1"); + + iface->routeAddList(m_vpnProtocol->routeGateway(), QStringList() << remoteAddress()); + addSitesRoutes(m_vpnProtocol->routeGateway(), m_settings->routeMode()); + } } } - } - } else if (state == Vpn::ConnectionState::Error) { - iface->flushDns(); + } break; + case Vpn::ConnectionState::Disconnected: + case Vpn::ConnectionState::Error: { + auto flushDns = iface->flushDns(); + if (flushDns.waitForFinished() && flushDns.returnValue()) + qDebug() << "VpnConnection::onConnectionStateChanged: Successfully flushed DNS"; + else + qWarning() << "VpnConnection::onConnectionStateChanged: Failed to flush DNS"; - if (m_settings->isSitesSplitTunnelingEnabled()) { - if (m_settings->routeMode() == Settings::VpnOnlyForwardSites) { - iface->clearSavedRoutes(); - } - } + auto clearSavedRoutes = iface->clearSavedRoutes(); + if (clearSavedRoutes.waitForFinished() && clearSavedRoutes.returnValue()) + qDebug() << "VpnConnection::onConnectionStateChanged: Successfully cleared saved routes"; + else + qWarning() << "VpnConnection::onConnectionStateChanged: Failed to clear saved routes"; + } break; + default: + break; } }); #endif @@ -120,7 +136,6 @@ void VpnConnection::onConnectionStateChanged(Vpn::ConnectionState state) m_checkTimer.stop(); } #endif - emit connectionStateChanged(state); } const QString &VpnConnection::remoteAddress() const @@ -165,7 +180,11 @@ void VpnConnection::addSitesRoutes(const QString &gw, Settings::RouteMode mode) }); m_settings->addVpnSite(mode, site, ip); } - flushDns(); + IpcClient::withInterface([](QSharedPointer iface) { + auto reply = iface->flushDns(); + if (reply.waitForFinished() || !reply.returnValue()) + qWarning() << "VpnConnection::addSitesRoutes: Failed to flush DNS"; + }); break; } } @@ -180,48 +199,6 @@ QSharedPointer VpnConnection::vpnProtocol() const return m_vpnProtocol; } -void VpnConnection::addRoutes(const QStringList &ips) -{ -#ifdef AMNEZIA_DESKTOP - IpcClient::withInterface([&](QSharedPointer iface) { - if (connectionState() == Vpn::ConnectionState::Connected) { - if (m_settings->routeMode() == Settings::VpnOnlyForwardSites) { - iface->routeAddList(m_vpnProtocol->vpnGateway(), ips); - } else if (m_settings->routeMode() == Settings::VpnAllExceptSites) { - iface->routeAddList(m_vpnProtocol->routeGateway(), ips); - } - } - }); -#endif -} - -void VpnConnection::deleteRoutes(const QStringList &ips) -{ -#ifdef AMNEZIA_DESKTOP - IpcClient::withInterface([&](QSharedPointer iface) { - if (connectionState() == Vpn::ConnectionState::Connected) { - if (m_settings->routeMode() == Settings::VpnOnlyForwardSites) { - iface->routeDeleteList(vpnProtocol()->vpnGateway(), ips); - } else if (m_settings->routeMode() == Settings::VpnAllExceptSites) { - iface->routeDeleteList(m_vpnProtocol->routeGateway(), ips); - } - } - }); -#endif -} - -void VpnConnection::flushDns() -{ -#ifdef AMNEZIA_DESKTOP - IpcClient::withInterface([](QSharedPointer iface) { - auto reply = iface->flushDns(); - if (reply.waitForFinished(1000) || !reply.returnValue()) { - qWarning() << "VpnConnection::flushDns(): Failed to flush DNS"; - } - }); -#endif -} - void VpnConnection::disconnectSlots() { if (m_vpnProtocol) { @@ -251,7 +228,7 @@ void VpnConnection::connectToVpn(int serverIndex, const ServerCredentials &crede << m_settings->routeMode(); m_remoteAddress = NetworkUtilities::getIPAddress(credentials.hostName); - emit connectionStateChanged(Vpn::ConnectionState::Connecting); + setConnectionState(Vpn::ConnectionState::Connecting); m_vpnConfiguration = vpnConfiguration; @@ -269,7 +246,7 @@ void VpnConnection::connectToVpn(int serverIndex, const ServerCredentials &crede #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) && !defined(MACOS_NE) m_vpnProtocol.reset(VpnProtocol::factory(container, m_vpnConfiguration)); if (!m_vpnProtocol) { - emit connectionStateChanged(Vpn::ConnectionState::Error); + setConnectionState(Vpn::ConnectionState::Error); return; } m_vpnProtocol->prepare(); @@ -287,17 +264,24 @@ void VpnConnection::connectToVpn(int serverIndex, const ServerCredentials &crede createProtocolConnections(); - ErrorCode errorCode = m_vpnProtocol->start(); - if (errorCode != ErrorCode::NoError) - emit connectionStateChanged(Vpn::ConnectionState::Error); + if (ErrorCode err = m_vpnProtocol->start(); err != ErrorCode::NoError) { + setConnectionState(Vpn::ConnectionState::Error); + emit vpnProtocolError(err); + } } void VpnConnection::createProtocolConnections() { connect(m_vpnProtocol.data(), &VpnProtocol::protocolError, this, &VpnConnection::vpnProtocolError); - connect(m_vpnProtocol.data(), SIGNAL(connectionStateChanged(Vpn::ConnectionState)), this, - SLOT(onConnectionStateChanged(Vpn::ConnectionState))); + connect(m_vpnProtocol.data(), &VpnProtocol::connectionStateChanged, this, &VpnConnection::setConnectionState); connect(m_vpnProtocol.data(), SIGNAL(bytesChanged(quint64, quint64)), this, SLOT(onBytesChanged(quint64, quint64))); + +#ifdef AMNEZIA_DESKTOP + IpcClient::withInterface([this](QSharedPointer rep) { + connect(rep.data(), &IpcInterfaceReplica::networkChanged, this, &VpnConnection::reconnectToVpn, Qt::QueuedConnection); + connect(rep.data(), &IpcInterfaceReplica::wakeup, this, &VpnConnection::reconnectToVpn, Qt::QueuedConnection); + }); +#endif } void VpnConnection::appendKillSwitchConfig() @@ -439,6 +423,27 @@ QString VpnConnection::bytesPerSecToText(quint64 bytes) return QString("%1 %2").arg(QString::number(mbps, 'f', 2)).arg(tr("Mbps")); // Mbit/s } +void VpnConnection::reconnectToVpn() { + if (m_vpnProtocol.isNull()) + return; + + if (m_connectionState != Vpn::ConnectionState::Connected) { + qWarning() << QString("Reconnect triggered on %1 during inappropriate state: %2; ignoring slot") + .arg(QMetaEnum::fromType().valueToKey(m_connectionState)); + return; + } + + qDebug() << "Reconnect triggered. Reconnecting to the server"; + + setConnectionState(Vpn::ConnectionState::Reconnecting); + + m_vpnProtocol->stop(); + if (ErrorCode err = m_vpnProtocol->start(); err != ErrorCode::NoError) { + setConnectionState(Vpn::ConnectionState::Error); + emit vpnProtocolError(err); + } +} + void VpnConnection::disconnectFromVpn() { #if defined(Q_OS_IOS) || defined(MACOS_NE) @@ -448,27 +453,11 @@ void VpnConnection::disconnectFromVpn() #endif if (m_vpnProtocol.isNull()) { - emit connectionStateChanged(Vpn::ConnectionState::Disconnected); + setConnectionState(Vpn::ConnectionState::Disconnected); return; } - m_vpnProtocol->stop(); - -#ifdef AMNEZIA_DESKTOP - IpcClient::withInterface([](QSharedPointer iface) { - QRemoteObjectPendingReply flushReply = iface->flushDns(); - if (flushReply.waitForFinished(5000) && flushReply.returnValue()) - qDebug() << "VpnConnection::disconnectFromVpn(): Successfully flushed DNS"; - else - qWarning() << "VpnConnection::disconnectFromVpn(): Failed to flush DNS"; - - QRemoteObjectPendingReply clearSavedRoutesReply = iface->clearSavedRoutes(); - if (clearSavedRoutesReply.waitForFinished(5000) && clearSavedRoutesReply.returnValue()) - qDebug() << "VpnConnection::disconnectFromVpn(): Successfully cleared saved routes"; - else - qWarning() << "VpnConnection::disconnectFromVpn(): Failed to clear saved routes"; - }); -#endif + setConnectionState(Vpn::ConnectionState::Disconnecting); #ifdef Q_OS_ANDROID auto *const connection = new QMetaObject::Connection; @@ -480,9 +469,10 @@ void VpnConnection::disconnectFromVpn() delete connection; } }); - m_vpnProtocol->stop(); #endif + m_vpnProtocol->stop(); + #if !defined(Q_OS_ANDROID) && !defined(AMNEZIA_DESKTOP) m_vpnProtocol->deleteLater(); #endif @@ -490,27 +480,12 @@ void VpnConnection::disconnectFromVpn() m_vpnProtocol = nullptr; } -Vpn::ConnectionState VpnConnection::connectionState() -{ - if (!m_vpnProtocol) - return Vpn::ConnectionState::Disconnected; - return m_vpnProtocol->connectionState(); -} - -bool VpnConnection::isConnected() const -{ - if (m_vpnProtocol.isNull()) { - return false; - } - - return m_vpnProtocol->isConnected(); -} - -bool VpnConnection::isDisconnected() const -{ - if (m_vpnProtocol.isNull()) { - return true; - } - - return m_vpnProtocol->isDisconnected(); +void VpnConnection::setConnectionState(Vpn::ConnectionState state) { + onConnectionStateChanged(state); + + if (state == Vpn::Disconnected && m_connectionState == Vpn::Reconnecting) + return; + + m_connectionState = state; + emit connectionStateChanged(state); } diff --git a/client/vpnconnection.h b/client/vpnconnection.h index 4d210d595..777573f26 100644 --- a/client/vpnconnection.h +++ b/client/vpnconnection.h @@ -34,10 +34,6 @@ public: ErrorCode lastError() const; - bool isConnected() const; - bool isDisconnected() const; - - Vpn::ConnectionState connectionState(); QSharedPointer vpnProtocol() const; const QString &remoteAddress() const; @@ -48,14 +44,10 @@ public: #endif public slots: - void connectToVpn(int serverIndex, - const ServerCredentials &credentials, DockerContainer container, const QJsonObject &vpnConfiguration); - + void connectToVpn(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &vpnConfiguration); + void reconnectToVpn(); void disconnectFromVpn(); - void addRoutes(const QStringList &ips); - void deleteRoutes(const QStringList &ips); - void flushDns(); void onKillSwitchModeChanged(bool enabled); void disconnectSlots(); @@ -70,6 +62,8 @@ protected slots: void onBytesChanged(quint64 receivedBytes, quint64 sentBytes); void onConnectionStateChanged(Vpn::ConnectionState state); + void setConnectionState(Vpn::ConnectionState state); + protected: QSharedPointer m_vpnProtocol; @@ -89,6 +83,8 @@ private: void createAndroidConnections(); #endif + Vpn::ConnectionState m_connectionState; + void createProtocolConnections(); void appendSplitTunnelingConfig(); diff --git a/ipc/ipc_interface.rep b/ipc/ipc_interface.rep index 90b4a67ef..f26bd8b35 100644 --- a/ipc/ipc_interface.rep +++ b/ipc/ipc_interface.rep @@ -45,5 +45,6 @@ class IpcInterface SLOT( bool stopNetworkCheck() ); SIGNAL( connectionLose() ); - SIGNAL( networkChange() ); + SIGNAL( wakeup() ); + SIGNAL( networkChanged() ); }; diff --git a/service/server/localserver.cpp b/service/server/localserver.cpp index 9fc11f6ce..26706079a 100644 --- a/service/server/localserver.cpp +++ b/service/server/localserver.cpp @@ -50,8 +50,8 @@ LocalServer::LocalServer(QObject *parent) : QObject(parent), } m_networkWatcher.initialize(); - connect(&m_networkWatcher, &NetworkWatcher::sleepMode, &m_ipcServer, &IpcServer::networkChange); - connect(&m_networkWatcher, &NetworkWatcher::networkChange, &m_ipcServer, &IpcServer::networkChange); + connect(&m_networkWatcher, &NetworkWatcher::networkChanged, &m_ipcServer, &IpcServer::networkChanged); + connect(&m_networkWatcher, &NetworkWatcher::wakeup, &m_ipcServer, &IpcServer::wakeup); KillSwitch::instance()->init(); #ifdef Q_OS_LINUX