diff --git a/client/platforms/linux/daemon/linuxroutemonitor.cpp b/client/platforms/linux/daemon/linuxroutemonitor.cpp index 39926f23..eaf5bcd8 100644 --- a/client/platforms/linux/daemon/linuxroutemonitor.cpp +++ b/client/platforms/linux/daemon/linuxroutemonitor.cpp @@ -164,8 +164,13 @@ bool LinuxRouteMonitor::rtmSendRoute(int action, int flags, int type, } if (rtm->rtm_type == RTN_THROW) { + QString gateway = NetworkUtilities::getGatewayAndIface().first; + if (gateway.isEmpty()) { + logger.warning() << "No default gateway available, skipping exclusion route"; + return false; + } struct in_addr ip4; - inet_pton(AF_INET, NetworkUtilities::getGatewayAndIface().first.toUtf8(), &ip4); + inet_pton(AF_INET, gateway.toUtf8(), &ip4); nlmsg_append_attr(nlmsg, sizeof(buf), RTA_GATEWAY, &ip4, sizeof(ip4)); nlmsg_append_attr32(nlmsg, sizeof(buf), RTA_PRIORITY, 0); rtm->rtm_type = RTN_UNICAST; diff --git a/client/platforms/linux/linuxnetworkwatcher.cpp b/client/platforms/linux/linuxnetworkwatcher.cpp index 11b31fa5..b27eae83 100644 --- a/client/platforms/linux/linuxnetworkwatcher.cpp +++ b/client/platforms/linux/linuxnetworkwatcher.cpp @@ -44,6 +44,9 @@ void LinuxNetworkWatcher::initialize() { 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 diff --git a/client/platforms/linux/linuxnetworkwatcherworker.cpp b/client/platforms/linux/linuxnetworkwatcherworker.cpp index f7cce6bb..ca3f7c1b 100644 --- a/client/platforms/linux/linuxnetworkwatcherworker.cpp +++ b/client/platforms/linux/linuxnetworkwatcherworker.cpp @@ -37,6 +37,7 @@ enum NMState { NM_STATE_UNKNOWN = 0, NM_STATE_ASLEEP = 10, + NM_STATE_DISABLED = 10, NM_STATE_DISCONNECTED = 20, NM_STATE_DISCONNECTING = 30, NM_STATE_CONNECTING = 40, @@ -199,10 +200,11 @@ void LinuxNetworkWatcherWorker::checkDevices() { void LinuxNetworkWatcherWorker::NMStateChanged(quint32 state) { - if (state == NM_STATE_ASLEEP) { - emit wakeup(); - } - - logger.debug() << "NMStateChanged " << state; -} + logger.debug() << "NMStateChanged " << state; + if (state == NM_STATE_ASLEEP || state == NM_STATE_DISABLED) { + emit wakeup(); + } else if (state == NM_STATE_CONNECTED_GLOBAL) { + emit networkChanged(); + } +} \ No newline at end of file diff --git a/client/platforms/linux/linuxnetworkwatcherworker.h b/client/platforms/linux/linuxnetworkwatcherworker.h index 7c5ae540..8dead74d 100644 --- a/client/platforms/linux/linuxnetworkwatcherworker.h +++ b/client/platforms/linux/linuxnetworkwatcherworker.h @@ -24,6 +24,7 @@ class LinuxNetworkWatcherWorker final : public QObject { signals: void unsecuredNetwork(const QString& networkName, const QString& networkId); void wakeup(); + void networkChanged(); public slots: void initialize();