Offer secure (HTTPS) and unsecured (HTTP) access side by side, add a QR codes page

Optional plain HTTP port next to HTTPS (server.http_port, off by default):
- open_sites()/serve() replace web.run_app: one AppRunner, two TCPSites, so the
  tablet picks https://<ip>:8765 or http://<ip>:8766 without a restart
- http_port requires TLS and must differ from port (validated in config.py)
- make http-on / http-off (--http-port N) write or remove the line, restoring
  the file if the result is invalid; make firewall accepts HTTP_PORT
- make url prints both addresses and QR codes

QR codes page (make qr, --qr):
- self-contained HTML written with mode 600 in $XDG_RUNTIME_DIR and opened as
  file://, never served: the codes contain the access token
- qrencode SVG with crispEdges (no seams between modules), fr/en from LANG
- cards for HTTPS, HTTP and the CA certificate, depending on the config

Tests: 107 (dual listeners with the local CA, set_http_port, QR page content
and file mode). Docs: README fr/en and CLAUDE.md updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Denis
2026-10-26 11:55:50 +01:00
parent e823b2d470
commit 27c8eeb37c
14 changed files with 726 additions and 27 deletions
+20
View File
@@ -64,6 +64,26 @@ class ParseConfigTest(unittest.TestCase):
with self.subTest(server=server), self.assertRaises(ConfigError):
parse_config({"server": {"token": TOKEN, **server}})
def test_http_port_is_off_by_default(self) -> None:
self.assertEqual(parse_config({"server": {"token": TOKEN}}).http_port, 0)
def test_http_port_next_to_tls(self) -> None:
server = {"token": TOKEN, "tls_cert": "/c.pem", "tls_key": "/k.key", "http_port": 8766}
self.assertEqual(parse_config({"server": server}).http_port, 8766)
def test_http_port_is_validated(self) -> None:
tls = {"tls_cert": "/c.pem", "tls_key": "/k.key"}
for server in (
{"http_port": 8766}, # sans TLS, `port` sert déjà du HTTP en clair
{**tls, "http_port": 8765}, # même port que le HTTPS
{**tls, "http_port": 70000},
{**tls, "http_port": -1},
{**tls, "http_port": "8766"},
{**tls, "http_port": True},
):
with self.subTest(server=server), self.assertRaises(ConfigError):
parse_config({"server": {"token": TOKEN, **server}})
def test_max_volume_bounds(self) -> None:
with self.assertRaises(ConfigError):
parse_config({"server": {"token": TOKEN}, "audio": {"max_volume": 3}})