Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating for Python3 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions dnsrev.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
############################### DEPENDENCIES ###############################
# If it doesn't run properly, make sure you have the dnspython and ipaddr
# Python modules installed, and named-compilezones. On Debian systems, just
# apt-get install python-ipaddr python-dnspython bind9utils
# apt-get install python3-dns bind9utils
#
# For Red Hat dependencies:
# dnf install python3-dns bind-utils

import dns.reversename
import getopt
import ipaddr
import ipaddress
import os
import re
import subprocess
Expand Down Expand Up @@ -156,7 +159,7 @@ def mktemp(self):
fn, sn = zone[0:2]
o = ZoneFile(fn)
o.sn = sn
o.sno = ipaddr.IPNetwork(sn)
o.sno = ipaddress.ip_network(sn)
if len(zone) > 2:
o.zone = zone[2]
else:
Expand Down Expand Up @@ -214,7 +217,7 @@ def mktemp(self):

name, _, address = m.groups()
for f in rev_files:
if ipaddr.IPNetwork(address) in f.sno:
if ipaddress.ip_network(address) in f.sno:
if f.sno.ip.version == 4 and f.sno.prefixlen > 24:
label = "%s.%s" % (address.split(".")[3], f.zone)
else:
Expand Down