From ba08187c069da93c943935ef60a78b506c035af0 Mon Sep 17 00:00:00 2001 From: Jernej Jakob Date: Thu, 11 Jun 2020 08:32:33 +0200 Subject: dns forwarding: T2486: change internal representation of 'domain' config Change internal representation to the new one expected by vyos-hostsd. --- src/conf_mode/dns_forwarding.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/conf_mode/dns_forwarding.py b/src/conf_mode/dns_forwarding.py index aedfb2623..36e2abb4a 100755 --- a/src/conf_mode/dns_forwarding.py +++ b/src/conf_mode/dns_forwarding.py @@ -41,7 +41,7 @@ default_config_data = { 'listen_address': [], 'name_servers': [], 'negative_ttl': 3600, - 'domains': [], + 'domains': {}, 'dnssec': 'process-no-validate' } @@ -67,13 +67,16 @@ def get_config(conf): dns['negative_ttl'] = negative_ttl if conf.exists(['domain']): - for node in conf.list_nodes(['domain']): - servers = conf.return_values(['domain', node, 'server']) - domain = { - "name": node, - "servers": bracketize_ipv6_addrs(servers) + for domain in conf.list_nodes(['domain']): + conf.set_level(base + ['domain', domain]) + entry = { + 'nslist': bracketize_ipv6_addrs(conf.return_values(['server'])), + 'addNTA': conf.exists(['addnta']), + 'recursion-desired': conf.exists(['recursion-desired']) } - dns['domains'].append(domain) + dns['domains'][domain] = entry + + conf.set_level(base) if conf.exists(['ignore-hosts-file']): dns['export_hosts_file'] = "no" @@ -136,9 +139,9 @@ def verify(conf, dns): if dns['domains']: for domain in dns['domains']: - if not domain['servers']: - raise ConfigError( - 'Error: No server configured for domain {0}'.format(domain['name'])) + if not dns['domains'][domain]['nslist']: + raise ConfigError(( + f'Error: No server configured for domain {domain}')) return None -- cgit v1.2.3