mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-10-26 22:10:45 +00:00
[DNS] Fix hostByName returning negative values when lookup failed
`hostByName` does only return `1` on success, however it may return a negative value when lookup failed. So need to check for the exact return value and not consider it a boolean return type.
This commit is contained in:
1 parent
488cb70ba9
commit
050017b2b0
3 files changed
+3
-3
No files matched your search
@@ -72,7 +72,7 @@ bool PingClass::ping(IPAddress dest, int16_t count) {
|
||||
bool PingClass::ping(const char* host, int16_t count) {
|
||||
IPAddress remote_addr;
|
||||
|
||||
if (WiFi.hostByName(host, remote_addr))
|
||||
if (WiFi.hostByName(host, remote_addr) == 1)
|
||||
return ping(remote_addr, count);
|
||||
|
||||
return false;
|
||||
|
||||
@@ -1173,7 +1173,7 @@ bool HTTPClientLight::connect(void)
|
||||
} else {
|
||||
IPAddress remote_addr;
|
||||
// Add include "ESP8266WiFi.h" for this to work
|
||||
if (!WiFi.hostByName(_host.c_str(), remote_addr)) {
|
||||
if (Network.hostByName(_host.c_str(), remote_addr) != 1) {
|
||||
return false;
|
||||
}
|
||||
if(!_client->connect(remote_addr, _port, _connectTimeout)) {
|
||||
|
||||
@@ -335,7 +335,7 @@ int WiFiClientSecure_light::connect(const char* name, uint16_t port, int32_t tim
|
||||
DEBUG_BSSL("connect(%s,%d)\n", name, port);
|
||||
IPAddress remote_addr;
|
||||
clearLastError();
|
||||
if (!WiFi.hostByName(name, remote_addr)) {
|
||||
if (Network.hostByName(name, remote_addr) != 1) {
|
||||
DEBUG_BSSL("connect: Name loopup failure\n");
|
||||
setLastError(ERR_CANT_RESOLVE_IP);
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user