Bridge support for MQTT v3.1.1.
This commit is contained in:
parent
be6a6430dd
commit
87d8e1f705
@ -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.
|
||||
|
@ -899,6 +899,31 @@
|
||||
with multiple addresses.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>bridge_attempt_unsubscribe</option> [ true | false ]</term>
|
||||
<listitem>
|
||||
<para>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
|
||||
<option>bridge_attempt_unsubscribe</option> to
|
||||
<replaceable>false</replaceable> will disable sending
|
||||
the unsubscribe request. Defaults to
|
||||
<replaceable>true</replaceable>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>bridge_protocol_version</option> <replaceable>version</replaceable></term>
|
||||
<listitem>
|
||||
<para>Set the version of the MQTT protocol to use with for
|
||||
this bridge. Can be one of
|
||||
<replaceable>mqttv31</replaceable> or
|
||||
<replaceable>mqttv311</replaceable>. Defaults to
|
||||
<replaceable>mqttv31</replaceable>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>cleansession</option> [ true | false ]</term>
|
||||
<listitem>
|
||||
|
@ -631,6 +631,10 @@
|
||||
#address <host>[:<port>] [<host>[:<port>]]
|
||||
#topic <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
|
||||
|
@ -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){
|
||||
|
25
src/conf.c
25
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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user