mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-24 02:00:24 +07:00
fix: add dns load/unload
This commit is contained in:
@@ -59,9 +59,9 @@ bool DnsUtilsLinux::updateResolvers(const QString& ifname,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_resolvers = resolvers;
|
|
||||||
setLinkDNS(m_ifindex, resolvers);
|
setLinkDNS(m_ifindex, resolvers);
|
||||||
setLinkDefaultRoute(m_ifindex, true);
|
setLinkDefaultRoute(m_ifindex, true);
|
||||||
|
setLinkDomains(m_ifindex, {DnsLinkDomain(".", true)});
|
||||||
updateLinkDomains();
|
updateLinkDomains();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -176,17 +176,12 @@ void DnsUtilsLinux::updateLinkDomains() {
|
|||||||
|
|
||||||
void DnsUtilsLinux::dnsDomainsReceived(QDBusPendingCallWatcher* call) {
|
void DnsUtilsLinux::dnsDomainsReceived(QDBusPendingCallWatcher* call) {
|
||||||
QDBusPendingReply<QVariant> reply = *call;
|
QDBusPendingReply<QVariant> reply = *call;
|
||||||
delete call;
|
call->deleteLater();
|
||||||
if (reply.isError()) {
|
if (reply.isError()) {
|
||||||
// systemd-resolved may still be starting up after a restart — retry a few times
|
// systemd-resolved may still be starting up after a restart — retry a few times
|
||||||
if (m_domainRetries++ < 5) {
|
if (m_domainRetries++ < 5) {
|
||||||
logger.debug() << "systemd-resolved not ready yet, retrying DNS setup ("
|
logger.debug() << "systemd-resolved not ready yet, retrying DNS setup ("
|
||||||
<< m_domainRetries << "/5)";
|
<< 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);
|
QTimer::singleShot(500, this, &DnsUtilsLinux::updateLinkDomains);
|
||||||
} else {
|
} else {
|
||||||
logger.warning() << "Failed to configure DNS after 5 retries";
|
logger.warning() << "Failed to configure DNS after 5 retries";
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ class DnsUtilsLinux final : public DnsUtils {
|
|||||||
private:
|
private:
|
||||||
int m_ifindex = 0;
|
int m_ifindex = 0;
|
||||||
int m_domainRetries = 0;
|
int m_domainRetries = 0;
|
||||||
QList<QHostAddress> m_resolvers;
|
|
||||||
QMap<int, DnsLinkDomainList> m_linkDomains;
|
QMap<int, DnsLinkDomainList> m_linkDomains;
|
||||||
QDBusInterface* m_resolver = nullptr;
|
QDBusInterface* m_resolver = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user