From e45560f763e363a8f7c899a150dfb35e618f4fa6 Mon Sep 17 00:00:00 2001 From: Franck Zoccolo Date: Wed, 5 Aug 2026 12:46:32 +0200 Subject: [PATCH] Fix SERVFAIL crash on TXT records with valueless keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit zeroconf represents a TXT attribute with no "=" (a bare boolean flag, valid per RFC 6763 ยง6.4) or an empty value as properties[key] = None. Reconstructing the TXT record blindly did b"%s=%s" % (key, None), which raises TypeError since bytes %-formatting rejects None. The exception propagated out of the deferToThread call and Twisted answered with SERVFAIL instead of the TXT record, silently breaking resolution for any service whose TXT record includes a bare key (e.g. some _rfb._tcp/screen-sharing advertisements). Found by diagnosing a real screen-sharing "impossible de resoudre" failure over a WireGuard-tunneled deployment: dig showed SRV resolving fine but TXT returning SERVFAIL for the same instance, which is why dns-sd -L (needs both) never completed even after flushing the client-side mDNSResponder cache. --- proxy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proxy.py b/proxy.py index 5ce4679..5f0a776 100644 --- a/proxy.py +++ b/proxy.py @@ -143,7 +143,8 @@ class DynamicResolver(object): order.append(kv[0]) i += length - data = [b"%s=%s" % (p, info.properties[p]) for p in sorted(info.properties, key=lambda k: order.index(k) if k in order else 1000)] + data = [(b"%s=%s" % (p, v)) if (v := info.properties[p]) is not None else p + for p in sorted(info.properties, key=lambda k: order.index(k) if k in order else 1000)] now = current_time_millis() cached = self.zeroconf.cache.get_by_details(localname, _TYPE_TXT, _CLASS_IN) record_ttl = int(cached.get_remaining_ttl(now)) if cached else ttl