philippe44 / AirConnect

Use AirPlay to stream to UPnP/Sonos & Chromecast devices
Other
3.5k stars 216 forks source link

AirPlay 1 backward compatibility #252

Closed jtbr closed 4 years ago

jtbr commented 4 years ago

More of a question than a request.

I've got an iPad on iOS 10, which is pre-airplay 2. I can see the airplay devices created by airconnect but cannot connect/cast to them. Could this be because airconnect supports airplay 2 only and airplay 2 is not backwards compatible? Or should it work? I noticed that when I updated an appletv to the latest OS I can no longer cast to it either.

Conversely would you expect a newly updated iPad to be able to cast audio to an old sink?

Many thanks

philippe44 commented 4 years ago

AirConnect only supports AirPlay1, so it should work just fine with iOS 10. It's probably something different, network-related

jtbr commented 4 years ago

Oh wow, I was up the wrong creek entirely. Thanks for that info, and for the great app.

I found two networking issues, actually. It seems that filtering multicast at the router level was causing issues. And the firewall on the machine running airconnect is not allowing some connection to be made, which I only know because disabling the firewall fixes it.

I've tried opening ports 554, 5353, 49152/tcp, 49159/udp, 49163/udp, which are listed by Apple as related to airplay.

I saw from another issue that there are dynamic incoming ports being used. Are these the same as for chromecast (UDP ports 32768 - 61000)?

philippe44 commented 4 years ago

yes, ports and dynamic and whatever the system gives me when I create a socket

jtbr commented 4 years ago

In linux there is no equivalent to what you can tell windows firewall: just allow a certain app to do whatever it wants with networking. I have to limit it by ports in and out. In linux firewalls, admins normally allow apps to connect to/broadcast anything outgoing, but block incoming TCP ports or listening on UDP, except for predefined exceptions.

Unfortunately, looking at netstat/ss, and browsing the code, the only thing we can predict about the LISTEN ports is they will come from the local port range found in /proc/sys/net/ipv4/ip_local_port_range (typically 32768 - 60999). Which is a lot to leave open, but I can see that it's not trivial to predefine port ranges given the dynamic nature of this application.

The following lines allow the app to work by opening all these ports, but only to connections from the local network.

# mdns    
sudo ufw allow from 192.168.0.0/16 to any port 5353 proto udp
# rtsp, audio, control, timing
sudo ufw allow from 192.168.0.0/16 to any port 32768:60999 proto tcp
# audio, control, timing (?)
sudo ufw allow from 192.168.0.0/16 to any port 32768:60999 proto udp

Sorry if you already know all this. But these firewall rules allowed me to run, and might help somebody else.

BTW, I did happen to notice that you might want to swap lines 134 & 135 in raopcore.c. Again, thank you for the very useful app.

philippe44 commented 4 years ago

Thanks for noticing the free() error. WRT ports, I know I should try to limit ports in a given range, but it's a bit of a pain