jbagg / QtZeroConf

Qt wrapper class for ZeroConf libraries across various platforms.
Other
69 stars 51 forks source link

Add optional parameter for binding service to specific interface #56

Closed briankendall closed 1 year ago

briankendall commented 1 year ago

This adds an optional parameter to registerService that allows specifying a specific interface index to bind to. I added it since I needed to publish a service specifically on the loopback interface. Since the parameter is optional, it shouldn't break any existing code.

This seems to duplicate the work of #25 but that PR was never merged. I think that PR also had an error where it would pass the wrong argument to avahi_server_add_service_strlst when using the previous / default behavior of registerService. (It ought to pass AVAHI_IF_UNSPEC for the interface index, which has a value of -1 not 0.)

Full disclosure: I have not tested the Android specific code as I don't have a dev environment for that. The change is quite small though and I'm pretty sure I got it right. But it should be verified.

jbagg commented 1 year ago

You mentioned you have not tested this on Android. What other OSs have you tested?

briankendall commented 1 year ago

I compiled it on macOS, so the Bonjour code path at least compiles, and does indeed work on macOS.

jbagg commented 1 year ago

Linux / avahiClient.cpp was missing so I added and tested on Linux. If I remember correctly I had issues with browsing by interface when I started this project, so that may be why I left by interface out for publishing as well.