Closed elbe0046 closed 2 years ago
Thanks! Absolutely interested in including this.
If you're willing I'd love to see an integration test that exercises this functionality with a third-party client. Maybe using the python zeroconf lib, as with the existing tests, provided it supports service type enumeration.
If you're willing I'd love to see an integration test that exercises this functionality with a third-party client. Maybe using the python zeroconf lib, as with the existing tests, provided it supports service type enumeration.
That's a great idea, I should have done so to begin with. I added a commit with an initial pass at such a test: https://github.com/librespot-org/libmdns/pull/38/commits/6b2ffba3216bf891559f16f7d5423a02de716118.
If you prefer that structured differently (multiple files, etc.) just let me know what you have in mind and I'll update.
I took a couple of liberties as well in the tests, any of them can be reverted:
'Service query: Success',
'Service type enumeration: Success'`)update_service
. You may have a different way you'd prefer to handle this. This addresses the warning we see:
/home/parallels/.local/lib/python3.8/site-packages/zeroconf/_services/browser.py:168: FutureWarning: <__main__.MyListener object at 0x7f8c07797820> has no update_service method. Provide one (it can be empty if you don't care about the updates), it'll become mandatory.
Thanks again!
Thanks again for your patience. Just had a moment to take another look at this. I see that you imported ZeroconfServiceTypes
, but then aren't using it for the actual test. I did some testing and it seems to work with that class.
Ideally with the integration test we'll be checking against as high-level a library as possible to ensure we aren't doing something differently than another mDNS client might be as it queries our services.
Thanks for your work on this, I'll release as a new patch release shortly.
Thanks again for your patience. Just had a moment to take another look at this.
Not at all, thank you for all of your time and for working with me to land this change!
I see that you imported
ZeroconfServiceTypes
, but then aren't using it for the actual test. I did some testing and it seems to work with that class.
Ah you're right, I neglected to remove it when I switched approaches, sorry about that.
Ideally with the integration test we'll be checking against as high-level a library as possible to ensure we aren't doing something differently than another mDNS client might be as it queries our services.
If there's any followup work you'd like for me to do here not covered by that test in zeroconf_test.py
, I'd be happy to do that. I'm a bit less familiar with the python / zeroconf side of things, so if you have a recommendation for a higher-level library / API any recommendations you have would be greatly appreciated.
Once again, thank you so much!
No problem, thanks for all your contributions. All I mean by high-level API is using ZeroconfServiceTypes
really.
Let's say we go the string "_services._dns-sd._udp.local." wrong, by specifying it in the test too we're not really testing integration with this other library, just that this library can query against us when we do it our way.
I switched the test back to using ZeroconfServiceTypes myself: https://github.com/librespot-org/libmdns/commit/10ceb7b23087a31510f2b3d4243d323b94422021 which seems to work fine :smiley:
I'm curious to see if there is any interest in landing support for service type enumeration. @willstott101 would such a change align with what you envision for this library? If the underlying idea seems palatable I'm happy to make changes to what is in this PR if you prefer a different approach / form.
For example, if gating this functionality behind a
service-type-enumeration
(or similar) feature would be preferred I can certainly do that.For reference, service type enumeration is detailed in the DNS-Based Service Discovery RFC (https://www.rfc-editor.org/rfc/rfc6763#section-9):
These changes aim to add support for such service type enumeration by implementing the described response to a PTR record query on "_services._dns-sd._udp.". This allows for utilities such as
avahi-browse
to discover services usinglibmdns
without needing to query for a specific service type.Thanks in advance for your time!