From 2892e39c7125f5632563e4ad550d0bad45cbfd09 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 26 Oct 2026 17:30:06 +0100 Subject: [PATCH] Installation: tell VPN users to set advertise_host before make cert make url, make qr and make cert take the PC address from the default route, which goes through the tunnel when a VPN is active (e.g. 10.2.0.2 with Proton VPN's WireGuard); the QR code then points to an address the tablet cannot reach and the HTTPS certificate is issued for it. The README (fr/en) installation steps, the example config and CLAUDE.md now say to put the PC's local-network address in server.advertise_host before make cert, how to find it (ip -4 -br addr), and that rerunning make cert afterwards reissues the server certificate while keeping the CA. Co-Authored-By: Claude Sonnet 5.5 --- CLAUDE.md | 2 +- README-EN.md | 18 +++++++++++++++++- README.md | 18 +++++++++++++++++- config.example.toml | 6 ++++-- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 0f70a0a..46491aa 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -211,7 +211,7 @@ Vérifié : - Les applications installées sont lancées par `gio launch` (paquet `libglib2.0-bin`, ajouté à `make deps`) ; la liste vient des `.desktop` de `XDG_DATA_DIRS` + exports Flatpak : un service systemd utilisateur sans `XDG_DATA_DIRS` retombe sur `/usr/local/share:/usr/share`. - Saisie de texte : Verr. Maj du PC non détecté (majuscules inversées s'il est actif) ; un moteur de saisie (fcitx/ibus) peut altérer le résultat ; la composition des touches mortes dépend de l'application (vérifiée par simulation xkb avec la table de composition `en_US.UTF-8`, pas dans chaque application). Testé en session X11 ; Wayland utilise les mêmes sources (kxkbrc) mais n'a pas été essayé. - Chromium déjà ouvert : un lanceur `web` peut s'ouvrir dans la fenêtre existante (le plein écran n'est alors pas garanti). -- `make url` détecte l'IP via la route par défaut : avec un VPN actif (WireGuard), il annonce l'IP du VPN. Renseigner `server.advertise_host` dans `config.toml` pour forcer l'adresse du QR code. +- `make url` détecte l'IP via la route par défaut : avec un VPN actif (WireGuard), il annonce l'IP du VPN. Renseigner `server.advertise_host` dans `config.toml` pour forcer l'adresse du QR code **et du certificat** : `make cert` émet le certificat pour l'adresse annoncée (`tls.default_hosts`), donc `advertise_host` se règle **avant** `make cert` (sinon corriger puis relancer `make cert`, la CA ne change pas). Vu en vrai : `make url` annonçait `10.2.0.2` (tunnel WireGuard de Proton VPN) sur le PC de l'auteur. Signalé dans l'installation des README et dans `config.example.toml`. - `firefox --kiosk` (et `chromium --kiosk`) ignore F11 : impossible de quitter le plein écran depuis la télécommande. Le lanceur YouTube TV utilise `chromium --start-fullscreen`, que F11 permet de quitter. - Lancé hors session graphique (ssh, cron), il n'y a pas de bus de session : MPRIS et système sont désactivés (log d'erreur) mais le serveur démarre quand même. - `/dev/uinput` nécessite `modprobe uinput` et une reconnexion de session après `make uinput` ; vérifier avec `getfacl /dev/uinput`. diff --git a/README-EN.md b/README-EN.md index ca810d6..cb695d1 100644 --- a/README-EN.md +++ b/README-EN.md @@ -41,6 +41,7 @@ KDE Connect is not required; it can stay installed for its other features. make deps # system packages (sudo): venv, gcc, pactl, qrencode, ffmpeg make install # .venv + Python dependencies make config # ~/.config/mediadeck/config.toml (mode 600) with a random token + # PC with a VPN: set `advertise_host` HERE, before `make cert` (see below) make cert # secure access (HTTPS): local CA + certificate, enabled in config.toml make http-on # optional: also keep an unencrypted HTTP access (port 8766) make uinput # "uaccess" udev rule for /dev/uinput (sudo) @@ -60,6 +61,21 @@ Run every `make` command **from the project folder** (the one containing the `Ma `make cert` it is the only mode; with `make cert` then `make http-on`, both coexist (see "Choosing: secure or unsecured"). - If the `ufw` firewall is active: `make firewall` (add `HTTP_PORT=8766` if plain HTTP is enabled). +- **PC with a VPN (WireGuard, Proton VPN…): set `advertise_host`.** `make url`, `make qr` and `make cert` work out + the PC's address from the default route; with an active VPN that route goes through the tunnel (`wg0`, `tun0`, + `proton0`…; for example `10.2.0.2`), so the advertised address cannot be reached by the tablet. The HTTPS + certificate would also be issued for that wrong address. Before `make cert`, put the PC's address **on the local + network**, outside any tunnel, in `~/.config/mediadeck/config.toml`: + + ```toml + [server] + advertise_host = "192.168.1.104" + ``` + + To find it: `ip -4 -br addr` and take the address of the physical interface (`enp…`, `eno…`, `wlp…`), not a + tunnel's or a Docker bridge's. If `make cert` was already run with a wrong address, fix it and rerun `make cert`: + the CA stays the same, nothing to redo on the tablet. If the tablet still cannot reach the PC, allow local network + connections in the PC's VPN application. On the tablet: scan the QR code, then browser menu → "Add to Home screen". The token is stored, then removed from the address bar. @@ -75,7 +91,7 @@ The service must run **inside the graphical session**: it needs the user's sessi host = "0.0.0.0" port = 8765 token = "…" # make token to regenerate it -advertise_host = "192.168.1.104" # optional: address used in the QR code (auto-detected otherwise) +advertise_host = "192.168.1.104" # address of the QR code and certificate (auto-detected otherwise); set it if the PC has a VPN tls_cert = "~/.config/mediadeck/tls/server.pem" # written by `make cert` (HTTPS) tls_key = "~/.config/mediadeck/tls/server.key" tls_ca = "~/.config/mediadeck/tls/mediadeck-ca.crt" # served on /ca.crt for the tablet diff --git a/README.md b/README.md index b4b3866..1600fad 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ KDE Connect n'est pas nécessaire : il peut rester installé pour ses autres fon make deps # paquets système (sudo) : venv, gcc, pactl, qrencode, ffmpeg make install # .venv + dépendances Python make config # ~/.config/mediadeck/config.toml (mode 600) avec un jeton aléatoire + # PC avec un VPN : renseigner `advertise_host` ICI, avant `make cert` (voir ci-dessous) make cert # accès sécurisé (HTTPS) : CA locale + certificat, activés dans config.toml make http-on # facultatif : garde aussi un accès HTTP en clair (port 8766) make uinput # règle udev « uaccess » pour /dev/uinput (sudo) @@ -59,6 +60,21 @@ redémarrer le service (`systemctl --user restart mediadeck`). - **Accès non sécurisé (HTTP)** : rien à installer, mais le jeton circule en clair sur le réseau local. Sans `make cert`, c'est le seul mode ; avec `make cert` puis `make http-on`, les deux coexistent (voir « Choisir : sécurisé ou non »). - Si le pare-feu `ufw` est actif : `make firewall` (ajouter `HTTP_PORT=8766` si le HTTP en clair est activé). +- **PC avec un VPN (WireGuard, Proton VPN…) : renseigner `advertise_host`.** `make url`, `make qr` et `make cert` + déduisent l'adresse du PC de la route par défaut ; avec un VPN actif, elle passe par le tunnel (`wg0`, `tun0`, + `proton0`… ; par exemple `10.2.0.2`) et l'adresse annoncée n'est pas joignable par la tablette. Le certificat HTTPS + serait en plus émis pour cette mauvaise adresse. Avant `make cert`, indiquer dans `~/.config/mediadeck/config.toml` + l'adresse du PC **sur le réseau local**, hors tunnel : + + ```toml + [server] + advertise_host = "192.168.1.104" + ``` + + Pour la trouver : `ip -4 -br addr` et prendre l'adresse de l'interface physique (`enp…`, `eno…`, `wlp…`), pas celle + d'un tunnel ni d'un pont Docker. Si `make cert` a déjà été lancé avec une mauvaise adresse, corriger puis relancer + `make cert` : la CA reste la même, rien à refaire sur la tablette. Si la tablette n'atteint toujours pas le PC, + autoriser les connexions au réseau local dans l'application VPN du PC. Sur la tablette : scanner le QR code, puis menu du navigateur → « Ajouter à l'écran d'accueil ». Le jeton est mémorisé puis retiré de la barre d'adresse. @@ -74,7 +90,7 @@ Le service doit tourner **dans la session graphique** : il a besoin du bus D-Bus host = "0.0.0.0" port = 8765 token = "…" # make token pour le régénérer -advertise_host = "192.168.1.104" # optionnel : adresse du QR code (sinon détection automatique) +advertise_host = "192.168.1.104" # adresse du QR code et du certificat (sinon détection) ; à renseigner si le PC a un VPN tls_cert = "~/.config/mediadeck/tls/server.pem" # écrits par `make cert` (HTTPS) tls_key = "~/.config/mediadeck/tls/server.key" tls_ca = "~/.config/mediadeck/tls/mediadeck-ca.crt" # servi sur /ca.crt pour la tablette diff --git a/config.example.toml b/config.example.toml index 6c1ad69..14ebdd2 100644 --- a/config.example.toml +++ b/config.example.toml @@ -5,8 +5,10 @@ # 0.0.0.0 = toutes les interfaces ; préférer l'IP LAN du PC si possible host = "0.0.0.0" port = 8765 -# Adresse affichée dans l'URL et le QR code (`make url`) ; à renseigner si la détection -# automatique choisit une mauvaise interface (VPN, Docker…). Nom d'hôte ou IPv4. +# Adresse affichée dans l'URL et le QR code (`make url`) et pour laquelle `make cert` émet le certificat HTTPS. +# À RENSEIGNER AVANT `make cert` si le PC utilise un VPN (WireGuard, Proton VPN…) ou Docker : la détection +# automatique suit la route par défaut, qui passe alors par le tunnel (ex. 10.2.0.2), injoignable par la tablette. +# Mettre l'adresse du PC sur le réseau local (`ip -4 -br addr`, interface enp…/eno…/wlp…). Nom d'hôte ou IPv4. # advertise_host = "192.168.1.104" # HTTPS : `make cert` crée une CA locale + un certificat et renseigne ces trois lignes. # La tablette doit installer la CA une fois (https://:/ca.crt).