Only use ifname for link-local discovery scopes. Fixes #283.

This commit is contained in:
Mark Qvist 2023-05-02 17:39:06 +02:00
parent 30021d89cb
commit 3848059f19
1 changed files with 5 additions and 1 deletions

View File

@ -196,7 +196,11 @@ class AutoInterface(Interface):
discovery_socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_JOIN_GROUP, mcast_group) discovery_socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_JOIN_GROUP, mcast_group)
# Bind socket # Bind socket
if self.discovery_scope == AutoInterface.SCOPE_LINK:
addr_info = socket.getaddrinfo(mcast_addr+"%"+ifname, self.discovery_port, socket.AF_INET6, socket.SOCK_DGRAM) addr_info = socket.getaddrinfo(mcast_addr+"%"+ifname, self.discovery_port, socket.AF_INET6, socket.SOCK_DGRAM)
else:
addr_info = socket.getaddrinfo(mcast_addr, self.discovery_port, socket.AF_INET6, socket.SOCK_DGRAM)
discovery_socket.bind(addr_info[0][4]) discovery_socket.bind(addr_info[0][4])
# Set up thread for discovery packets # Set up thread for discovery packets