summaryrefslogtreecommitdiff
path: root/src/conf_mode/dns_forwarding.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-10-07 18:10:31 +0200
committerGitHub <noreply@github.com>2020-10-07 18:10:31 +0200
commit97b96aec7b94f9992920fc1fdbbe6ec3b5ffa1bb (patch)
treec262977bf685718945c9b9222af6f0a5b28f6d93 /src/conf_mode/dns_forwarding.py
parenta86c4347c214d7f74a011d1500c4cfa1fb3d854c (diff)
parente9cac63933ae9ddbb13a64406cff77640ab901dc (diff)
downloadvyos-1x-97b96aec7b94f9992920fc1fdbbe6ec3b5ffa1bb.tar.gz
vyos-1x-97b96aec7b94f9992920fc1fdbbe6ec3b5ffa1bb.zip
Merge pull request #563 from lucasec/dns-source-address
pdns_recursor: T2964: Expose query-local-address to dns config.
Diffstat (limited to 'src/conf_mode/dns_forwarding.py')
-rwxr-xr-xsrc/conf_mode/dns_forwarding.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/conf_mode/dns_forwarding.py b/src/conf_mode/dns_forwarding.py
index 5101c1e79..2187b3c73 100755
--- a/src/conf_mode/dns_forwarding.py
+++ b/src/conf_mode/dns_forwarding.py
@@ -26,6 +26,7 @@ from vyos.util import chown
from vyos.util import vyos_dict_search
from vyos.template import render
from vyos.xml import defaults
+from vyos.validate import is_ipv6
from vyos import ConfigError
from vyos import airbag
@@ -65,6 +66,21 @@ def get_config(config=None):
if conf.exists(base_nameservers_dhcp):
dns.update({'system_name_server_dhcp': conf.return_values(base_nameservers_dhcp)})
+ # Split the source_address property into separate IPv4 and IPv6 lists
+ # NOTE: In future versions of pdns-recursor (> 4.4.0), this logic can be removed
+ # as both IPv4 and IPv6 addresses can be specified in a single setting.
+ source_address_v4 = []
+ source_address_v6 = []
+
+ for source_address in dns['source_address']:
+ if is_ipv6(source_address):
+ source_address_v6.append(source_address)
+ else:
+ source_address_v4.append(source_address)
+
+ dns.update({'source_address_v4': source_address_v4})
+ dns.update({'source_address_v6': source_address_v6})
+
return dns
def verify(dns):