fix: add dns load/unload

This commit is contained in:
NickVs2015
2026-03-31 23:01:37 +03:00
parent 214b18f65f
commit af0d561c5c
2 changed files with 3 additions and 9 deletions

View File

@@ -59,9 +59,9 @@ bool DnsUtilsLinux::updateResolvers(const QString& ifname,
return false;
}
m_resolvers = resolvers;
setLinkDNS(m_ifindex, resolvers);
setLinkDefaultRoute(m_ifindex, true);
setLinkDomains(m_ifindex, {DnsLinkDomain(".", true)});
updateLinkDomains();
return true;
}
@@ -175,18 +175,13 @@ void DnsUtilsLinux::updateLinkDomains() {
}
void DnsUtilsLinux::dnsDomainsReceived(QDBusPendingCallWatcher* call) {
QDBusPendingReply<QVariant> reply = *call;
delete call;
QDBusPendingReply<QVariant> reply = *call;
call->deleteLater();
if (reply.isError()) {
// systemd-resolved may still be starting up after a restart — retry a few times
if (m_domainRetries++ < 5) {
logger.debug() << "systemd-resolved not ready yet, retrying DNS setup ("
<< m_domainRetries << "/5)";
// Re-apply DNS servers and default route in case systemd-resolved lost them on restart
if (m_ifindex > 0 && !m_resolvers.isEmpty()) {
setLinkDNS(m_ifindex, m_resolvers);
setLinkDefaultRoute(m_ifindex, true);
}
QTimer::singleShot(500, this, &DnsUtilsLinux::updateLinkDomains);
} else {
logger.warning() << "Failed to configure DNS after 5 retries";

View File

@@ -35,7 +35,6 @@ class DnsUtilsLinux final : public DnsUtils {
private:
int m_ifindex = 0;
int m_domainRetries = 0;
QList<QHostAddress> m_resolvers;
QMap<int, DnsLinkDomainList> m_linkDomains;
QDBusInterface* m_resolver = nullptr;
};