Rename remote bridge identifiers to remote_.

pull/211/merge
Roger A. Light 11 years ago
parent a03465da3f
commit b937a043e7

@ -902,15 +902,6 @@
normal.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>clientid</option> <replaceable>id</replaceable></term>
<listitem>
<para>Set the client id for this bridge connection. If not
defined, this defaults to 'name.hostname', where name
is the connection name and hostname is the hostname of
this computer.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>connection</option> <replaceable>name</replaceable></term>
<listitem>
@ -988,13 +979,41 @@
</listitem>
</varlistentry>
<varlistentry>
<term><option>password</option> <replaceable>value</replaceable></term>
<term><option>remote_clientid</option> <replaceable>id</replaceable></term>
<listitem>
<para>Set the client id for this bridge connection. If not
defined, this defaults to 'name.hostname', where name
is the connection name and hostname is the hostname of
this computer.</para>
<para>This replaces the old "clientid" option to avoid
confusion with local/remote sides of the bridge.
"clientid" remains valid for the time being.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>remote_password</option> <replaceable>value</replaceable></term>
<listitem>
<para>Configure a password for the bridge. This is used for
authentication purposes when connecting to a broker
that support MQTT v3.1 and requires a username and/or
password to connect. This option is only valid if a
username is also supplied.</para>
that supports MQTT v3.1 and up and requires a username
and/or password to connect. This option is only valid
if a remote_username is also supplied.</para>
<para>This replaces the old "password" option to avoid
confusion with local/remote sides of the bridge.
"password" remains valid for the time being.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>remote_username</option> <replaceable>name</replaceable></term>
<listitem>
<para>Configure a username for the bridge. This is used for
authentication purposes when connecting to a broker
that supports MQTT v3.1 and up and requires a username
and/or password to connect. See also the
<option>remote_password</option> option.</para>
<para>This replaces the old "username" option to avoid
confusion with local/remote sides of the bridge.
"username" remains valid for the time being.</para>
</listitem>
</varlistentry>
<varlistentry>
@ -1172,16 +1191,6 @@ topic clients/total in 0 test/mosquitto/org $SYS/broker/
<para>Defaults to <replaceable>true</replaceable>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>username</option> <replaceable>name</replaceable></term>
<listitem>
<para>Configure a <option>username</option> for the bridge.
This is used for authentication purposes when
connecting to a broker that support MQTT v3.1 and
requires a username and/or password to connect. See
also the <option>password</option> option.</para>
</listitem>
</varlistentry>
</variablelist>
<refsect2>
<title>SSL/TLS Support</title>

@ -626,7 +626,9 @@
# Set the client id to use on the remote end of this bridge connection. If not
# defined, this defaults to 'name.hostname' where name is the connection name
# and hostname is the hostname of this computer.
#clientid
# This replaces the old "clientid" option to avoid confusion. "clientid"
# remains valid for the time being.
#remote_clientid
# Set the clientid to use on the local broker. If not defined, this defaults to
# 'local.<clientid>'. If you are bridging a broker to itself, it is important
@ -699,14 +701,17 @@
# properly.
#try_private true
# Set the username to use when connecting to an MQTT v3.1 broker
# that requires authentication.
#username
# Set the password to use when connecting to an MQTT v3.1 broker
# that requires authentication. This option is only used if
# username is also set.
#password
# Set the username to use when connecting to a broker that requires
# authentication.
# This replaces the old "username" option to avoid confusion. "username"
# remains valid for the time being.
#remote_username
# Set the password to use when connecting to a broker that requires
# authentication. This option is only used if remote_username is also set.
# This replaces the old "password" option to avoid confusion. "password"
# remains valid for the time being.
#remote_password
# Set the username to use on the local broker.
#local_username

@ -52,7 +52,7 @@ int mqtt3_bridge_new(struct mosquitto_db *db, struct _mqtt3_bridge *bridge)
assert(db);
assert(bridge);
if(!bridge->clientid){
if(!bridge->remote_clientid){
if(!gethostname(hostname, 256)){
len = strlen(hostname) + strlen(bridge->name) + 2;
id = _mosquitto_malloc(len);
@ -63,7 +63,7 @@ int mqtt3_bridge_new(struct mosquitto_db *db, struct _mqtt3_bridge *bridge)
}else{
return 1;
}
bridge->clientid = id;
bridge->remote_clientid = id;
}
if(bridge->local_clientid){
local_id = _mosquitto_strdup(bridge->local_clientid);
@ -71,12 +71,12 @@ int mqtt3_bridge_new(struct mosquitto_db *db, struct _mqtt3_bridge *bridge)
return MOSQ_ERR_NOMEM;
}
}else{
len = strlen(bridge->clientid) + strlen("local.") + 2;
len = strlen(bridge->remote_clientid) + strlen("local.") + 2;
local_id = _mosquitto_malloc(len);
if(!local_id){
return MOSQ_ERR_NOMEM;
}
snprintf(local_id, len, "local.%s", bridge->clientid);
snprintf(local_id, len, "local.%s", bridge->remote_clientid);
bridge->local_clientid = _mosquitto_strdup(local_id);
if(!bridge->local_clientid){
_mosquitto_free(local_id);
@ -100,8 +100,8 @@ int mqtt3_bridge_new(struct mosquitto_db *db, struct _mqtt3_bridge *bridge)
new_context->bridge = bridge;
new_context->is_bridge = true;
new_context->username = new_context->bridge->username;
new_context->password = new_context->bridge->password;
new_context->username = new_context->bridge->remote_username;
new_context->password = new_context->bridge->remote_password;
#ifdef WITH_TLS
new_context->tls_cafile = new_context->bridge->tls_cafile;

@ -249,9 +249,9 @@ void mqtt3_config_cleanup(struct mqtt3_config *config)
}
_mosquitto_free(config->bridges[i].addresses);
}
if(config->bridges[i].clientid) _mosquitto_free(config->bridges[i].clientid);
if(config->bridges[i].username) _mosquitto_free(config->bridges[i].username);
if(config->bridges[i].password) _mosquitto_free(config->bridges[i].password);
if(config->bridges[i].remote_clientid) _mosquitto_free(config->bridges[i].remote_clientid);
if(config->bridges[i].remote_username) _mosquitto_free(config->bridges[i].remote_username);
if(config->bridges[i].remote_password) _mosquitto_free(config->bridges[i].remote_password);
if(config->bridges[i].local_clientid) _mosquitto_free(config->bridges[i].local_clientid);
if(config->bridges[i].local_username) _mosquitto_free(config->bridges[i].local_username);
if(config->bridges[i].local_password) _mosquitto_free(config->bridges[i].local_password);
@ -931,7 +931,7 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char
#else
_mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
#endif
}else if(!strcmp(token, "clientid")){
}else if(!strcmp(token, "clientid") || !strcmp(token, "remote_clientid")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(!cur_bridge){
@ -940,12 +940,12 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char
}
token = strtok_r(NULL, " ", &saveptr);
if(token){
if(cur_bridge->clientid){
if(cur_bridge->remote_clientid){
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Duplicate clientid value in bridge configuration.");
return MOSQ_ERR_INVAL;
}
cur_bridge->clientid = _mosquitto_strdup(token);
if(!cur_bridge->clientid){
cur_bridge->remote_clientid = _mosquitto_strdup(token);
if(!cur_bridge->remote_clientid){
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory");
return MOSQ_ERR_NOMEM;
}
@ -1373,7 +1373,7 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char
#else
_mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
#endif
}else if(!strcmp(token, "password")){
}else if(!strcmp(token, "password") || !strcmp(token, "remote_password")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(!cur_bridge){
@ -1382,12 +1382,12 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char
}
token = strtok_r(NULL, " ", &saveptr);
if(token){
if(cur_bridge->password){
if(cur_bridge->remote_password){
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Duplicate password value in bridge configuration.");
return MOSQ_ERR_INVAL;
}
cur_bridge->password = _mosquitto_strdup(token);
if(!cur_bridge->password){
cur_bridge->remote_password = _mosquitto_strdup(token);
if(!cur_bridge->remote_password){
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory");
return MOSQ_ERR_NOMEM;
}
@ -1775,7 +1775,7 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char
}else if(!strcmp(token, "user")){
if(reload) continue; // Drop privileges user not valid for reloading.
if(_conf_parse_string(&token, "user", &config->user, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "username")){
}else if(!strcmp(token, "username") || !strcmp(token, "remote_username")){
#ifdef WITH_BRIDGE
if(reload) continue; // FIXME
if(!cur_bridge){
@ -1784,12 +1784,12 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char
}
token = strtok_r(NULL, " ", &saveptr);
if(token){
if(cur_bridge->username){
if(cur_bridge->remote_username){
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Duplicate username value in bridge configuration.");
return MOSQ_ERR_INVAL;
}
cur_bridge->username = _mosquitto_strdup(token);
if(!cur_bridge->username){
cur_bridge->remote_username = _mosquitto_strdup(token);
if(!cur_bridge->remote_username){
_mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory");
return MOSQ_ERR_NOMEM;
}

@ -114,11 +114,11 @@ void mqtt3_context_cleanup(struct mosquitto_db *db, struct mosquitto *context, b
_mosquitto_free(context->bridge->local_clientid);
context->bridge->local_clientid = NULL;
}
if(context->bridge->username){
context->bridge->username = NULL;
if(context->bridge->remote_username){
context->bridge->remote_username = NULL;
}
if(context->bridge->password){
context->bridge->password = NULL;
if(context->bridge->remote_password){
context->bridge->remote_password = NULL;
}
if(context->bridge->local_username){
context->bridge->local_username = NULL;

@ -260,15 +260,15 @@ struct _mqtt3_bridge{
int address_count;
time_t primary_retry;
bool round_robin;
char *clientid;
int keepalive;
bool clean_session;
struct _mqtt3_bridge_topic *topics;
int topic_count;
bool topic_remapping;
time_t restart_t;
char *username;
char *password;
char *remote_clientid;
char *remote_username;
char *remote_password;
char *local_clientid;
char *local_username;
char *local_password;

Loading…
Cancel
Save