From 40d09b7ad1bb5e785b7c8be3f04ac923043545ca Mon Sep 17 00:00:00 2001 From: Christoph Brand <> Date: Tue, 4 Oct 2022 09:07:13 +0200 Subject: [PATCH] fix: skip null txt record Do not try to send a txt record when information for sending it out is missing. Before this if there was a TXT record request it did raise an Exception instead of just not returning the information. --- src/mdns_client/responder.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mdns_client/responder.py b/src/mdns_client/responder.py index 37ffef5..e64a702 100644 --- a/src/mdns_client/responder.py +++ b/src/mdns_client/responder.py @@ -169,8 +169,12 @@ def _on_txt_question(self, question: DNSQuestion) -> None: if service is None: return + txt_record = self._txt_record_for(service) + if txt_record is None: + return + self._dprint("Responding to DNS TXT question for {}".format(query)) - srv_answers = [self._txt_record_for(service)] + srv_answers = [txt_record] self._send_response(srv_answers) def _get_service_of(self, query: str) -> "Optional[str]":