Skip to content

Admit this host's own addresses at the pairing token endpoint - #134

Merged
chrisuthe merged 1 commit into
mainfrom
chrisuthe/admit-the-hosts-own-addresses-at-the-pairing-endpoint
Nov 20, 2026
Merged

chrisuthe merged 1 commit into
mainfrom
chrisuthe/admit-the-hosts-own-addresses-at-the-pairing-endpoint

Conversation

@chrisuthe

Copy link
Copy Markdown
Member

Local pairing fails on Home Assistant OS. Music Assistant runs with host_network: true, so its fetch of http://172.30.32.1:<port>/ goes out over lo, and HAOS's nat rule ip saddr 172.30.32.0/23 oifname != "hassio" masquerade rewrites the source to the host's LAN address. That address is off 172.30.32.0/23, so the endpoint answered 403 (Pairing token endpoint refused 10.0.0.16: not on its subnet at debug), and Music Assistant logged Fetching the local token of <id> failed: HTTP 403.

The admit now also lets in a peer whose address is assigned to one of this host's interfaces. A process on this host could reach the bound address anyway, so the boundary stays at "this host plus the address's subnet". A machine elsewhere on the LAN still gets 403, because its address isn't this host's.

  • local_addresses() lists every interface address with its prefix. local_subnet_of() now uses it, and so does the admit.
  • is_local_address() checks for an exact address match, not a subnet match. A LAN neighbour shares the host's subnet, so a subnet match would let it in.
  • The admit lists addresses only when a peer is off the subnet, and does it on every such connection, so a DHCP renewal is picked up without a restart.

Tests: KnowsWhichPeersAreThisHost (the masqueraded host address is admitted; a neighbour on the same /24, another network, and non-addresses are refused) and ListsThisMachinesAddresses (127.0.0.1 is listed, TEST-NET-1 is not). The README, Configuration and Advanced Usage text now say "subnet or this host".

Tested on Home Assistant OS

HAOS amd64 with Music Assistant dev 2.11.0.dev2026112003, running the local-audio app built from this branch (34c15f5) with default options:

  • Music Assistant paired with no manual step. The player logged Paired with server … and then A server paired -- stopped serving the token on http://172.30.32.1:8929/, and Music Assistant logged no 403 after the restart.
  • A second unpaired instance on 172.30.32.1:8939 answered 200 to host-sourced requests, which arrive as 10.0.0.16.
  • From another LAN machine, 172.30.32.1:8939 timed out (no route) and <host LAN IP>:8939 was refused (nothing listens there).

On Home Assistant OS, Music Assistant runs on the host network, and its connection to 172.30.32.1 is masqueraded to the host's LAN address, which is off the endpoint's subnet, so it was refused with 403. A peer holding one of this host's addresses could reach the bound address anyway; machines elsewhere on the LAN are still refused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant