From ce5e1df673b3f7c05274f4ac527503943c49797e Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 13 Jan 2023 17:06:16 +0100 Subject: [PATCH] Fix DNS lookup for ``upload`` Fix DNS lookup for ``upload`` from ota server using http regression from v12.3.1.1 --- CHANGELOG.md | 1 + .../src/HttpClientLight.cpp | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba3ec5ac0..a663d6195 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ All notable changes to this project will be documented in this file. - Orno WE517 modbus serial config 8E1 setting (#17545) - No IP address shown when in AP mode regression from v12.3.1.1 (#17599) - Rename ``tasmota4M.bin`` to ``tasmota-4M.bin`` to solve use of ``tasmota-minimal.bin`` (#17674) +- DNS lookup for ``upload`` from ota server using http regression from v12.3.1.1 ### Removed diff --git a/lib/libesp32/Berry-HttpClientLight/src/HttpClientLight.cpp b/lib/libesp32/Berry-HttpClientLight/src/HttpClientLight.cpp index d8c85b2ac..3b66ca539 100644 --- a/lib/libesp32/Berry-HttpClientLight/src/HttpClientLight.cpp +++ b/lib/libesp32/Berry-HttpClientLight/src/HttpClientLight.cpp @@ -39,6 +39,7 @@ #include #include "HttpClientLight.h" +#include "ESP8266WiFi.h" #ifdef USE_WEBCLIENT_HTTPS #include "WiFiClientSecureLightBearSSL.h" @@ -1158,9 +1159,21 @@ bool HTTPClientLight::connect(void) return false; } #endif - if(!_client->connect(_host.c_str(), _port, _connectTimeout)) { - log_d("failed connect to %s:%u", _host.c_str(), _port); - return false; + if (_protocol == "https") { + if(!_client->connect(_host.c_str(), _port, _connectTimeout)) { + log_d("failed connect to %s:%u", _host.c_str(), _port); + return false; + } + } else { + IPAddress remote_addr; + // Add include "ESP8266WiFi.h" for this to work + if (!WiFi.hostByName(_host.c_str(), remote_addr)) { + return false; + } + if(!_client->connect(remote_addr, _port, _connectTimeout)) { + log_d("failed connect to %s:%u", _host.c_str(), _port); + return false; + } } // set Timeout for WiFiClient and for Stream::readBytesUntil() and Stream::readStringUntil()