diff --git a/ChangeLog.txt b/ChangeLog.txt index 292c3b26..b42091fc 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -19,6 +19,7 @@ Important changes: - Wildcard TLS certificates are now supported for bridges and clients. - The clients have support for config files with default options. - Client and client libraries have support for MQTT v3.1.1. +- Bridge support for MQTT v3.1.1. Broker: @@ -57,6 +58,7 @@ Broker: - Wildcard TLS certificates are now supported for bridges. - Support for "hour" client expiration lengths for the persistent_client_expiration option. Closes bug #425835. +- Bridge support for MQTT v3.1.1. Clients: - Both clients can now load default configuration options from a file. diff --git a/man/mosquitto.conf.5.xml b/man/mosquitto.conf.5.xml index 28586d36..9119867f 100644 --- a/man/mosquitto.conf.5.xml +++ b/man/mosquitto.conf.5.xml @@ -899,6 +899,31 @@ with multiple addresses. + + [ true | false ] + + If a bridge has topics that have "out" direction, the + default behaviour is to send an unsubscribe request to + the remote broker on that topic. This means that + changing a topic direction from "in" to "out" will not + keep receiving incoming messages. Sending these + unsubscribe requests is not always desirable, setting + to + false will disable sending + the unsubscribe request. Defaults to + true. + + + + version + + Set the version of the MQTT protocol to use with for + this bridge. Can be one of + mqttv31 or + mqttv311. Defaults to + mqttv31. + + [ true | false ] diff --git a/mosquitto.conf b/mosquitto.conf index 5afc12a1..8480b3c6 100644 --- a/mosquitto.conf +++ b/mosquitto.conf @@ -631,6 +631,10 @@ #address [:] [[:]] #topic [[[out | in | both] qos-level] local-prefix remote-prefix] +# Set the version of the MQTT protocol to use with for this bridge. Can be one +# of mqttv31 or mqttv311. Defaults to mqttv31. +#bridge_protocol_version mqttv31 + # If a bridge has topics that have "out" direction, the default behaviour is to # send an unsubscribe request to the remote broker on that topic. This means # that changing a topic direction from "in" to "out" will not keep receiving diff --git a/src/bridge.c b/src/bridge.c index 9da398c8..58f0dec0 100644 --- a/src/bridge.c +++ b/src/bridge.c @@ -120,6 +120,7 @@ int mqtt3_bridge_new(struct mosquitto_db *db, struct _mqtt3_bridge *bridge) #endif bridge->try_private_accepted = true; + new_context->protocol = bridge->protocol_version; bridges = _mosquitto_realloc(db->bridges, (db->bridge_count+1)*sizeof(struct mosquitto *)); if(bridges){ diff --git a/src/conf.c b/src/conf.c index e2daf5e1..bad57a18 100644 --- a/src/conf.c +++ b/src/conf.c @@ -858,6 +858,30 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char } #else _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge and/or TLS support not available."); +#endif + }else if(!strcmp(token, "bridge_protocol_version")){ +#ifdef WITH_BRIDGE + if(reload) continue; // FIXME + if(!cur_bridge){ + _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration."); + return MOSQ_ERR_INVAL; + } + token = strtok_r(NULL, " ", &saveptr); + if(token){ + if(!strcmp(token, "mqttv31")){ + cur_bridge->protocol_version = mosq_p_mqtt31; + }else if(!strcmp(token, "mqttv311")){ + cur_bridge->protocol_version = mosq_p_mqtt311; + }else{ + _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge_protocol_version value (%s).", token); + return MOSQ_ERR_INVAL; + } + }else{ + _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty bridge_protocol_version value in configuration."); + return MOSQ_ERR_INVAL; + } +#else + _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available."); #endif }else if(!strcmp(token, "bridge_psk")){ #if defined(WITH_BRIDGE) && defined(REAL_WITH_TLS_PSK) @@ -1019,6 +1043,7 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char cur_bridge->threshold = 10; cur_bridge->try_private = true; cur_bridge->attempt_unsubscribe = true; + cur_bridge->protocol_version = mosq_p_mqtt31; }else{ _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty connection value in configuration."); return MOSQ_ERR_INVAL; diff --git a/src/mosquitto_broker.h b/src/mosquitto_broker.h index 2587df00..a673a2e4 100644 --- a/src/mosquitto_broker.h +++ b/src/mosquitto_broker.h @@ -286,6 +286,7 @@ struct _mqtt3_bridge{ struct _mqtt3_bridge_topic *topics; int topic_count; bool topic_remapping; + enum _mosquitto_protocol protocol_version; time_t restart_t; char *remote_clientid; char *remote_username;