[dns-client] feature to auto set the default server address (#6787)

This commit adds a new feature in DNS client to automatically set and
update the server's IPv6 address in the default config. This is done
only when user does not explicitly set or specify the server address.
This behavior requires SRP client and its auto-start feature to be
enabled. SRP client will then monitor the Thread Network Data for
DNS/SRP Service entries to select an SRP server. The selected SRP
server address is also set as the DNS server address in the default
config.

This commit also adds `test_dns_client_config_auto_start.py` which
verifies the behavior of the new feature. In particular, that the DNS
client's default config gets changed and mirrors the SRP client
selected server address (when not set by user) and that it remains
unchanged if user explicitly sets the address in the default config.
This commit is contained in:
Abtin Keshavarzian
2021-07-12 17:25:02 -07:00
committed by GitHub
parent 75df7a26fb
commit 42d86ed832
10 changed files with 272 additions and 3 deletions
+26
View File
@@ -2487,6 +2487,32 @@ class NodeImpl:
self.send_command(cmd)
self._expect_done()
def dns_get_config(self):
"""
Returns the DNS config as a list of property dictionary (string key and string value).
Example output:
{
'Server': '[fd00:0:0:0:0:0:0:1]:1234'
'ResponseTimeout': '5000 ms'
'MaxTxAttempts': '2'
'RecursionDesired': 'no'
}
"""
cmd = f'dns config'
self.send_command(cmd)
output = self._expect_command_output(cmd)
config = {}
for line in output:
k, v = line.split(': ')
config[k] = v
return config
def dns_set_config(self, config):
cmd = f'dns config {config}'
self.send_command(cmd)
self._expect_done()
def dns_resolve(self, hostname, server=None, port=53):
cmd = f'dns resolve {hostname}'
if server is not None: