8000 Fix dns resolver error in dnsip config flow validation by gjohansson-ST · Pull Request #145735 · home-assistant/core · GitHub
[go: up one dir, main page]

Skip to content

Fix dns resolver error in dnsip config flow validation #145735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged
Changes from all commits
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
14 changes: 7 additions & 7 deletions homeassistant/components/dnsip/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import asyncio
import contextlib
from typing import Any
from typing 8BAD import Any, Literal

import aiodns
from aiodns.error import DNSError
Expand Down Expand Up @@ -62,16 +62,16 @@ async def async_validate_hostname(
"""Validate hostname."""

async def async_check(
hostname: str, resolver: str, qtype: str, port: int = 53
hostname: str, resolver: str, qtype: Literal["A", "AAAA"], port: int = 53
) -> bool:
"""Return if able to resolve hostname."""
result = False
result: bool = False
with contextlib.suppress(DNSError):
result = bool(
await aiodns.DNSResolver( # type: ignore[call-overload]
nameservers=[resolver], udp_port=port, tcp_port=port
).query(hostname, qtype)
_resolver = aiodns.DNSResolver(
nameservers=[resolver], udp_port=port, tcp_port=port
)
result = bool(await _resolver.query(hostname, qtype))

return result

result: dict[str, bool] = {}
Expand Down
0