Limit PTP addresses to configured network interface #1813
Merged
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.
This is a conservative change. I think I have identified an even better fix, but with more risk of regression.
Without this change (or with no general.interface configured) every address of the ShairPort Sync server seems to be advertised via PTP, including many internal Docker networks that are not reachable from elsewhere. My AirPlay sources (at least macOS 12.7.2 & iOS 17.3.1) send a lot of PTP messages to all of these addresses in parallel, most of which are rejected by my firewall.
With this change and when general.interface is set, only addresses for that interface are advertised for PTP. Even in this case my ShairPort Sync server still receives 4x seemingly duplicate streams of PTP messages to each of those addresses (static IPv4, link-local IPv6, ULA IPv6, public IPv6). The actual audio only goes to the public IPv6 address in my case.
I stumbled upon a potentally even better fix by accident when I mucked up the logic during testing: Don't advertise any addresses here. ShairPort still worked fine. PTP messages are still sent to the same address as the audio stream (public IPv6 address in my case) and recognised by ShairPort ("Connection 1: AP2 PTP connection from IPHONE_IPV6_ADDR"). Multi-room sync between ShairPort & a HomePod Mini seemed good. For now I'm going to run my build with the following hack as it minimises network traffic without any apparent drawbacks.
Testing performed: