diff options
author | Jernej Jakob <jernej.jakob@gmail.com> | 2020-06-11 08:32:33 +0200 |
---|---|---|
committer | Jernej Jakob <jernej.jakob@gmail.com> | 2020-06-11 22:10:47 +0200 |
commit | ba08187c069da93c943935ef60a78b506c035af0 (patch) | |
tree | cdf869961ceac5835ffa9bf1305fb05840c52b0e /src/conf_mode/dns_forwarding.py | |
parent | 1eaf0077f2b42405d9bf8699dcf813c1b249d6fc (diff) | |
download | vyos-1x-ba08187c069da93c943935ef60a78b506c035af0.tar.gz vyos-1x-ba08187c069da93c943935ef60a78b506c035af0.zip |
dns forwarding: T2486: change internal representation of 'domain' config
Change internal representation to the new one expected by vyos-hostsd.
Diffstat (limited to 'src/conf_mode/dns_forwarding.py')
-rwxr-xr-x | src/conf_mode/dns_forwarding.py | 23 |
1 files changed, 13 insertions, 10 deletions
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 |