|
@ -218,6 +218,8 @@ def parse_response(data): |
|
|
response = DNSResponse() |
|
|
response = DNSResponse() |
|
|
if qds: |
|
|
if qds: |
|
|
response.hostname = qds[0][0] |
|
|
response.hostname = qds[0][0] |
|
|
|
|
|
for an in qds: |
|
|
|
|
|
response.questions.append((an[1], an[2], an[3])) |
|
|
for an in ans: |
|
|
for an in ans: |
|
|
response.answers.append((an[1], an[2], an[3])) |
|
|
response.answers.append((an[1], an[2], an[3])) |
|
|
return response |
|
|
return response |
|
@ -249,6 +251,7 @@ def is_valid_hostname(hostname): |
|
|
class DNSResponse(object): |
|
|
class DNSResponse(object): |
|
|
def __init__(self): |
|
|
def __init__(self): |
|
|
self.hostname = None |
|
|
self.hostname = None |
|
|
|
|
|
self.questions = [] # each: (addr, type, class) |
|
|
self.answers = [] # each: (addr, type, class) |
|
|
self.answers = [] # each: (addr, type, class) |
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
def __str__(self): |
|
@ -359,6 +362,8 @@ class DNSResolver(object): |
|
|
if ip: |
|
|
if ip: |
|
|
self._cache[hostname] = ip |
|
|
self._cache[hostname] = ip |
|
|
self._call_callback(hostname, ip) |
|
|
self._call_callback(hostname, ip) |
|
|
|
|
|
elif self._hostname_status.get(hostname, None) == STATUS_IPV6: |
|
|
|
|
|
self._call_callback(hostname, None) |
|
|
|
|
|
|
|
|
def handle_events(self, events): |
|
|
def handle_events(self, events): |
|
|
for sock, fd, event in events: |
|
|
for sock, fd, event in events: |
|
|