mdns-termux/tests
Andres Garcia 5e5d42f997 feat: publisher-daemon (singleton + re-announce), sync-hosts, status/stop y tests
Bloque de robustez operativa + integracion de sistema + calidad:

Publisher como servicio (lib/mdns_tools/service.py):
- `mdns publish --daemon`: daemon singleton con lock PID en
  ~/.cache/mdns/publisher.pid. Un segundo intento es rechazado -> evita el
  problema de "Termux SMB" duplicado (varios publishers compitiendo por el
  mismo nombre, que zeroconf renombra a "-2").
- Re-anuncio automatico al cambiar la IP local (WiFi<->datos, roaming):
  unregister + register con la nueva IP para que el registro no quede stale.
- Apagado limpio: maneja SIGTERM ademas de SIGINT (loop en ticks de 1s) y
  envia goodbye packets para que los clientes borren la entrada al instante.
- `mdns status` (running/host/ip/servicios/desde) y `mdns stop`.

Integracion de sistema (lib/mdns_tools/hosts.py):
- `mdns sync-hosts [--dry-run]`: escribe un bloque gestionado en
  $PREFIX/etc/hosts (o /etc/hosts) para que ping/curl/kubectl nativos
  resuelvan .local sin el wrapper `resolve`. Solo toca su propio bloque.

Refactor publish.py: expone helpers reutilizables (local_ipv4, load_config,
build_infos, register_all, unregister_all) que consume el daemon.

Tests offline (tests/, pytest, 20 casos, sin red):
- construccion/parseo de queries A, seleccion de IP ante multi-homing
  (rechazo de rangos virtuales), cache con TTL y familias, PTR reverse,
  render/strip del bloque de hosts.
- pyproject.toml con metadata, deps, extras [test] y config de pytest.

README: seccion de daemon, sync-hosts y tests; tabla RFC ampliada.
bashrc.snippet: aliases mdns-up/status/down/hosts (consolidados).
install.sh: fix de backticks; symlinks ya cubren mdns + lib via resolve().

Nota: publish.py (109) y service.py (110) exceden levemente las 100 lineas;
se dejan como modulos cohesivos de responsabilidad unica, igual que el
dispatcher CLI, para no fragmentar.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-20 12:59:10 -05:00
..
conftest.py feat: publisher-daemon (singleton + re-announce), sync-hosts, status/stop y tests 2026-07-20 12:59:10 -05:00
test_cache.py feat: publisher-daemon (singleton + re-announce), sync-hosts, status/stop y tests 2026-07-20 12:59:10 -05:00
test_pick.py feat: publisher-daemon (singleton + re-announce), sync-hosts, status/stop y tests 2026-07-20 12:59:10 -05:00
test_reverse_hosts.py feat: publisher-daemon (singleton + re-announce), sync-hosts, status/stop y tests 2026-07-20 12:59:10 -05:00
test_stdlib_resolve.py feat: publisher-daemon (singleton + re-announce), sync-hosts, status/stop y tests 2026-07-20 12:59:10 -05:00