expose already existing possibility to change the DNS servers to the DnsStub API

This commit is contained in:
Szókovács Róbert
2026-01-08 16:38:39 +01:00
parent 08e9316169
commit 96cd724f47
5 changed files with 20 additions and 0 deletions

View File

@@ -450,6 +450,12 @@ AresDns::internalInit(const std::vector<GenericIPAddress>& additionalNameservers
}
}
void
AresDns::changeNameServers(const std::vector<GenericIPAddress>& additional)
{
mAdditionalNameservers = additional;
}
bool AresDns::checkDnsChange()
{
// We must return 'true' if there are changes in the list of DNS servers

View File

@@ -37,6 +37,7 @@ class AresDns : public ExternalDns, public FdSetIOObserver
int internalInit(const std::vector<GenericIPAddress>& additionalNameservers,
AfterSocketCreationFuncPtr socketfunc, unsigned int features=0, ares_channeldata** channel = 0, int timeout=0, int tries=0);
virtual void changeNameServers(const std::vector<GenericIPAddress>& additional);
virtual bool checkDnsChange();
virtual unsigned int getTimeTillNextProcessMS();

View File

@@ -303,6 +303,17 @@ DnsStub::skipDNSQuestion(const unsigned char *aptr,
return aptr;
}
bool
DnsStub::changeNameServers(const NameserverList& additional)
{
if(mDnsProvider)
{
mDnsProvider->changeNameServers(additional);
return mDnsProvider->checkDnsChange();
}
return false;
}
bool
DnsStub::checkDnsChange()
{

View File

@@ -182,6 +182,7 @@ class DnsStub : public ExternalDnsHandler
void setDnsCacheTTL(int ttl);
void setDnsCacheSize(int size);
void reloadDnsServers();
bool changeNameServers(const NameserverList& additional);
bool checkDnsChange();
bool supportedType(int);

View File

@@ -44,6 +44,7 @@ class ExternalDns
// reinitializes with the same additionalNameservers and AfterSocketCreationFuncPtr as last call to init
virtual int init(int dnsTimeout = 0, int dnsTries = 0, unsigned int features = 0) = 0;
virtual void changeNameServers(const std::vector<GenericIPAddress>& additional) = 0;
//returns 'true' only is there are changes in the DNS server list
virtual bool checkDnsChange() = 0;