Remove anything behind .local and ignore case

This commit is contained in:
Blaž Kristan 2025-07-15 13:36:44 +02:00
parent 24f2306129
commit 07e303bcc1

View File

@ -215,7 +215,9 @@ bool initMqtt()
} else {
#ifdef ARDUINO_ARCH_ESP32
String mqttMDNS = mqttServer;
mqttMDNS.replace(F(".local"), ""); // remove .local if present
mqttMDNS.toLowerCase(); // make sure we have a lowercase hostname
int pos = mqttMDNS.indexOf(F(".local"));
if (pos > 0) mqttMDNS.remove(pos); // remove .local domain if present (and anything following it)
if (strlen(cmDNS) > 0 && mqttMDNS.length() > 0 && mqttMDNS.indexOf('.') < 0) { // if mDNS is enabled and server does not have domain
mqttIP = MDNS.queryHost(mqttMDNS.c_str());
if (mqttIP != IPAddress()) // if MDNS resolved the hostname