Revert "Add support for sending direct messages to clients."

This reverts commit 8f54cde293.
pull/139/head
Roger A. Light 10 years ago
parent 8f54cde293
commit 559e2438cb

@ -25,8 +25,6 @@ Broker:
- Minimum supported libwebsockets version is now 1.3.
- Support for Windows XP has been dropped.
- Miscellaneous fixes on Windows.
- Add support for sending direct messages to clients through
$CLIENT/direct/<client id>, using the allow_direct_messages option.
Client library:
- Outgoing messages with QoS>1 are no longer retried after a timeout period.

@ -163,23 +163,6 @@
<para>Reloaded on reload signal.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>allow_direct_messages</option> [ true | false ]</term>
<listitem>
<para>If this option is enabled, messages published to
<replaceable>$CLIENTS/direct/&lt;client
id&gt;</replaceable> will be delivered to the
client with <replaceable>&lt;client
id&gt;</replaceable> directly. It is not possible
to subscribe to any topics under $CLIENTS manually.
This is a non-spec option and should be used with care.
Clients that are not expecting these messages may not
be able to cope with them. See also
<option>direct_message_qos</option>. Defaults to
<replaceable>false</replaceable>.</para>
<para>Reloaded on reload signal.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>allow_duplicate_messages</option> [ true | false ]</term>
<listitem>
@ -281,26 +264,6 @@
<para>Reloaded on reload signal.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>direct_message_qos</option> [ 0 | 1 | 2 | msg ]</term>
<listitem>
<para>As clients do not subscribe to direct messages
manually, they have no opportunity to set the QoS. This
option allows a global QoS to be set for direct
messages. Choose either <replaceable>0</replaceable>,
<replaceable>1</replaceable>,
<replaceable>2</replaceable>, or
<replaceable>msg</replaceable> - where
<replaceable>msg</replaceable> indicates that the QoS
of the incoming message should be used. Note that
<option>upgrade_outgoing_qos</option> also affects this
setting. The option
<option>allow_direct_messages</option> must be
<replaceable>true</replaceable> for this option to have
any effect.</para>
<para>Reloaded on reload signal.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>include_dir</option> <replaceable>dir</replaceable></term>
<listitem>

@ -118,20 +118,6 @@
# This is a non-standard option explicitly disallowed by the spec.
#upgrade_outgoing_qos false
# If this option is enabled, messages published to $CLIENTS/direct/<client id>
# will be delivered to the client with <client id> directly. It is not possible
# to subscribe to any topics under $CLIENTS manually. This is a non-spec option
# and should be used with care. Clients that are not expecting these messages
# may not be able to cope with them. See also direct_message_qos.
#allow_direct_messages false
# As clients do not subscribe to direct messages manually, they have no
# opportunity to set the QoS. This option allows a global QoS to be set for
# direct messages. Choose either 0, 1, 2, or msg - where msg indicates that the
# QoS of the incoming message should be used. Note that upgrade_outgoing_qos
# also affects this setting.
#direct_message_qos 0
# =================================================================
# Default listener
# =================================================================

@ -111,7 +111,6 @@ static void config__init_reload(struct mosquitto__config *config)
mosquitto__free(config->acl_file);
config->acl_file = NULL;
config->allow_anonymous = true;
config->allow_direct_messages = false;
config->allow_duplicate_messages = false;
config->allow_zero_length_clientid = true;
config->auto_id_prefix = NULL;
@ -121,7 +120,6 @@ static void config__init_reload(struct mosquitto__config *config)
mosquitto__free(config->clientid_prefixes);
config->connection_messages = true;
config->clientid_prefixes = NULL;
config->direct_message_qos = 0;
if(config->log_fptr){
fclose(config->log_fptr);
config->log_fptr = NULL;
@ -649,8 +647,6 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, const
#endif
}else if(!strcmp(token, "allow_anonymous")){
if(conf__parse_bool(&token, "allow_anonymous", &config->allow_anonymous, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "allow_direct_messages")){
if(conf__parse_bool(&token, "allow_direct_messages", &config->allow_direct_messages, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "allow_duplicate_messages")){
if(conf__parse_bool(&token, "allow_duplicate_messages", &config->allow_duplicate_messages, saveptr)) return MOSQ_ERR_INVAL;
}else if(!strcmp(token, "allow_zero_length_clientid")){
@ -1102,25 +1098,6 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, const
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available.");
#endif
}else if(!strcmp(token, "direct_message_qos")){
token = strtok_r(NULL, " ", &saveptr);
if(token){
if(!strcmp(token, "0")){
direct_message_qos = 0;
}else if(!strcmp(token, "1")){
direct_message_qos = 1;
}else if(!strcmp(token, "2")){
direct_message_qos = 2;
}else if(!strcmp(token, "msg")){
direct_messag_qos = -1;
}else{
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid direct_message_qos value (%s).", token);
return MOSQ_ERR_INVAL;
}
}else{
log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty direct_message_qos value in configuration.");
return MOSQ_ERR_INVAL;
}
}else if(!strcmp(token, "http_dir")){
#ifdef WITH_WEBSOCKETS
if(reload) continue; // Listeners not valid for reloading.

@ -165,7 +165,6 @@ struct mosquitto__config {
char *config_file;
char *acl_file;
bool allow_anonymous;
bool allow_direct_messages;
bool allow_duplicate_messages;
bool allow_zero_length_clientid;
char *auto_id_prefix;
@ -175,7 +174,6 @@ struct mosquitto__config {
char *clientid_prefixes;
bool connection_messages;
bool daemon;
int direct_message_qos;
struct mosquitto__listener default_listener;
struct mosquitto__listener *listeners;
int listener_count;

@ -678,18 +678,8 @@ int handle__subscribe(struct mosquitto_db *db, struct mosquitto *context)
sub = sub_mount;
}
if(!strncmp(sub, "$CLIENT/", 7)){
/* Access denied, never allow subs here. */
if(context->protocol == mosq_p_mqtt311){
qos = 0x80;
}else{
mosquitto__free(sub);
return MOSQ_ERR_PROTOCOL;
}
}
log__printf(NULL, MOSQ_LOG_DEBUG, "\t%s (QoS %d)", sub, qos);
#if 0
/* FIXME
* This section has been disabled temporarily. mosquitto_acl_check

@ -61,40 +61,14 @@ struct sub__token {
uint16_t topic_len;
};
static int subs__send_msg(struct mosquitto_db *db, struct mosquitto *context, int sub_qos, int retain, int msg_qos, struct mosquitto_msg_store *stored)
{
int final_qos;
bool final_retain;
uint16_t mid;
if(db->config->upgrade_outgoing_qos){
final_qos = sub_qos;
}else{
final_qos = (msg_qos > sub_qos)?sub_qos:msg_qos;
}
if(final_qos > 0){
mid = mosquitto__mid_generate(context);
}else{
mid = 0;
}
if(context->is_bridge){
/* If we know the client is a bridge then we should set retain
* even if the message is fresh. If we don't do this, retained
* messages won't be propagated. */
final_retain = retain;
}else{
/* Client is not a bridge and this isn't a stale message so
* retain should be false. */
final_retain = false;
}
return db__message_insert(db, context, mid, mosq_md_out, final_qos, final_retain, stored);
}
static int subs__process(struct mosquitto_db *db, struct mosquitto__subhier *hier, const char *source_id, const char *topic, int qos, int retain, struct mosquitto_msg_store *stored, bool set_retain)
{
int rc = 0;
int rc2;
int client_qos, msg_qos;
uint16_t mid;
struct mosquitto__subleaf *leaf;
bool client_retain;
leaf = hier->subs;
@ -133,7 +107,33 @@ static int subs__process(struct mosquitto_db *db, struct mosquitto__subhier *hie
leaf = leaf->next;
continue;
}else if(rc2 == MOSQ_ERR_SUCCESS){
if(subs__send_msg(db, leaf->context, leaf->qos, retain, qos, stored) != 0) return 1;
client_qos = leaf->qos;
if(db->config->upgrade_outgoing_qos){
msg_qos = client_qos;
}else{
if(qos > client_qos){
msg_qos = client_qos;
}else{
msg_qos = qos;
}
}
if(msg_qos){
mid = mosquitto__mid_generate(leaf->context);
}else{
mid = 0;
}
if(leaf->context->is_bridge){
/* If we know the client is a bridge then we should set retain
* even if the message is fresh. If we don't do this, retained
* messages won't be propagated. */
client_retain = retain;
}else{
/* Client is not a bridge and this isn't a stale message so
* retain should be false. */
client_retain = false;
}
if(db__message_insert(db, leaf->context, mid, mosq_md_out, msg_qos, client_retain, stored) == 1) rc = 1;
}else{
return 1; /* Application error */
}
@ -510,14 +510,11 @@ int sub__remove(struct mosquitto_db *db, struct mosquitto *context, const char *
return rc;
}
int sub__messages_queue(struct mosquitto_db *db, const char *source_id, const char *topic, int qos, int retain, struct mosquitto_msg_store **stored)
{
int rc = MOSQ_ERR_SUCCESS;
int rc = 0;
struct mosquitto__subhier *subhier;
struct sub__token *tokens = NULL;
struct mosquitto *context;
int sub_qos;
assert(db);
assert(topic);
@ -530,29 +527,6 @@ int sub__messages_queue(struct mosquitto_db *db, const char *source_id, const ch
*/
(*stored)->ref_count++;
if(db->config->allow_direct_messages){
if(!strncmp(UHPA_ACCESS_TOPIC(tokens), "$CLIENT", tokens->topic_len)){
tokens = tokens->next;
if(tokens && !strncmp(UHPA_ACCESS_TOPIC(tokens), "direct", tokens->topic_len)){
tokens = tokens->next;
if(tokens && tokens->topic_len > 0){
HASH_FIND(hh_id, db->contexts_by_id, UHPA_ACCESS_TOPIC(tokens), tokens->topic_len, context);
if(context){
if(db->config->direct_message_qos == -1){
sub_qos = qos;
}else{
sub_qos = db->config->direct_message_qos;
}
rc = subs__send_msg(db, context, sub_qos, retain, qos, *stored);
}
}
}
db__msg_store_deref(db, stored);
sub__topic_tokens_free(tokens);
return rc;
}
}
subhier = db->subs.children;
while(subhier){
if(!strcmp(UHPA_ACCESS_TOPIC(subhier), UHPA_ACCESS_TOPIC(tokens))){

Loading…
Cancel
Save