Fixing query_client failing with IPv6

* Change query_client to use rsplit to split ip
  to make sure we can handle IPv6 addresses.

* Strip brackets from ip address to make sure dig
  does not fail if the IPv6 is uri formatted.

Change-Id: I2619fab9eb7e35579566cac70e2e718dae474be0
This commit is contained in:
Erik Olof Gunnar Andersson 2019-08-23 17:19:58 -07:00
parent e57bcbb1ca
commit 1096ab9889
1 changed files with 2 additions and 2 deletions

View File

@ -60,7 +60,7 @@ class SingleQueryClient(object):
@classmethod
def _dig(cls, name, rdatatype, ip, port, timeout):
query = cls._prepare_query(name, rdatatype)
return dns.query.udp(query, ip, port=port, timeout=timeout)
return dns.query.udp(query, ip.strip('[]'), port=port, timeout=timeout)
class Nameserver(object):
@ -78,6 +78,6 @@ class Nameserver(object):
@classmethod
def from_str(self, nameserver):
if ':' in nameserver:
ip, port = nameserver.split(':')
ip, port = nameserver.rsplit(':', 1)
return Nameserver(ip, int(port))
return Nameserver(nameserver)