mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-05-08 14:33:23 +00:00
fix: add dns load/unload
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user