mirror of
https://github.com/esphome/esphome.git
synced 2025-09-30 09:02:17 +01:00
Fix dashboard dns lookup delay
This commit is contained in:
@@ -6,6 +6,9 @@ import os
|
||||
import re
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from esphome.address_cache import AddressCache
|
||||
|
||||
from esphome.const import (
|
||||
CONF_COMMENT,
|
||||
CONF_ESPHOME,
|
||||
@@ -584,7 +587,7 @@ class EsphomeCore:
|
||||
# The current component being processed during validation
|
||||
self.current_component: str | None = None
|
||||
# Address cache for DNS and mDNS lookups from command line arguments
|
||||
self.address_cache: object | None = None
|
||||
self.address_cache: AddressCache | None = None
|
||||
|
||||
def reset(self):
|
||||
from esphome.pins import PIN_SCHEMA_REGISTRY
|
||||
|
@@ -364,14 +364,16 @@ class EsphomePortCommandWebSocket(EsphomeCommandWebSocket):
|
||||
addresses.extend(sort_ip_addresses(cached))
|
||||
dns_cache_entries[entry.name] = set(cached)
|
||||
|
||||
# Build cache arguments to pass to CLI
|
||||
# Build cache arguments to pass to CLI (normalize hostnames)
|
||||
for hostname, addrs in dns_cache_entries.items():
|
||||
normalized = hostname.rstrip(".").lower()
|
||||
cache_args.extend(
|
||||
["--dns-lookup-cache", f"{hostname}={','.join(sorted(addrs))}"]
|
||||
["--dns-lookup-cache", f"{normalized}={','.join(sorted(addrs))}"]
|
||||
)
|
||||
for hostname, addrs in mdns_cache_entries.items():
|
||||
normalized = hostname.rstrip(".").lower()
|
||||
cache_args.extend(
|
||||
["--mdns-lookup-cache", f"{hostname}={','.join(sorted(addrs))}"]
|
||||
["--mdns-lookup-cache", f"{normalized}={','.join(sorted(addrs))}"]
|
||||
)
|
||||
|
||||
if not addresses:
|
||||
|
Reference in New Issue
Block a user