Commit Graph
15 Commits
Author SHA1 Message Date
franck e45560f763 Fix SERVFAIL crash on TXT records with valueless keys
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.
2026-08-05 12:46:32 +02:00
franck 8270d2d7ca Add continuous querying and caching
Replace one-shot, blind-sleep mDNS lookups with a warm cache backed by
persistent background queriers:

- PTR (browse): a single ServiceBrowser tracks every service type seen
  so far (recreated with the enlarged type set when a new one shows
  up, rather than one browser per type), so zeroconf continuously
  refreshes it in the background; answers are read straight from the
  mDNS cache instead of blocking timeout seconds on every query.
- TXT/SRV: still resolved via get_service_info() (already cache-first
  internally), but a background job now periodically re-primes the
  cache so it doesn't go cold between queries.
- A/AAAA (bare hostnames): answers are read from the mDNS cache first;
  only a first-ever query for a name blocks waiting for a response,
  with a background job keeping it warm afterwards.

Periodic refresh jobs are scheduled by a single heap-based scheduler
thread and executed by a fixed pool of 4 worker threads, so the
background thread count stays constant no matter how many distinct
names/services get queried over the proxy's lifetime.

All returned TTLs now reflect the real remaining TTL of the underlying
mDNS record instead of a fixed constant, and goodbye packets (TTL=0)
are handled for free since eviction is delegated to zeroconf's own
cache.

Also add .gitignore for the project-local .venv/ and __pycache__/.
2026-08-05 11:32:18 +02:00
franck fc8b0bfffd Add negative response handling (RFC 2308)
Synthesize an SOA record for the zone, return it for direct SOA
queries, and include it in the authority section of empty responses
so resolvers can negative-cache properly. RCODE stays NOERROR rather
than NXDOMAIN, since mDNS can't reliably prove non-existence.
2026-08-05 11:01:18 +02:00
franck 006f2cfa89 Restrict published IPv6 addresses to ULA range
Only return AAAA/glue records within fc00::/7, filtering out public
IPv6 addresses in addition to link-local ones.
2026-08-05 10:44:51 +02:00
franck 0fa23ae378 Add IPv6 support
Enable dual-stack mDNS lookups (Zeroconf ip_version was set to a value
that matched no IPVersion member), add AAAA query handling, and include
AAAA glue records for SRV targets. Link-local IPv6/IPv4 addresses are
filtered out since they aren't usable by clients off the local link.
2026-08-05 10:22:32 +02:00
Michael Kuron 159b193cb7 Compatibility with different python-zeroconf versions 2024-03-10 14:23:07 +01:00
Michael Kuron 9cd06d86cf strip additional records before truncating the message 2021-02-28 22:46:29 +01:00
Michael Kuron be42b16652 Fix AirPrint
- Keep TXT record order
- Force replies with more than 512 bytes to go over TCP
2021-02-24 18:50:25 +01:00
Michael Kuron 33762575b6 fix _device-info._tcp 2021-01-24 09:48:23 +01:00
Michael Kuron 020f430194 Don't produce error if get_service_info fails 2020-09-05 12:52:32 +02:00
Michael Kuron 687d9a742a A 2020-08-02 23:01:58 +02:00
Michael Kuron 641276272f SRV with additional 2020-08-02 22:40:58 +02:00
Michael Kuron d244c7caec TXT 2020-08-02 22:20:51 +02:00
Michael Kuron 2a260313de progress 2020-08-02 19:48:23 +02:00
Michael Kuron ad7d2c9f05 rough draft 2020-08-02 17:31:50 +02:00