From e42ff53234e23b00b254f83e1579d219b478e5ff Mon Sep 17 00:00:00 2001 From: Ednunp Date: Fri, 15 May 2026 17:24:24 +0100 Subject: [PATCH] =?UTF-8?q?server:=20update=20to=20v2.3=20=E2=80=94=20dual?= =?UTF-8?q?-protocol=20relay=20(v1=20pair=20+=20v2=20lobby)=20+=20auto-upd?= =?UTF-8?q?ater=20with=20EXIT=20trap=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/smoke-test.sh | 92 ++++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 28 deletions(-) diff --git a/server/smoke-test.sh b/server/smoke-test.sh index 13155b9..b47fd40 100644 --- a/server/smoke-test.sh +++ b/server/smoke-test.sh @@ -1,12 +1,9 @@ #!/bin/bash -# smoke-test.sh — Quick health check for the RemSound relay. +# smoke-test.sh — Quick health check for the RemSound relay + auto-updater. # -# Run after install. Confirms the service is running, listening on UDP 47830, -# and accepts a valid RemSound header (silently dropping it as unpaired, which -# is the expected behaviour with no real peers connected). -# -# Run as a regular user; only the log read at the end needs sudo and that -# step degrades gracefully if you don't have it. +# Run after install. Confirms the relay service is running, listening on +# UDP 47830, accepts both a v1 and a v2 valid RemSound header, and that +# the auto-updater scaffolding is in place. set -u @@ -21,7 +18,7 @@ warn() { printf "%s[warn]%s %s\n" "$YELLOW" "$RESET" "$*"; } failures=0 -# 1. Service active? +# 1. Relay service active? if systemctl is-active --quiet remsound-relay.service; then ok "remsound-relay.service is active" else @@ -41,40 +38,79 @@ else warn "ss not installed, skipping listener check" fi -# 3. Send a synthetic valid RemSound header from this machine to localhost, -# confirm the relay accepts it (it'll be admitted to slot 1 and then -# dropped as unpaired, which logs an event=peer_joined line). +# 3. Send synthetic valid v1 + v2 RemSound headers, confirm they're accepted. if command -v python3 >/dev/null 2>&1; then python3 - <<'PY' -import socket -# Magic 'RMND' (little-endian 0x444E4D52), version 1, type 4 (Heartbeat), -# stream id 1, sequence 1. -header = bytes([0x52, 0x4D, 0x4E, 0x44, 1, 4, 1, 0, 1, 0, 0, 0]) +import socket, struct, uuid s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) -s.sendto(header, ("127.0.0.1", 47830)) + +# v1: magic 'RMND' (LE 'RMND'), version 1, type 4 (Heartbeat), stream 1, seq 1. +v1 = bytes([0x52, 0x4D, 0x4E, 0x44, 1, 4, 1, 0, 1, 0, 0, 0]) +s.sendto(v1, ("127.0.0.1", 47830)) + +# v2: magic 'RMND', version 2, type 4 (Heartbeat), stream 1, seq 1, random UUID. +cid = uuid.uuid4().bytes +v2 = bytes([0x52, 0x4D, 0x4E, 0x44, 2, 4, 1, 0, 1, 0, 0, 0]) + cid +s.sendto(v2, ("127.0.0.1", 47830)) + s.close() PY - ok "sent synthetic valid RemSound header to 127.0.0.1:47830" + ok "sent synthetic v1 + v2 RemSound headers to 127.0.0.1:47830" else warn "python3 not installed, skipping header send" fi -# 4. Look for the resulting peer_joined event in the relay log. +# 4. Look for the expected log events for both protocols. sleep 1 -if [[ -r /var/log/remsound-relay.log ]]; then - if tail -20 /var/log/remsound-relay.log 2>/dev/null | grep -q "event=peer_joined.*127.0.0.1"; then - ok "relay logged a peer_joined event for 127.0.0.1 — header validation works" - else - warn "no peer_joined event for 127.0.0.1 found in last 20 log lines (may have aged out if you ran this twice)" +read_log() { + if [[ -r /var/log/remsound-relay.log ]]; then + tail -40 /var/log/remsound-relay.log 2>/dev/null + elif sudo -n test -r /var/log/remsound-relay.log 2>/dev/null; then + sudo tail -40 /var/log/remsound-relay.log 2>/dev/null fi -elif sudo -n test -r /var/log/remsound-relay.log 2>/dev/null; then - if sudo tail -20 /var/log/remsound-relay.log 2>/dev/null | grep -q "event=peer_joined.*127.0.0.1"; then - ok "relay logged a peer_joined event for 127.0.0.1 — header validation works" +} +log_lines="$(read_log)" +if [[ -n "$log_lines" ]]; then + if printf '%s\n' "$log_lines" | grep -q "event=peer_joined.*127.0.0.1"; then + ok "v1 path: relay logged a peer_joined event for 127.0.0.1" else - warn "no peer_joined event for 127.0.0.1 found in last 20 log lines" + warn "v1 path: no peer_joined event for 127.0.0.1 in last 40 log lines" + fi + if printf '%s\n' "$log_lines" | grep -q "event=client_joined.*127.0.0.1"; then + ok "v2 path: relay logged a client_joined event for 127.0.0.1" + else + warn "v2 path: no client_joined event for 127.0.0.1 in last 40 log lines" fi else - warn "cannot read /var/log/remsound-relay.log (try: sudo $0 to also read the log)" + warn "cannot read /var/log/remsound-relay.log (try: sudo $0)" +fi + +# 5. Auto-updater scaffolding in place? +if [[ -x /usr/local/sbin/remsound-relay-update.sh ]]; then + ok "auto-updater script at /usr/local/sbin/remsound-relay-update.sh" +else + fail "missing /usr/local/sbin/remsound-relay-update.sh" + failures=$((failures + 1)) +fi +if systemctl is-active --quiet remsound-relay-update.timer; then + ok "remsound-relay-update.timer is active" +else + fail "remsound-relay-update.timer is not active. Try: sudo systemctl status remsound-relay-update.timer" + failures=$((failures + 1)) +fi +if [[ -r /etc/remsound-relay/version ]]; then + installed_tag="$(tr -d '[:space:]' < /etc/remsound-relay/version)" + if [[ "$installed_tag" =~ ^server-v[0-9]+\.[0-9]+ ]]; then + ok "installed version: $installed_tag" + else + warn "version file present but unexpected format: $installed_tag" + fi +elif sudo -n test -r /etc/remsound-relay/version 2>/dev/null; then + installed_tag="$(sudo tr -d '[:space:]' < /etc/remsound-relay/version)" + ok "installed version (via sudo): $installed_tag" +else + fail "cannot read /etc/remsound-relay/version" + failures=$((failures + 1)) fi echo