Skip to content

Commit 1cd134f

Browse files
committed
mqtt: only use http-proxy() if it is supported
Signed-off-by: Attila Szakacs <attila.szakacs@oneidentity.com>
1 parent 1042b5a commit 1cd134f

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

configure.ac

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,24 @@ if test "x$enable_mqtt" = "xyes" || test "x$enable_mqtt" = "xauto"; then
13301330
if test "x$enable_mqtt" = "xyes" && test "x$libpaho_mqtt" = "xno"; then
13311331
AC_MSG_ERROR(libPAHO_MQTT not found)
13321332
fi
1333+
1334+
if test "x$libpaho_mqtt" = "xyes"; then
1335+
CPPFLAGS_SAVE="$CPPFLAGS"
1336+
LDFLAGS_SAVE="$LDFLAGS"
1337+
CPPFLAGS="$CPPFLAGS $LIBPAHO_MQTT_CFLAGS"
1338+
LDFLAGS="$LDFLAGS $LIBPAHO_MQTT_LIBS"
1339+
1340+
AC_CHECK_MEMBER([MQTTClient_connectOptions.httpProxy],
1341+
[have_paho_http_proxy=1],
1342+
[have_paho_http_proxy=0],
1343+
[[#include "MQTTClient.h"]])
1344+
1345+
CPPFLAGS="$CPPFLAGS_SAVE"
1346+
LDFLAGS="$LDFLAGS_SAVE"
1347+
1348+
AC_DEFINE_UNQUOTED(HAVE_PAHO_HTTP_PROXY, $have_paho_http_proxy, [libpaho-mqtt supports MQTTClient_connectOptions::httpProxy])
1349+
fi
1350+
13331351
enable_mqtt=$libpaho_mqtt
13341352
fi
13351353

modules/mqtt/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ if (NOT ENABLE_MQTT)
55
return()
66
endif()
77

8+
CHECK_STRUCT_HAS_MEMBER("MQTTClient_connectOptions" "httpProxy" "MQTTClient.h" SYSLOG_NG_HAVE_PAHO_HTTP_PROXY)
89

910
add_subdirectory(destination)
1011

modules/mqtt/destination/mqtt-destination.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,17 @@ _init(LogPipe *d)
298298
return FALSE;
299299
}
300300

301+
#if !SYSLOG_NG_HAVE_PAHO_HTTP_PROXY
302+
if (self->http_proxy)
303+
{
304+
msg_warning_once("WARNING: the http-proxy() option of the mqtt() destination "
305+
"is not supported on the current libpaho-mqtt version. "
306+
"If you would like to use this feature, update to at least libpaho-mqtt 1.3.7");
307+
g_free(self->http_proxy);
308+
self->http_proxy = NULL;
309+
}
310+
#endif
311+
301312
if (!log_threaded_dest_driver_init_method(d))
302313
{
303314
return FALSE;

modules/mqtt/destination/mqtt-worker.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,13 @@ _connect(LogThreadedDestWorker *s)
227227
conn_opts.username = owner->username;
228228
conn_opts.password = owner->password;
229229

230+
#if SYSLOG_NG_HAVE_PAHO_HTTP_PROXY
230231
if (owner->http_proxy)
231232
{
232233
conn_opts.httpProxy = owner->http_proxy;
233234
conn_opts.httpsProxy = owner->http_proxy;
234235
}
236+
#endif
235237

236238
MQTTClient_SSLOptions ssl_opts = _create_ssl_options(self);
237239
conn_opts.ssl = &ssl_opts;

syslog-ng-config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@
9292
#cmakedefine01 SYSLOG_NG_ENABLE_PYTHONv2
9393
#cmakedefine01 SYSLOG_NG_ENABLE_PYTHONv3
9494
#cmakedefine SYSLOG_NG_HAVE_RD_KAFKA_INIT_TRANSACTIONS
95+
#cmakedefine01 SYSLOG_NG_HAVE_PAHO_HTTP_PROXY

0 commit comments

Comments
 (0)