mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
mDNS resolution for *.local fixes #16269
"Add user control over DNS timeout reducing blocking" c988ba1645
created DnsClient so that a timeout can be used to prevent blocking on ESP32, but it can't do one-shot mDNS queries. Use WiFi.hostByName () for those.
This commit is contained in:
parent
204289e1ab
commit
16c39aab9e
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user