Patch zeroconf

This commit is contained in:
Xoconoch
2025-08-07 09:52:59 -06:00
parent 4f8364441c
commit bd75f2f5cc

View File

@@ -23,6 +23,8 @@ import zeroconf
class ZeroconfServer(Closeable):
logger = logging.getLogger("Librespot:ZeroconfServer")
logger.propagate = False
service = "_spotify-connect._tcp.local."
__connecting_username: typing.Union[str, None] = None
__connection_lock = threading.Condition()
@@ -65,7 +67,9 @@ class ZeroconfServer(Closeable):
listen_port = random.randint(self.__min_port + 1, self.__max_port)
self.__runner = ZeroconfServer.HttpRunner(self, listen_port)
threading.Thread(target=self.__runner.run,
name="zeroconf-http-server").start()
name="zeroconf-http-server",
daemon=True).start()
self.__zeroconf = zeroconf.Zeroconf()
advertised_ip_str = self._get_local_ip()
@@ -120,7 +124,7 @@ class ZeroconfServer(Closeable):
hostname = socket.gethostname()
# gethostbyname can return 127.0.0.1 if hostname resolves to it
ip_address = socket.gethostbyname(hostname)
self.logger.info(f"IP from socket.gethostbyname('{hostname}'): {ip_address}")
self.logger.info(f"IP from socket.gethostname('{hostname}'): {ip_address}")
except socket.gaierror:
self.logger.error(
f"socket.gaierror resolving hostname '{socket.gethostname()}'. Falling back to 0.0.0.0."
@@ -414,4 +418,4 @@ class ZeroconfServer(Closeable):
self.device_id = util.random_hex_string(
40).lower() if not device_id else device_id
self.device_type = device_type
self.preferred_locale = preferred_locale
self.preferred_locale = preferred_locale