FDH2 / UxPlay

AirPlay Unix mirroring server
GNU General Public License v3.0
1.34k stars 72 forks source link

Add the ability to request a code for connection #208

Closed GribouilleVert closed 9 months ago

GribouilleVert commented 9 months ago

Hi,

I use UxPlay to forward the sound of my iPad to my computer, buy when i'm at my work (which is a coworking space with ~40 peoples on the network), people sometime start airplaying on my computer which is qui annoying. I know that airplay has a feature wherin the airplay server can request for the client to provide a code to confirm physical access to the server device (my TV does this). Would it be possible to implement such a feature in UxPlay ? It would be usefull in preventing people on the same network from connecting to your devices without consent.

-Vasco

fduncanh commented 9 months ago

Not easy to replicate the apple code solution.

An iOS client lists a Wi-Fi Address in its "about" in General Settings section which is its true MAC address and is reported to the server as its unchangeable "device ID" when the connection is set up (this not its apparent macAddress, which I think is randomized for privacy, and visible on the network).

It would be fairly easy add an option to uxplay to only allow connections to clients with a deviceID listed in the uxplay startup file.

For example, maybe "uxplay -restrict"

would limit clients to deviceID's given by entries in the .uxplayrc file like

allow AC:23:45:CB:22:01
allow 2C:5D:88:9B:67:2A
GribouilleVert commented 9 months ago

Oh ok, thank you for the info !

fduncanh commented 9 months ago

@GribouilleVert

I looked into this, and its easy to implement, so I'll add this feature. UxPlay will report name, model and deviceID of client that request a connection, and if option "-restrict" is is used, it will check that deviceID is in the "allowed" list, specified by option " -allow XX:XX:XX:XX:XX:XX: (probably entered in the uxplayrc file) so that it's easy to enter the right number for future connections

fduncanh commented 9 months ago

@GribouilleVert The code you wanted is now in the "testing" branch.

The new options -restrict [no] and -allow <clientID> are documented in uxplay -h and man uxplay, but not yet in the README.

Please test.

EDIT: it is NOT the Wi-Fi address, but might be the "true" MAC address which iOS hides and does not expose to the network.

Add allowed clients in ~/.uxplayrc (with restrictions enforced) using

restrict
allow  XX:XX:XX:XX:XX:XX
allow YY:YY:YY:YY:YY:YY

Use

uxplay -restrict

to run uxplay with client restrictions (only needed if it not placed in ~/.uxplayrc), and

uxplay -restrict no

to switch off client checking that is set in ~/.uxplayrc.

Use

uxplay -allow ZZ:ZZ:ZZ:ZZ:ZZ:ZZ

to allow a client not listed in ~/.uxplayrc.

fduncanh commented 9 months ago

I will probably also add a -block option to block certain clients while not enforcing restrictions on others.

EDIT: done (the README is now also updated for the new options) clientID's on the "block" list will never be allowed to connect

syntax:

uxplay -block AA:AA:AA:AA:AA:AA

(best added in ~/.uxplayrc).

fduncanh commented 9 months ago

The main branch has this feature (plus an unrelated fix) now

fduncanh commented 9 months ago

@GribouilleVert

The --restrict -allow -block features are included in the latest UxPlay-1.66 (just released).

Let us know if they solve your issue.

fduncanh commented 6 months ago

@GribouilleVert

Latest UxPlay at github (v 1.67) finally supports Apple-Style pin pairing. https://github.com/FDH2/UxPlay

GribouilleVert commented 4 months ago

Awesome, thank you so much !