Skip to content

Rebase PR #188 (Fixes for OS X) with resolved conflicts #270

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

Merged
merged 15 commits into from
Jul 7, 2020
Merged

Conversation

jstasiak
Copy link
Collaborator

No description provided.

* Listen on respond_sockets in addition to listen_socket
* Do not bind to respond_sockets in multicast mode

Without either of these changes, I get no replies at all when browsing for
services using the browser example. I'm on a corporate network, and when
connecting to a different network it works without these changes, so maybe
it's something about the network configuration in this particular network
that breaks the previous behavior.

Unfortunately, I have no idea how this affects other platforms, or what
the changes really mean. However, it works for me and it seems reasonable
to get replies back on the same socket where they are sent.
@jstasiak
Copy link
Collaborator Author

cc #188

@estyrke while running examples with this seems fine both on Linux (tried it on Raspberry Pi) and on OS X this breaks the test suite on both of those systems for some reason, I'll try to figure out why.

@jstasiak jstasiak changed the title Rebase PR #188 with resolved conflicts Rebase PR #188 (Fixes for OS X) with resolved conflicts May 31, 2020
@jstasiak
Copy link
Collaborator Author

I think the failures are due to the respond sockets not being assigned port 5353. Now their assigned a random port by the OS and, when a question gets sent through them it's received by the listening socket from a source port different than 5353 and this condition (from https://github.com/jstasiak/python-zeroconf/blob/beff99897f0a5ece17e224a7ea9b12ebd420044f/zeroconf/__init__.py#L1388)

        elif msg.is_query():
            # Always multicast responses
            if port == _MDNS_PORT:
                self.zc.handle_query(msg, None, _MDNS_PORT)

doesn't trigger and a query gets ignored, which is followed by no answer being sent and the whole listener integration test crashes.

It's time for me to reread RFC 6762 in regards to sockets, interfaces and port numbers.

@jstasiak
Copy link
Collaborator Author

From RFC 6762:

   A compliant Multicast DNS querier, which implements the rules
   specified in this document, MUST send its Multicast DNS queries from
   UDP source port 5353 (the well-known port assigned to mDNS), and MUST
   listen for Multicast DNS replies sent to UDP destination port 5353 at
   the mDNS link-local multicast address (224.0.0.251 and/or its IPv6
   equivalent FF02::FB).
(...)
   The source UDP port in all Multicast DNS responses MUST be 5353 (the
   well-known port assigned to mDNS).  Multicast DNS implementations
   MUST silently ignore any Multicast DNS responses they receive where
   the source UDP port is not 5353.

jstasiak added 5 commits June 1, 2020 00:49
This is an attempt to still send packets with the correct source port yet not
bind to INADDR_ANY so that the original use case of this pull request is taken
care of.
It has some dirty log.debug changes too, I'll clean it up once it works.
Also it's a tangled mess of tuples now, I'll also deal with that when
there's time to do it.
@coveralls
Copy link

coveralls commented Jun 2, 2020

Coverage Status

Coverage decreased (-0.06%) to 92.593% when pulling b46da94 on rebase-188 into a7f9823 on master.

jstasiak and others added 2 commits June 2, 2020 14:01
When there is nothing to write, we don't need to warn about not making progress.
@jstasiak
Copy link
Collaborator Author

jstasiak commented Jun 2, 2020

@estyrke (or is it @estyrke-axis?) can you test this branch? I massaged it to the state that passes the test suite on Travis CI and my manual tests on both Mac and Linux were successful.

I'm actually thinking about removing the listening socket totally since we handle packets read from the respond sockets now, but I'll leave it for later.

@ghost
Copy link

ghost commented Jun 9, 2020

Hi @jstasiak, sorry for the late reply! I made the commits using my work email, but created the PR using my personal github account, I guess that's the cause of the mixup.

Unfortunately, I haven't been able to test this branch in the original network where I had the problem, due to working from home at the moment. And to be honest, I don't even really remember what the specifics of the original problem were.

This branch does work in my home network, but then again, so does the master branch...

@jstasiak
Copy link
Collaborator Author

@estyrke-axis so I think I'll merge this as long as it doesn't break currently working usecases and, if in the future you discovered something's yet to be done, we can revisit this.

@jstasiak jstasiak merged commit fc92b1e into master Jul 7, 2020
@jstasiak jstasiak deleted the rebase-188 branch July 7, 2020 11:11
@jstasiak
Copy link
Collaborator Author

jstasiak commented Jul 7, 2020

This has been released in 0.28.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants