MCPcopy
hub / github.com/shadowsocks/shadowsocks / _handle_data

Method _handle_data

shadowsocks/asyncdns.py:345–368  ·  view source on GitHub ↗
(self, data)

Source from the content-addressed store, hash-verified

343 del self._hostname_status[hostname]
344
345 def _handle_data(self, data):
346 response = parse_response(data)
347 if response and response.hostname:
348 hostname = response.hostname
349 ip = None
350 for answer in response.answers:
351 if answer[1] in (QTYPE_A, QTYPE_AAAA) and \
352 answer[2] == QCLASS_IN:
353 ip = answer[0]
354 break
355 if not ip and self._hostname_status.get(hostname, STATUS_SECOND) \
356 == STATUS_FIRST:
357 self._hostname_status[hostname] = STATUS_SECOND
358 self._send_req(hostname, self._QTYPES[1])
359 else:
360 if ip:
361 self._cache[hostname] = ip
362 self._call_callback(hostname, ip)
363 elif self._hostname_status.get(hostname, None) \
364 == STATUS_SECOND:
365 for question in response.questions:
366 if question[1] == self._QTYPES[1]:
367 self._call_callback(hostname, None)
368 break
369
370 def handle_event(self, sock, fd, event):
371 if sock != self._sock:

Callers 1

handle_eventMethod · 0.95

Calls 4

_send_reqMethod · 0.95
_call_callbackMethod · 0.95
parse_responseFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected