Made reverse zone generation work with python3.5
ipaddress does not support the reverse pointer in at least python older than 3.6
This commit is contained in:
parent
098c45e241
commit
67ec9904b2
|
@ -100,20 +100,33 @@ class ReverseZone(WhoisObject):
|
||||||
def getZone(self):
|
def getZone(self):
|
||||||
net = self.parentNet.getNetwork()
|
net = self.parentNet.getNetwork()
|
||||||
if net.version == 4:
|
if net.version == 4:
|
||||||
# for these we delegate the full domain
|
# does not work with python3.4
|
||||||
if 0 < net.prefixlen < 32 and net.prefixlen % 8 == 0:
|
## for these we delegate the full domain
|
||||||
zoneParts = net.reverse_pointer.split(".")
|
#if 0 < net.prefixlen < 32 and net.prefixlen % 8 == 0:
|
||||||
|
# zoneParts = net.reverse_pointer.split(".")
|
||||||
|
|
||||||
return ".".join(zoneParts[1:])
|
# return ".".join(zoneParts[1:])
|
||||||
|
#else:
|
||||||
|
# # return RFC2317 compliant zone
|
||||||
|
# return net.reverse_pointer
|
||||||
|
parts = list(reversed(str(net.network_address).split(".")))
|
||||||
|
domain = ".".join(parts[4 - net.prefixlen // 8:]) + ".in-addr.arpa."
|
||||||
|
if net.prefixlen % 8 == 0:
|
||||||
|
# clean cut!
|
||||||
|
return domain
|
||||||
else:
|
else:
|
||||||
# return RFC2317 compliant zone
|
# RFC2317 compliant!
|
||||||
return net.reverse_pointer
|
rfc2317Domain = "%s/%s.%s" % (parts[4 - net.prefixlen // 8 - 1], net.prefixlen, domain)
|
||||||
|
return rfc2317Domain
|
||||||
else:
|
else:
|
||||||
# ipv6
|
## does not work with python3.4
|
||||||
# thefuck ipaddress lib... _the_ _fuck_
|
## ipv6
|
||||||
zoneParts = net.reverse_pointer.split(".")[-2 - net.prefixlen // 4:]
|
## thefuck ipaddress lib... _the_ _fuck_
|
||||||
|
#zoneParts = net.reverse_pointer.split(".")[-2 - net.prefixlen // 4:]
|
||||||
|
#return ".".join(zoneParts)
|
||||||
|
|
||||||
return ".".join(zoneParts)
|
parts = list(reversed(net.exploded.split("/")[0].replace(":", "")))[32 - net.prefixlen // 4:]
|
||||||
|
return ".".join(parts) + ".ip6.arpa."
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse("domains:reversezone-show", args=(self.pk,))
|
return reverse("domains:reversezone-show", args=(self.pk,))
|
||||||
|
|
Loading…
Reference in New Issue