From c34ee66b92fd5a46504489da8a2f51a5e2680864 Mon Sep 17 00:00:00 2001 From: lougovsk Date: Fri, 23 Jun 2023 14:07:46 +0200 Subject: [PATCH] Added hostname resolution Currently one mqtt client requires an ip address. However, often we want to use hostname instead. This change should account for that --- sources/mqtt/mqtt.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sources/mqtt/mqtt.cpp b/sources/mqtt/mqtt.cpp index b681f64eb..656051f74 100644 --- a/sources/mqtt/mqtt.cpp +++ b/sources/mqtt/mqtt.cpp @@ -34,6 +34,10 @@ void mqtt::start(QString host, int port, QString username, QString password, boo QSTRING_CSTR(host), port, (is_ssl) ? "SSL": "NO SSL", (!username.isEmpty() || !password.isEmpty()) ? "YES" : "NO", (ignore_ssl_errors) ? "YES" : "NO"); QHostAddress adr(host); + QHostInfo info = QHostInfo::fromName(host); + if (!info.addresses().isEmpty()) { + adr = info.addresses().first(); + } if (is_ssl)