From 66f9184c74f19e3644408247372d93909d44c9fb Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Fri, 19 Aug 2022 17:23:20 -0400 Subject: [PATCH] zeroconf: support binding to all interfaces Signed-off-by: Eric Callahan --- moonraker/components/zeroconf.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/moonraker/components/zeroconf.py b/moonraker/components/zeroconf.py index 254bcc2..84ac089 100644 --- a/moonraker/components/zeroconf.py +++ b/moonraker/components/zeroconf.py @@ -7,6 +7,7 @@ from __future__ import annotations import socket import asyncio import logging +import ipaddress from zeroconf import IPVersion from zeroconf.asyncio import AsyncServiceInfo, AsyncZeroconf @@ -50,8 +51,13 @@ class ZeroconfRegistrar: self.server = config.get_server() self.runner = AsyncRunner(IPVersion.All) hi = self.server.get_host_info() - addresses: Optional[List[bytes]] = [socket.inet_aton(hi["address"])] - self.bound_all = hi["address"] == "0.0.0.0" + addr: str = hi["address"] + if addr.lower() == "all": + addr = "::" + host_ip = ipaddress.ip_address(addr) + fam = socket.AF_INET6 if host_ip.version == 6 else socket.AF_INET + addresses: List[bytes] = [(socket.inet_pton(fam, addr))] + self.bound_all = addr in ["0.0.0.0", "::"] self.service_info = self._build_service_info(addresses) if self.bound_all: self.server.register_event_handler(