-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utilities/Zeroconf.app: Use dns-sd instead of avahi-browse #57
base: master
Are you sure you want to change the base?
Conversation
- This will make it easier to write unit tests later. - This is consistent with the example set in Utilities/Calculator.app. - ./Zeroconf is now just a shell script pointing to the Python application.
In Python 2, there were old-style classes (`class Foo:`) and new-style classes (`class Foo(object):`). This is not necessary in Python 3.
This means that the self.app.aboutToQuit signal will be processed, and the application can clean up after itself.
A simple class representing a service, with some unused fields left out, and with no handle() method.
This will be useful when we want to remove services from the list or avoid adding duplicates.
It runs a command using QProcess and emits each line of the output through a pyqtSignal.
This class discovers services on the local network by running `dns-sd`.
This means the tool no longer leaves several `dns-sd` processes running in the background.
The recently added/modified classes behave differently from the old ones - so hook things up.
I don't know how to remove a PyQt5 widget entirely, so I used setHidden(true).
- self.services changed slightly in the previous commit, so the method has been updated to handle that. - DRY.
Preferences/Sharing.app also depends on Avahi because it uses Utilities/Preferences/Sharing.app/Resources/sharing.py Lines 159 to 160 in ce1bb2f
Though, if I'll also note that |
This is a very interesting aspect which I did not know before, I was assuming that it is an either-or. At least Avahi had given me some messages to that end back when I was also experimenting with mDNSResponder/dns-sd, with the result that gvfs did not show network shares in Filer anymore. I will need to do more testing (using Live systems so that I don't break my installed system). Do you think you could implement something like #1 (comment)? |
Note to self: Consider rewrite in Qt/C++ with https://github.com/nitroshare/qmdnsengine. This one is known to work even though avahi is running on the system (but does not need it). |
Hi!
First of all: I did all this work on a macOS desktop. I suspect everything will work on FreeBSD/hello (FreeBSD's mDNSResponder package comes from Apple), but I don't have a spare machine to experiment with right now.
Anyway, here's a PR that removes one dependency on Avahi from hello. Avahi depends on D-Bus, and D-Bus is unwelcome on hello.
avahi-browse
outputs all the relevant information when provided one set of flags. However thedns-sd
tool in the mDNSResponder package requires several invocations to provide the same invocation so the Zeroconf.app tool has become a little more complex.Keeping with the spirit of hello, the whole application is still in one file. However I did add a couple of unit tests in separate files (
Resources/CommandReader_test.py
andResources/ZeroconfService_test.py
).Testing
Install and setup mDNSResponder:
sudo pkg install mDNSResponder mDNSResponder_nss
sudo vi /etc/nsswitch.conf
mdns
to the end of thehosts:
linesudo sysrc mdnsd_enable=YES
sudo service mdnsd start
You can run the application with the
Utilities/Zeroconf.app/Zeroconf
script, or runpython3 Utilities/Zeroconf.app/Resources/zeroconf.py
.You can advertise a new service with this command (and take away the new service with Ctrl-C):
Hope this is useful. Thanks!