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
25 changes: 25 additions & 0 deletions tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,31 @@ def test_ptr_optimization():
zc.close()


def test_any_query_for_ptr():
"""Test that queries for ANY will return PTR records."""
zc = Zeroconf(interfaces=['127.0.0.1'])
type_ = "_knownservice._tcp.local."
name = "knownname"
registration_name = "%s.%s" % (name, type_)
desc = {'path': '/~paulsm/'}
server_name = "ash-2.local."
ipv6_address = socket.inet_pton(socket.AF_INET6, "2001:db8::1")
info = ServiceInfo(type_, registration_name, 80, 0, 0, desc, server_name, addresses=[ipv6_address])
zc.register_service(info)

_clear_cache(zc)
generated = r.DNSOutgoing(const._FLAGS_QR_QUERY)
question = r.DNSQuestion(type_, const._TYPE_ANY, const._CLASS_IN)
generated.add_question(question)
packets = generated.packets()
_, multicast_out = zc.query_handler.response(r.DNSIncoming(packets[0]), "1.2.3.4", const._MDNS_PORT)
assert multicast_out.answers[0][0].name == type_
assert multicast_out.answers[0][0].alias == registration_name
# unregister
zc.unregister_service(info)
zc.close()


def test_aaaa_query():
"""Test that queries for AAAA records work."""
zc = Zeroconf(interfaces=['127.0.0.1'])
Expand Down
2 changes: 1 addition & 1 deletion zeroconf/_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _answer_question(
additionals: Set[DNSRecord] = set()
type_ = question.type

if type_ == _TYPE_PTR:
if type_ in (_TYPE_PTR, _TYPE_ANY):
self._add_pointer_answers(question.name, msg, answers, additionals)

if type_ in (_TYPE_A, _TYPE_AAAA, _TYPE_ANY):
Expand Down