Socket option check for OpenWRT compatibility

This commit is contained in:
Mark Qvist 2022-06-07 12:40:50 +02:00
parent c6df6293b2
commit 379e56b2ce

View File

@ -168,6 +168,7 @@ class AutoInterface(Interface):
# Set up multicast socket
discovery_socket = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
discovery_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
if hasattr(socket, "SO_REUSEPORT"):
discovery_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
discovery_socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_MULTICAST_IF, if_struct)