diff --git a/tasmota/tasmota_support/support_wifi.ino b/tasmota/tasmota_support/support_wifi.ino index 495fe71b8..899733c61 100644 --- a/tasmota/tasmota_support/support_wifi.ino +++ b/tasmota/tasmota_support/support_wifi.ino @@ -807,6 +807,17 @@ void wifiKeepAlive(void) { #endif // ESP8266 bool WifiHostByName(const char* aHostname, IPAddress& aResult) { + // DnsClient can't do one-shot mDNS queries so use WiFi.hostByName() for *.local + size_t hostname_len = strlen(aHostname); + if (strstr(aHostname, ".local") == &aHostname[hostname_len] - 6) { + if (WiFi.hostByName(aHostname, aResult)) { + // Host name resolved + if (0xFFFFFFFF != (uint32_t)aResult) { + return true; + } + return false; + } + } // Use this instead of WiFi.hostByName or connect(host_name,.. to block less if DNS server is not found uint32_t dns_address = (!TasmotaGlobal.global_state.eth_down) ? Settings->eth_ipv4_address[3] : Settings->ipv4_address[3]; DnsClient.begin((IPAddress)dns_address);