Add check for IPv6 aswell
This commit is contained in:
parent
0a01989fc6
commit
e789a1a891
1 changed files with 13 additions and 2 deletions
13
subnet.py
13
subnet.py
|
@ -13,5 +13,16 @@ def zone_is_subset(re2o_reverse_zone, network):
|
|||
>>> zone_is_subset(zone, net1)
|
||||
True
|
||||
"""
|
||||
|
||||
if network.version == 4:
|
||||
return all(ipaddress.ip_network(n).subnet_of(network) for n in
|
||||
zone["cidrs"])
|
||||
re2o_reverse_zone["cidrs"])
|
||||
|
||||
elif network.version == 6:
|
||||
if re2o_reverse_zone["prefix_v6"]:
|
||||
ipv6_prefix = re2o_reverse_zone["prefix_v6"]
|
||||
ipv6_prefix_length = re2o_reverse_zone["prefix_v6_length"]
|
||||
net6 = ipaddress.ip_network(f"{ipv6_prefix}/{ipv6_prefix_length}")
|
||||
return net6.subnet_of(network)
|
||||
else:
|
||||
return False
|
||||
|
|
Loading…
Reference in a new issue