fix: revert wireguardutilslinux

This commit is contained in:
NickVs2015
2026-04-03 20:16:35 +03:00
parent c6a40b09c9
commit 7c075625d2
3 changed files with 5 additions and 26 deletions

View File

@@ -237,10 +237,8 @@ bool WireguardUtilsLinux::updatePeer(const InterfaceConfig& config) {
// Exclude the server address, except for multihop exit servers. // Exclude the server address, except for multihop exit servers.
if ((config.m_hopType != InterfaceConfig::MultiHopExit) && if ((config.m_hopType != InterfaceConfig::MultiHopExit) &&
(m_rtmonitor != nullptr)) { (m_rtmonitor != nullptr)) {
IPAddress v4(config.m_serverIpv4AddrIn); m_rtmonitor->addExclusionRoute(IPAddress(config.m_serverIpv4AddrIn));
if (!v4.address().isNull()) addExclusionRoute(v4); m_rtmonitor->addExclusionRoute(IPAddress(config.m_serverIpv6AddrIn));
IPAddress v6(config.m_serverIpv6AddrIn);
if (!v6.address().isNull()) addExclusionRoute(v6);
} }
int err = uapiErrno(uapiCommand(message)); int err = uapiErrno(uapiCommand(message));
@@ -254,13 +252,11 @@ bool WireguardUtilsLinux::deletePeer(const InterfaceConfig& config) {
QByteArray publicKey = QByteArray publicKey =
QByteArray::fromBase64(qPrintable(config.m_serverPublicKey)); QByteArray::fromBase64(qPrintable(config.m_serverPublicKey));
// Clear exclusion routes for this peer. // Clear exclustion routes for this peer.
if ((config.m_hopType != InterfaceConfig::MultiHopExit) && if ((config.m_hopType != InterfaceConfig::MultiHopExit) &&
(m_rtmonitor != nullptr)) { (m_rtmonitor != nullptr)) {
IPAddress v4(config.m_serverIpv4AddrIn); m_rtmonitor->deleteExclusionRoute(IPAddress(config.m_serverIpv4AddrIn));
if (!v4.address().isNull()) deleteExclusionRoute(v4); m_rtmonitor->deleteExclusionRoute(IPAddress(config.m_serverIpv6AddrIn));
IPAddress v6(config.m_serverIpv6AddrIn);
if (!v6.address().isNull()) deleteExclusionRoute(v6);
} }
QString message; QString message;
@@ -361,10 +357,6 @@ bool WireguardUtilsLinux::addExclusionRoute(const IPAddress& prefix) {
if (!m_rtmonitor) { if (!m_rtmonitor) {
return false; return false;
} }
if (++m_exclusionRefCount[prefix] > 1) {
// Route already in the kernel (added by a different caller).
return true;
}
return m_rtmonitor->addExclusionRoute(prefix); return m_rtmonitor->addExclusionRoute(prefix);
} }
@@ -372,14 +364,6 @@ bool WireguardUtilsLinux::deleteExclusionRoute(const IPAddress& prefix) {
if (!m_rtmonitor) { if (!m_rtmonitor) {
return false; return false;
} }
auto it = m_exclusionRefCount.find(prefix);
if (it == m_exclusionRefCount.end()) {
return true; // not tracked — already gone
}
if (--(*it) > 0) {
return true; // still referenced by another caller
}
m_exclusionRefCount.erase(it);
return m_rtmonitor->deleteExclusionRoute(prefix); return m_rtmonitor->deleteExclusionRoute(prefix);
} }

View File

@@ -5,7 +5,6 @@
#ifndef WIREGUARDUTILSLINUX_H #ifndef WIREGUARDUTILSLINUX_H
#define WIREGUARDUTILSLINUX_H #define WIREGUARDUTILSLINUX_H
#include <QHash>
#include <QObject> #include <QObject>
#include <QProcess> #include <QProcess>
@@ -57,7 +56,6 @@ private:
QString m_ifname; QString m_ifname;
QProcess m_tunnel; QProcess m_tunnel;
LinuxRouteMonitor* m_rtmonitor = nullptr; LinuxRouteMonitor* m_rtmonitor = nullptr;
QHash<IPAddress, int> m_exclusionRefCount;
}; };
#endif // WIREGUARDUTILSLINUX_H #endif // WIREGUARDUTILSLINUX_H

View File

@@ -9,8 +9,6 @@
#include <QObject> #include <QObject>
#include <QVariant> #include <QVariant>
#include <atomic>
class QThread; class QThread;
class LinuxNetworkWatcherWorker final : public QObject { class LinuxNetworkWatcherWorker final : public QObject {
@@ -37,7 +35,6 @@ class LinuxNetworkWatcherWorker final : public QObject {
void NMStateChanged(quint32 state); void NMStateChanged(quint32 state);
private: private:
void checkGatewayAndEmit(int generation, int count);
// We collect the list of DBus wifi network device paths during the // We collect the list of DBus wifi network device paths during the
// initialization. When a property of them changes, we check if the access // initialization. When a property of them changes, we check if the access