Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/zeroconf/_dns.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,5 @@ cdef class DNSRRSet:
record_sets=cython.list,
)
cdef cython.dict _get_lookup(self)

cpdef cython.set lookup_set(self)
6 changes: 5 additions & 1 deletion src/zeroconf/_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import enum
import socket
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Union, cast

from ._exceptions import AbstractMethodException
from ._utils.net import _is_v6_address
Expand Down Expand Up @@ -533,6 +533,10 @@ def lookup(self) -> Dict[DNSRecord, float]:
"""Return the lookup table."""
return self._get_lookup()

def lookup_set(self) -> Set[DNSRecord]:
"""Return the lookup table as aset."""
return set(self._get_lookup())

def _get_lookup(self) -> Dict[DNSRecord, float]:
"""Return the lookup table, building it if needed."""
if self._lookup is None:
Expand Down
4 changes: 2 additions & 2 deletions src/zeroconf/_handlers/query_handler.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ cdef class QueryHandler:
cdef _add_address_answers(self, str lower_name, cython.dict answer_set, DNSRRSet known_answers, cython.uint type_)

@cython.locals(question_lower_name=str, type_=cython.uint, service=ServiceInfo)
cdef _answer_question(self, DNSQuestion question, DNSRRSet known_answers)
cdef cython.dict _answer_question(self, DNSQuestion question, DNSRRSet known_answers)

@cython.locals(
msg=DNSIncoming,
Expand All @@ -68,4 +68,4 @@ cdef class QueryHandler:
known_answers=DNSRRSet,
known_answers_set=cython.set,
)
cpdef async_response(self, cython.list msgs, object unicast_source)
cpdef async_response(self, cython.list msgs, cython.bint unicast_source)
6 changes: 3 additions & 3 deletions src/zeroconf/_handlers/query_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ def async_response( # pylint: disable=unused-argument

for msg in msgs:
for question in msg.questions:
if not question.unicast:
if not question.unique: # unique and unicast are the same flag
if not known_answers_set: # pragma: no branch
known_answers_set = set(known_answers.lookup)
known_answers_set = known_answers.lookup_set()
self.question_history.add_question_at_time(question, msg.now, known_answers_set)
answer_set = self._answer_question(question, known_answers)
if not ucast_source and question.unicast:
if not ucast_source and question.unique: # unique and unicast are the same flag
query_res.add_qu_question_response(answer_set)
continue
if ucast_source:
Expand Down