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
4 changes: 2 additions & 2 deletions tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _process_outgoing_packet(out):

# The additonals should all be suppresed since they are all in the answers section
#
assert nbr_answers == 4 and nbr_additionals == 3 and nbr_authorities == 0
assert nbr_answers == 4 and nbr_additionals == 0 and nbr_authorities == 0
nbr_answers = nbr_additionals = nbr_authorities = 0

# unregister
Expand Down Expand Up @@ -136,7 +136,7 @@ def _process_outgoing_packet(out):
_process_outgoing_packet(
zc.query_handler.response(r.DNSIncoming(query.packets()[0]), None, const._MDNS_PORT)[1]
)
assert nbr_answers == 4 and nbr_additionals == 3 and nbr_authorities == 0
assert nbr_answers == 4 and nbr_additionals == 0 and nbr_authorities == 0
nbr_answers = nbr_additionals = nbr_authorities = 0

# unregister
Expand Down
4 changes: 4 additions & 0 deletions zeroconf/_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ def _construct_outgoing_from_record_set(
"""Add answers and additionals to a DNSOutgoing."""
if not rrset[RecordSetKeys.Answers] and not rrset[RecordSetKeys.Additionals]:
return None

# Suppress any additionals that are already in answers
rrset[RecordSetKeys.Additionals] -= rrset[RecordSetKeys.Answers]

out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA, multicast=multicast, id_=self._msg.id)
for answer in rrset[RecordSetKeys.Answers]:
out.add_answer_at_time(answer, 0)
Expand Down