mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 04:36:31 +00:00
Use Wifi.hostByName() for ESP8266
Saves ~1K on ESP8266. Also, the check for resolving to 255.255.255.255 is already done by Wifi.hostByName().
This commit is contained in:
parent
c3fc050eba
commit
03f2e0b6e9
@ -817,15 +817,17 @@ void wifiKeepAlive(void) {
|
|||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
|
|
||||||
bool WifiHostByName(const char* aHostname, IPAddress& aResult) {
|
bool WifiHostByName(const char* aHostname, IPAddress& aResult) {
|
||||||
|
#ifdef ESP8266
|
||||||
|
if (WiFi.hostByName(aHostname, aResult, Settings->dns_timeout)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#else
|
||||||
// DnsClient can't do one-shot mDNS queries so use WiFi.hostByName() for *.local
|
// DnsClient can't do one-shot mDNS queries so use WiFi.hostByName() for *.local
|
||||||
size_t hostname_len = strlen(aHostname);
|
size_t hostname_len = strlen(aHostname);
|
||||||
if (strstr_P(aHostname, PSTR(".local")) == &aHostname[hostname_len] - 6) {
|
if (strstr_P(aHostname, PSTR(".local")) == &aHostname[hostname_len] - 6) {
|
||||||
if (WiFi.hostByName(aHostname, aResult)) {
|
if (WiFi.hostByName(aHostname, aResult)) {
|
||||||
// Host name resolved
|
|
||||||
if (0xFFFFFFFF != (uint32_t)aResult) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Use this instead of WiFi.hostByName or connect(host_name,.. to block less if DNS server is not found
|
// 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];
|
uint32_t dns_address = (!TasmotaGlobal.global_state.eth_down) ? Settings->eth_ipv4_address[3] : Settings->ipv4_address[3];
|
||||||
@ -834,6 +836,7 @@ bool WifiHostByName(const char* aHostname, IPAddress& aResult) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("DNS: Unable to resolve '%s'"), aHostname);
|
AddLog(LOG_LEVEL_DEBUG, PSTR("DNS: Unable to resolve '%s'"), aHostname);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user