Formatage
This commit is contained in:
parent
4bba92b930
commit
c3ad5c3ac4
1 changed files with 5 additions and 6 deletions
11
main.py
11
main.py
|
@ -249,12 +249,12 @@ def write_dns_reverse_file(api_client):
|
|||
ns = "ns"+extension+"."
|
||||
soa_mail_fields = zone['soa']['mail'].split('@')
|
||||
soa_mail = "{}.{}.".format(soa_mail_fields[0].replace('.', '\\.'),
|
||||
soa_mail_fields[1])
|
||||
soa_mail_fields[1])
|
||||
ns_records = "\n".join(
|
||||
template_ns.format(target=x['target'])
|
||||
for x in zone['ns_records']
|
||||
)
|
||||
|
||||
|
||||
mx_records = "\n".join(
|
||||
template_mx.format(
|
||||
priority=x['priority'],
|
||||
|
@ -274,9 +274,9 @@ def write_dns_reverse_file(api_client):
|
|||
net = netaddr.IPNetwork(net)
|
||||
# on fragmente les subnets
|
||||
# dans les tailles qui vont bien.
|
||||
if net.prefixlen > 24:
|
||||
if net.prefixlen > 24:
|
||||
subnets.extend(net.subnet(32))
|
||||
elif net.prefixlen > 16:
|
||||
elif net.prefixlen > 16:
|
||||
subnets.extend(net.subnet(24))
|
||||
elif net.prefixlen > 8:
|
||||
subnets.extend(net.subnet(16))
|
||||
|
@ -327,11 +327,10 @@ def write_dns_reverse_file(api_client):
|
|||
### Continue with the ipv6 reverse
|
||||
if zone['ptr_v6_records']:
|
||||
net = netaddr.IPNetwork(zone['prefix_v6']+"/"+str(zone['prefix_v6_length']))
|
||||
net_class = max(((net.prefixlen - 1) // 4) + 1, 1)
|
||||
net_class = max(((net.prefixlen - 1) // 4) + 1, 1)
|
||||
zone6_name = ".".join(
|
||||
netaddr.IPAddress(net.first).reverse_dns.split('.')[32 - net_class:]
|
||||
)[:-1]
|
||||
|
||||
|
||||
soa = template_soa.format(
|
||||
zone=zone6_name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue