diff --git a/domains/models.py b/domains/models.py index d406c50..cd4e235 100644 --- a/domains/models.py +++ b/domains/models.py @@ -100,20 +100,33 @@ class ReverseZone(WhoisObject): def getZone(self): net = self.parentNet.getNetwork() if net.version == 4: - # for these we delegate the full domain - if 0 < net.prefixlen < 32 and net.prefixlen % 8 == 0: - zoneParts = net.reverse_pointer.split(".") + # does not work with python3.4 + ## for these we delegate the full domain + #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: - # return RFC2317 compliant zone - return net.reverse_pointer + # RFC2317 compliant! + rfc2317Domain = "%s/%s.%s" % (parts[4 - net.prefixlen // 8 - 1], net.prefixlen, domain) + return rfc2317Domain else: - # ipv6 - # thefuck ipaddress lib... _the_ _fuck_ - zoneParts = net.reverse_pointer.split(".")[-2 - net.prefixlen // 4:] + ## does not work with python3.4 + ## ipv6 + ## 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): return reverse("domains:reversezone-show", args=(self.pk,))