From aae93051a0fc5d0e9ae7e7fe4ff115c6984e2ee2 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 7 Apr 2026 22:15:36 +0200 Subject: [PATCH] control: fix request-body checks and stream timeout wiring --- cmd/fmrtx/main.go | 2 +- internal/control/control.go | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/fmrtx/main.go b/cmd/fmrtx/main.go index 5354f08..98a8e88 100644 --- a/cmd/fmrtx/main.go +++ b/cmd/fmrtx/main.go @@ -188,7 +188,7 @@ func runTXMode(cfg cfgpkg.Config, configPath string, driver platform.SoapyDriver streamSrc = audio.NewStreamSource(bufferFrames, rate) engine.SetStreamSource(streamSrc) - source, sourceIngress, err := ingestfactory.BuildSource(cfg, ingestfactory.Deps{Stdin: os.Stdin}) + source, sourceIngress, err := ingestfactory.BuildSource(ctx, cfg, ingestfactory.Deps{Stdin: os.Stdin}) if err != nil { log.Fatalf("ingest source: %v", err) } diff --git a/internal/control/control.go b/internal/control/control.go index 1e9bd9d..3618463 100644 --- a/internal/control/control.go +++ b/internal/control/control.go @@ -340,7 +340,7 @@ func (s *Server) handleRuntimeFaultReset(w http.ResponseWriter, r *http.Request) http.Error(w, "method not allowed", http.StatusMethodNotAllowed) return } - if !s.rejectBody(w, r) { + if s.rejectBody(w, r) { // BUG-01 fix: rejectBody returns true when rejected return } s.mu.RLock() @@ -383,6 +383,14 @@ func (s *Server) handleAudioStream(w http.ResponseWriter, r *http.Request) { return } + // BUG-10 fix: /audio/stream is a long-lived streaming endpoint. + // The global HTTP server ReadTimeout (5s) and WriteTimeout (10s) would + // kill connections mid-stream. Disable them per-request via ResponseController + // (requires Go 1.20+, confirmed Go 1.22). + rc := http.NewResponseController(w) + _ = rc.SetReadDeadline(time.Time{}) + _ = rc.SetWriteDeadline(time.Time{}) + r.Body = http.MaxBytesReader(w, r.Body, audioStreamBodyLimit) // Read body in chunks and push to ring buffer @@ -426,7 +434,7 @@ func (s *Server) handleTXStart(w http.ResponseWriter, r *http.Request) { http.Error(w, "method not allowed", http.StatusMethodNotAllowed) return } - if !s.rejectBody(w, r) { + if s.rejectBody(w, r) { // BUG-01 fix: rejectBody returns true when rejected return } s.mu.RLock() @@ -450,7 +458,7 @@ func (s *Server) handleTXStop(w http.ResponseWriter, r *http.Request) { http.Error(w, "method not allowed", http.StatusMethodNotAllowed) return } - if !s.rejectBody(w, r) { + if s.rejectBody(w, r) { // BUG-01 fix: rejectBody returns true when rejected return } s.mu.RLock()