Plugins using MOSQ_EVT_MESSAGE can reject based on quota.

This commit is contained in:
Roger A. Light
2021-05-21 16:22:16 +01:00
parent b051b62251
commit 86ebf1149e
3 changed files with 11 additions and 0 deletions
+4
View File
@@ -19,6 +19,10 @@ Broker:
- Add `--tls-keylog` option which can be used to generate a file that can be
used by wireshark to decrypt TLS traffic for debugging purposes. Closes #1818.
- Add support for delayed basic authentication in plugins.
- Plugins using the MOSQ_EVT_MESSAGE callback can now return
MOSQ_ERR_QUOTA_EXCEEDED to have the message be rejected. MQTT v5 clients
using QoS 1 or 2 will receive the quota-exceeded reason code in the
corresponding PUBACK/PUBREC.
Client library:
- Add MOSQ_OPT_DISABLE_SOCKETPAIR to allow the disabling of the socketpair
+1
View File
@@ -85,6 +85,7 @@ extern "C" {
/* Error values */
enum mosq_err_t {
MOSQ_ERR_QUOTA_EXCEEDED = -6,
MOSQ_ERR_AUTH_DELAYED = -5,
MOSQ_ERR_AUTH_CONTINUE = -4,
MOSQ_ERR_NO_SUBSCRIBERS = -3,
+6
View File
@@ -278,6 +278,12 @@ int handle__publish(struct mosquitto *context)
reason_code = MQTT_RC_NOT_AUTHORIZED;
goto process_bad_message;
}else if(rc == MOSQ_ERR_QUOTA_EXCEEDED){
log__printf(NULL, MOSQ_LOG_DEBUG,
"Rejected PUBLISH from %s, quota exceeded.", context->id);
reason_code = MQTT_RC_QUOTA_EXCEEDED;
goto process_bad_message;
}else if(rc != MOSQ_ERR_SUCCESS){
db__msg_store_free(msg);
return rc;