bundlewrap/libs/bind.py
mwiegand 0a0c7cb859 wip
2021-11-07 13:30:47 +01:00

29 lines
923 B
Python

from ipaddress import ip_address
def _values_from_all_nodes(type, name, zone):
return {
value
for node in repo.nodes
for value in node.metadata.get(f'dns/{name}.{zone}/{type}', [])
}
def record_matches_view(value, type, name, zone, view, metadata):
if type not in ['A', 'AAAA']:
return True
if metadata.get(f'bind/views/{view}/is_internal'):
if ip_address(value).is_private:
return True
elif not list(filter(
lambda other_value: ip_address(other_value).is_private,
_values_from_all_nodes(type, name, zone),
)):
return True
else:
if ip_address(value).is_global:
return True
elif not list(filter(
lambda other_value: ip_address(other_value).is_global,
_values_from_all_nodes(type, name, zone),
)):
return True