Warn when the peripheral API binds to a non-loopback address - #420
Open
sappafrancesco wants to merge 1 commit into
Open
sappafrancesco wants to merge 1 commit into
sappafrancesco wants to merge 1 commit into
Conversation
Fixes OHF-Voice#400. The peripheral WebSocket API defaults to 0.0.0.0 and has no authentication (documented and by design, per the linked issue's discussion, the network-accessible case is intentional for people who want to control LVA from another device or container). But nothing told the operator that this combination means anyone on the LAN can mute/unmute the mic, start a voice pipeline (streaming captured audio to whatever conversation agent is configured), change the volume, or register arbitrary entities into Home Assistant. This doesn't change the default (that's a bigger, more opinionated call than a warning, and the issue thread hasn't converged on it). Instead: - Logs a clear warning at startup whenever the peripheral API binds to anything other than 127.0.0.1/::1/localhost, naming the concrete commands an unauthenticated LAN client could send and pointing at `--peripheral-host 127.0.0.1`. - Updates docs/peripheral_api.md's "No authentication is required" line, which read as a convenience note, with an explicit explanation of what that means combined with the 0.0.0.0 default. Added test_start_warns_on_non_loopback_host and test_start_does_not_warn_on_loopback_host (parametrized over 127.0.0.1/::1/localhost). Checked: ``` black --check / isort --check / flake8 / mypy / pylint -> clean pytest tests/unit/test_peripheral_api.py -> 88 passed pytest tests/ -> same 49 pre-existing failures in test_satellite.py as on main with this diff stashed out (unrelated audio/OS-level test environment issue, not touched by this change) ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #400.
The peripheral WebSocket API defaults to
0.0.0.0and has noauthentication. That combination isn't flagged anywhere at runtime,
and
docs/peripheral_api.md's "No authentication is required." readsas a convenience note rather than a warning.
Per the issue discussion, keeping
0.0.0.0as the default isn'tobviously wrong (some setups genuinely want to control LVA from
another device or container), so this doesn't change it. What it does:
--peripheral-hostresolves toanything other than
127.0.0.1/::1/localhost, naming theconcrete things an unauthenticated LAN client could do (mute/unmute
the mic,
start_listeningto open a voice pipeline and streamcaptured audio to whatever conversation agent is configured, change
the volume, register arbitrary entities) and pointing at
--peripheral-host 127.0.0.1.0.0.0.0default actually means, and how to opt out of it.Type of change
Testing
Added:
test_start_warns_on_non_loopback_hosttest_start_does_not_warn_on_loopback_host(parametrized over127.0.0.1,::1,localhost)