diff --git a/discovery/IPy.py b/discovery/IPy.py index 3ed8f065..ae53f3eb 100644 --- a/discovery/IPy.py +++ b/discovery/IPy.py @@ -20,7 +20,7 @@ 127.0.0.3 >>> ip2 = IP('0x7f000000/30') >>> ip == ip2 - 1 + False >>> ip.reverseNames() ['0.0.0.127.in-addr.arpa.', '1.0.0.127.in-addr.arpa.', '2.0.0.127.in-addr.arpa.', '3.0.0.127.in-addr.arpa.'] >>> ip.reverseName() @@ -231,7 +231,7 @@ def __init__(self, data, ipversion=0): prefixlen = -1 # handling of non string values in constructor - if type(data) == int: + if isinstance(data,int): self.ip = int(data) if ipversion == 0: if self.ip < 0x100000000: @@ -628,16 +628,16 @@ def __getitem__(self, key): >>> ip=IP('127.0.0.0/30') >>> for x in ip: - ... print(hex(int(x))) + ... print(bytes(x.strHex(),encoding='UTF-8')) ... - 0x7F000000L - 0x7F000001L - 0x7F000002L - 0x7F000003L + 0x7F000000 + 0x7F000001 + 0x7F000002 + 0x7F000003 >>> hex(ip[2].int()) - '0x7F000002L' + '0x7F000002' >>> hex(ip[-1].int()) - '0x7F000003L' + '0x7F000003' """ if not isinstance(key,int): @@ -892,7 +892,7 @@ def reverseName(self): s.reverse() first_byte_index = int(4 - (self._prefixlen / 8)) if self._prefixlen % 8 != 0: - nibblepart = "%s-%s" % (s[3 - (self._prefixlen / 8)], + nibblepart = "%s-%s" % (s[3 - int(self._prefixlen / 8)], intToIp(self.ip + self.len() - 1, 4).split('.')[-1]) if nibblepart[-1] == 'l': nibblepart = nibblepart[:-1] diff --git a/discovery/dnssearch.py b/discovery/dnssearch.py index 67796a72..14495770 100644 --- a/discovery/dnssearch.py +++ b/discovery/dnssearch.py @@ -103,6 +103,7 @@ def getdns(self, domain): qtype='NS', server=primary, aa=1).req() + except Exception as e: print(e) try: