Skip to content
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

only send packets to the selected interface, not all interfaces #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

distributed
Copy link

In the current implementation, the ipv{4,6}conn is bound to 224.0.0.1:5353 which works out to 0.0.0.0:5353 when you ask the connection's LocalAddr() method. Accordingly, multicast writes go out to all interfaces of the host.

I have a situation where I announce my services on two different network interfaces, each of which has its own IP address. As all packets are sent to all interfaces, one of the updates will win and it will not always be the right one.

In this pull request I added calls to *ipv{4,6}.PacketConn.SetMulticastInterface. This makes the underlying *net.UDPConns send out multicast packets on only the specified interface, thereby correcting the behavior.

Thanks for writing this library :)

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.

1 participant