Failback to v4 resolver for AAAA records in DNSIP integration (#82740)
This commit is contained in:
parent
c8fbdde3b8
commit
1c86a543b7
2 changed files with 15 additions and 3 deletions
|
@ -19,6 +19,7 @@ from .const import (
|
|||
CONF_HOSTNAME,
|
||||
CONF_IPV4,
|
||||
CONF_IPV6,
|
||||
CONF_IPV6_V4,
|
||||
CONF_RESOLVER,
|
||||
CONF_RESOLVER_IPV6,
|
||||
DEFAULT_HOSTNAME,
|
||||
|
@ -61,10 +62,12 @@ async def async_validate_hostname(
|
|||
tasks = await asyncio.gather(
|
||||
async_check(hostname, resolver_ipv4, "A"),
|
||||
async_check(hostname, resolver_ipv6, "AAAA"),
|
||||
async_check(hostname, resolver_ipv4, "AAAA"),
|
||||
)
|
||||
|
||||
result[CONF_IPV4] = tasks[0]
|
||||
result[CONF_IPV6] = tasks[1]
|
||||
result[CONF_IPV6_V4] = tasks[2]
|
||||
|
||||
return result
|
||||
|
||||
|
@ -98,7 +101,15 @@ class DnsIPConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
|
||||
validate = await async_validate_hostname(hostname, resolver, resolver_ipv6)
|
||||
|
||||
if not validate[CONF_IPV4] and not validate[CONF_IPV6]:
|
||||
set_resolver = resolver
|
||||
if validate[CONF_IPV6]:
|
||||
set_resolver = resolver_ipv6
|
||||
|
||||
if (
|
||||
not validate[CONF_IPV4]
|
||||
and not validate[CONF_IPV6]
|
||||
and not validate[CONF_IPV6_V4]
|
||||
):
|
||||
errors["base"] = "invalid_hostname"
|
||||
else:
|
||||
await self.async_set_unique_id(hostname)
|
||||
|
@ -110,11 +121,11 @@ class DnsIPConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
CONF_HOSTNAME: hostname,
|
||||
CONF_NAME: name,
|
||||
CONF_IPV4: validate[CONF_IPV4],
|
||||
CONF_IPV6: validate[CONF_IPV6],
|
||||
CONF_IPV6: validate[CONF_IPV6] or validate[CONF_IPV6_V4],
|
||||
},
|
||||
options={
|
||||
CONF_RESOLVER: resolver,
|
||||
CONF_RESOLVER_IPV6: resolver_ipv6,
|
||||
CONF_RESOLVER_IPV6: set_resolver,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ CONF_RESOLVER = "resolver"
|
|||
CONF_RESOLVER_IPV6 = "resolver_ipv6"
|
||||
CONF_IPV4 = "ipv4"
|
||||
CONF_IPV6 = "ipv6"
|
||||
CONF_IPV6_V4 = "ipv6_v4"
|
||||
|
||||
DEFAULT_HOSTNAME = "myip.opendns.com"
|
||||
DEFAULT_IPV6 = False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue