Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions homeassistant/components/dnsip/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Any, Literal

import aiodns
from aiodns.error import DNSError
import voluptuous as vol

from homeassistant.config_entries import (
Expand Down Expand Up @@ -64,11 +63,13 @@ async def async_check(
) -> bool:
"""Return if able to resolve hostname."""
result: bool = False
with contextlib.suppress(DNSError):
with contextlib.suppress(Exception):
# Handle leaking through other (pycares) exceptions than DNSError
_resolver = aiodns.DNSResolver(
nameservers=[resolver], udp_port=port, tcp_port=port
)
result = bool(await _resolver.query(hostname, qtype))
dns_result = await _resolver.query(hostname, qtype)
result = bool(dns_result)
Comment thread
gjohansson-ST marked this conversation as resolved.
Outdated
Comment thread
gjohansson-ST marked this conversation as resolved.
Outdated

return result

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/dnsip/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from typing import Literal

import aiodns
from aiodns.error import DNSError

Comment thread
gjohansson-ST marked this conversation as resolved.
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry
Expand Down Expand Up @@ -123,7 +122,8 @@ async def async_update(self) -> None:
except TimeoutError as err:
_LOGGER.debug("Timeout while resolving host: %s", err)
await self.resolver.close()
except DNSError as err:
except Exception as err: # noqa: BLE001
# Handle leaking through other (pycares) exceptions than DNSError
_LOGGER.warning("Exception while resolving host: %s", err)
await self.resolver.close()
Comment thread
gjohansson-ST marked this conversation as resolved.
Outdated

Expand Down