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

Service discovery on specific IPv6 interface #1132

Open
lokesh2019 opened this issue Feb 15, 2023 · 0 comments
Open

Service discovery on specific IPv6 interface #1132

lokesh2019 opened this issue Feb 15, 2023 · 0 comments

Comments

@lokesh2019
Copy link

Not sure if this is a bug or I am using the API wrong. Please advise. This is all IPv6-only network.
I have a host with say three network interfaces : eth0, eth1 and eth2 - and I want to listen to advertisements coming only from eth1.

My service listener is based on browser.py example. The api calls look something like this:

class ZeroconfListener:
    """Class for zeroconf to populate"""

    def remove_service(self, _zeroconf, service_type, name):
        """Called when zeroconf when a service is nolonger available"""
       do stuff

    def add_service(self, zeroconf, service_type, name):
        """Called when zeroconf when a service becomes available"""
        do stuff

    def update_service(self, *_):
        """Called internally by Zeroconf."""
        not needed. do nothing

zeroconf = Zeroconf(ip_version=IPVersion.V6Only, interfaces=[addr_of_eth1])
services = ["_device-info._tcp.local."]
ServiceBrowser(zeroconf, services, ZeroconfListener())

while True: # wait forever
    time.sleep(60)

The problem is, I only want to listen to advertisements coming from eth1 but this seems to listen to all the interfaces. I can verify this by publishing a _device-info._tcp.local service from a machine connected on eth0 subnet. I suspect that is because I am not using unicast argument when initialising Zeroconf class, and this line puts a listener on all the interfaces:

listen_socket = new_socket(ip_version=ip_version, apple_p2p=apple_p2p, bind_addr=('',))

TL;DR Question is, how do I restrict zeroconf to a specific interface? Is this a supported use case?

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

No branches or pull requests

1 participant