bundlewrap/libs/dns.py
mwiegand 1481a99ae0 wip
2021-07-12 21:00:33 +02:00

23 lines
611 B
Python

from ipaddress import ip_interface
def get_a_records(metadata, internal=True, external=True):
networks = metadata.get('network')
if not internal:
networks.pop('internal', None)
if not external:
networks.pop('external', None)
return {
'A': [
str(ip_interface(network['ipv4']).ip)
for network in networks.values()
if 'ipv4' in network
],
'AAAA': [
str(ip_interface(network['ipv6']).ip)
for network in networks.values()
if 'ipv6' in network
],
}