RuView icon indicating copy to clipboard operation
RuView copied to clipboard

feat(sensing-server): make UDP CSI receiver bind address configurable

Open sridhar-3009 opened this issue 4 months ago • 1 comments

Fixes #1394.

Problem

wifi-densepose-sensing-server lets an operator restrict the HTTP API to loopback via --bind-addr (default 127.0.0.1), but the UDP CSI receiver bound 0.0.0.0 unconditionally with no equivalent flag. An operator who deliberately kept the API on loopback still had an unauthenticated CSI ingest port open on every interface.

Change

  • Added --udp-bind-addr / SENSING_UDP_BIND_ADDR, defaulting to 0.0.0.0 — no behaviour change for existing deployments.
  • Kept it as its own flag rather than reusing --bind-addr, since the common real-hardware topology is HTTP on loopback with UDP still open to the LAN so paired ESP32/MediaTek/Qualcomm/RTL8720F nodes can reach it.
  • Threaded the new address through both places that bind the UDP port:
    • probe_esp32 — the one-shot 2s auto-detect probe run at boot in auto mode
    • udp_receiver_task — the persistent listener
  • Startup log now prints the actual UDP bind address (was hardcoded to 0.0.0.0 in the log even before this change would have made it wrong), and adds an explicit exposure note — LAN-reachable, unauthenticated vs restricted — mirroring the existing bind_ip.is_unspecified() pattern used for the HTTP bearer-auth warning.

Out of scope (per the issue)

Authenticating the CSI datagrams themselves (per-node HMAC/PSK, DTLS, source allow-list) is a device-plane design change spanning firmware and consumers — this PR is only about making the listener's bind address as configurable as its HTTP sibling.

Testing

I don't have ESP32/CSI hardware to exercise this against a live radio, so I traced both UDP bind call sites and the auto-mode startup sequence by reading the surrounding code (source-state-machine from #1004, the boot probe timing) rather than running it end-to-end. Happy to adjust if a maintainer can test against real hardware.

sridhar-3009 avatar Jul 22 '26 19:07 sridhar-3009

Clean, behavior-preserving change (default stays 0.0.0.0, both bind sites updated). One small nit:

let udp_ip: std::net::IpAddr = args.udp_bind_addr.parse().expect("Invalid --udp-bind-addr ...") — since clap takes the arg as a String, a malformed value panics at startup (with a backtrace) instead of producing a clean CLI usage error. Letting clap parse it directly is nicer:

#[arg(long, env = "SENSING_UDP_BIND_ADDR", default_value = "0.0.0.0",
      value_parser = clap::value_parser!(std::net::IpAddr))]
udp_bind_addr: std::net::IpAddr,

Then drop the .parse().expect(...) at the use site. Fail-fast is fine; this just makes bad input a usage error rather than a panic.

PrinceAudre avatar Jul 25 '26 12:07 PrinceAudre