From a4caa445b662865332fea213b46f75f31441f435 Mon Sep 17 00:00:00 2001 From: Mirko Vogt Date: Wed, 22 Jul 2026 21:38:42 +0000 Subject: [PATCH] connection_handler: resolve static server host via DNS The static server (CONFIG_SNAPSERVER_HOST) was only run through ipaddr_aton(), which parses numeric IP literals, so a DNS hostname failed outright. Fall back to netconn_gethostbyname() when it is not a numeric IP, so the configured host may be a hostname resolved on the device network. Build-shim branch based on 1dfe76aa (the commit the esphome integration pins); the upstream-master version of this fix is on nameresolution-addition. Assisted-By: Claude Opus 4.8 (1M context) --- components/snapclient/connection_handler.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/snapclient/connection_handler.c b/components/snapclient/connection_handler.c index 67da69b9..d04d515d 100644 --- a/components/snapclient/connection_handler.c +++ b/components/snapclient/connection_handler.c @@ -175,9 +175,15 @@ void setup_network(esp_netif_t** netif) { } if (ipaddr_aton(static_host, &remote_ip) == 0) { - ESP_LOGE(TAG, "can't convert static server address to numeric: %s", - static_host); - continue; + // Not a numeric IP literal - resolve the configured host via DNS so a + // hostname (not only a numeric address) works for the static server. + err_t host_err = netconn_gethostbyname(static_host, &remote_ip); + if (host_err != ERR_OK) { + ESP_LOGE(TAG, "can't resolve static server host '%s', err %d", + static_host, host_err); + vTaskDelay(pdMS_TO_TICKS(1000)); + continue; + } } remotePort = (uint16_t)static_port;