Force Zeroconf to listen and answer only on interface specified with '-i' command line argument.
--- a/runtime/ServicePublisher.py Tue Oct 23 13:31:26 2018 +0200
+++ b/runtime/ServicePublisher.py Tue Oct 23 13:34:15 2018 +0200
@@ -56,11 +56,15 @@
self.name = name
self.port = port
- self.server = zeroconf.Zeroconf()
- print("MDNS brodcasting on :" + ip)
+ if ip == "0.0.0.0":
+ print("MDNS brodcasted on all interfaces")
+ interfaces=zeroconf.InterfaceChoice.All
+ ip = self.gethostaddr()
+ else:
+ interfaces=[ip]
- if ip == "0.0.0.0":
- ip = self.gethostaddr()
+ self.server = zeroconf.Zeroconf(interfaces=interfaces)
+
print("MDNS brodcasted service address :" + ip)
self.ip_32b = socket.inet_aton(ip)