From 1eaf0077f2b42405d9bf8699dcf813c1b249d6fc Mon Sep 17 00:00:00 2001 From: Jernej Jakob Date: Thu, 11 Jun 2020 08:24:06 +0200 Subject: dns forwarding: T2486: move Config() call into main As Config is required in both get_config and verify, init it once and pass it to both functions. --- src/conf_mode/dns_forwarding.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/dns_forwarding.py b/src/conf_mode/dns_forwarding.py index 188a39ef0..aedfb2623 100755 --- a/src/conf_mode/dns_forwarding.py +++ b/src/conf_mode/dns_forwarding.py @@ -46,9 +46,8 @@ default_config_data = { } -def get_config(): +def get_config(conf): dns = deepcopy(default_config_data) - conf = Config() base = ['service', 'dns', 'forwarding'] if not conf.exists(base): @@ -122,7 +121,7 @@ def bracketize_ipv6_addrs(addrs): """Wraps each IPv6 addr in addrs in [], leaving IPv4 addrs untouched.""" return ['[{0}]'.format(a) if a.count(':') > 1 else a for a in addrs] -def verify(dns): +def verify(conf, dns): # bail out early - looks like removal from running config if dns is None: return None @@ -164,8 +163,9 @@ if __name__ == '__main__': try: - c = get_config() - verify(c) + conf = Config() + c = get_config(conf) + verify(conf, c) generate(c) apply(c) except ConfigError as e: -- cgit v1.2.3