diff --git a/hassio/const.py b/hassio/const.py index 3e45005a9..c27cc021f 100644 --- a/hassio/const.py +++ b/hassio/const.py @@ -3,7 +3,7 @@ from pathlib import Path from ipaddress import ip_network -HASSIO_VERSION = "180" +HASSIO_VERSION = "181" URL_HASSIO_ADDONS = "https://github.com/home-assistant/hassio-addons" URL_HASSIO_VERSION = "https://version.home-assistant.io/{channel}.json" diff --git a/hassio/data/coredns.tmpl b/hassio/data/coredns.tmpl index 01ed22b0c..7ab08f4aa 100644 --- a/hassio/data/coredns.tmpl +++ b/hassio/data/coredns.tmpl @@ -1,8 +1,12 @@ .:53 { log + errors hosts /config/hosts { fallthrough } + template ANY AAAA local.hass.io hassio { + rcode NOERROR + } forward . $servers { except local.hass.io policy sequential diff --git a/hassio/dns.py b/hassio/dns.py index 798d2f9d9..a06bd81f0 100644 --- a/hassio/dns.py +++ b/hassio/dns.py @@ -120,8 +120,9 @@ class CoreDNS(JsonConfig, CoreSysAttributes): # Start is not Running if await self.instance.is_running(): - return - await self.start() + await self.restart() + else: + await self.start() async def unload(self) -> None: """Unload DNS forwarder.""" @@ -146,6 +147,8 @@ class CoreDNS(JsonConfig, CoreSysAttributes): self.version = self.instance.version self.save_data() + # Init Hosts / Run server + self.write_hosts() await self.start() async def update(self, version: Optional[str] = None) -> None: @@ -174,14 +177,13 @@ class CoreDNS(JsonConfig, CoreSysAttributes): async def restart(self) -> None: """Restart CoreDNS plugin.""" + self._write_corefile() with suppress(DockerAPIError): - await self.instance.stop() - await self.start() + await self.instance.restart() async def start(self) -> None: """Run CoreDNS.""" self._write_corefile() - self.write_hosts() # Start Instance _LOGGER.info("Start CoreDNS plugin") @@ -195,6 +197,7 @@ class CoreDNS(JsonConfig, CoreSysAttributes): """Reset Config / Hosts.""" self.servers = DNS_SERVERS + # Resets hosts with suppress(OSError): self.hosts.unlink() self._init_hosts() @@ -231,6 +234,7 @@ class CoreDNS(JsonConfig, CoreSysAttributes): ["homeassistant", "home-assistant"], write=False, ) + self.add_host(self.sys_docker.network.dns, ["dns"], write=False) def write_hosts(self) -> None: """Write hosts from memory to file.""" @@ -343,7 +347,7 @@ class CoreDNS(JsonConfig, CoreSysAttributes): continue resolv_lines.append(line.strip()) except OSError as err: - _LOGGER.error("Can't read local resolv: %s", err) + _LOGGER.warning("Can't read local resolv: %s", err) raise CoreDNSError() from None if nameserver in resolv_lines: @@ -357,5 +361,5 @@ class CoreDNS(JsonConfig, CoreSysAttributes): for line in resolv_lines: resolv.write(f"{line}\n") except OSError as err: - _LOGGER.error("Can't write local resolv: %s", err) + _LOGGER.warning("Can't write local resolv: %s", err) raise CoreDNSError() from None