mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-24 17:44:08 +08:00
Merge branch 'master' into develop
This commit is contained in:
@@ -62,6 +62,8 @@ test/broker/c/auth_plugin.so
|
||||
test/broker/c/*.test
|
||||
|
||||
test/ssl/*.csr
|
||||
test/ssl/rootCA/
|
||||
test/ssl/signingCA/
|
||||
|
||||
test/lib/c/*.test
|
||||
test/lib/cpp/*.test
|
||||
|
||||
+4
-1
@@ -11,7 +11,7 @@ project(mosquitto)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
# Only for version 3 and up. cmake_policy(SET CMP0042 NEW)
|
||||
|
||||
set (VERSION 1.6.4)
|
||||
set (VERSION 1.6.7)
|
||||
|
||||
add_definitions (-DCMAKE -DVERSION=\"${VERSION}\")
|
||||
|
||||
@@ -50,6 +50,9 @@ endif (WITH_SOCKS)
|
||||
|
||||
option(WITH_SRV "Include SRV lookup support?" OFF)
|
||||
|
||||
option(WITH_STATIC_LIBRARIES "Build static versions of the libmosquitto/pp libraries?" OFF)
|
||||
option(WITH_PIC "Build the static library with PIC (Position Independent Code) enabled archives?" OFF)
|
||||
|
||||
option(WITH_THREADING "Include client library threading support?" ON)
|
||||
if (WITH_THREADING)
|
||||
add_definitions("-DWITH_THREADING")
|
||||
|
||||
@@ -12,6 +12,78 @@ Clients:
|
||||
- Add timeout return code (27) for `mosquitto_sub -W <secs>` and
|
||||
`mosquitto_rr -W <secs>`. Closes #275.
|
||||
|
||||
|
||||
1.6.7 - 20190925
|
||||
================
|
||||
|
||||
Broker:
|
||||
- Add workaround for working with libwebsockets 3.2.0.
|
||||
- Fix potential crash when reloading config. Closes #1424, #1425.
|
||||
|
||||
Client library:
|
||||
- Don't use `/` in autogenerated client ids, to avoid confusing with topics.
|
||||
- Fix `mosquitto_max_inflight_messages_set()` and `mosquitto_int_option(...,
|
||||
MOSQ_OPT_*_MAX, ...)` behaviour. Closes #1417.
|
||||
- Fix regression on use of `mosquitto_connect_async()` not working.
|
||||
Closes #1415 and #1422.
|
||||
|
||||
Clients:
|
||||
- mosquitto_sub: Fix `-E` incorrectly not working unless `-d` was also
|
||||
specified. Closes #1418.
|
||||
- Updated documentation around automatic client ids.
|
||||
|
||||
|
||||
1.6.6 - 20190917
|
||||
================
|
||||
|
||||
Security:
|
||||
- Restrict topic hierarchy to 200 levels to prevent possible stack overflow.
|
||||
Closes #1412.
|
||||
|
||||
Broker:
|
||||
- Restrict topic hierarchy to 200 levels to prevent possible stack overflow.
|
||||
Closes #1412.
|
||||
- mosquitto_passwd now returns 1 when attempting to update a user that does
|
||||
not exist. Closes #1414.
|
||||
|
||||
|
||||
1.6.5 - 20190912
|
||||
================
|
||||
|
||||
Broker:
|
||||
- Fix v5 DISCONNECT packets with remaining length == 2 being treated as a
|
||||
protocol error. Closes #1367.
|
||||
- Fix support for libwebsockets 3.x.
|
||||
- Fix slow websockets performance when sending large messages. Closes #1390.
|
||||
- Fix bridges potentially not connecting on Windows. Closes #478.
|
||||
- Fix clients authorised using `use_identity_as_username` or
|
||||
`use_subject_as_username` being disconnected on SIGHUP. Closes #1402.
|
||||
- Improve error messages in some situations when clients disconnect. Reduces
|
||||
the number of "Socket error on client X, disconnecting" messages.
|
||||
- Fix Will for v5 clients not being sent if will delay interval was greater
|
||||
than the session expiry interval. Closes #1401.
|
||||
- Fix CRL file not being reloaded on HUP. Closes #35.
|
||||
- Fix repeated "Error in poll" messages on Windows when only websockets
|
||||
listeners are defined. Closes #1391.
|
||||
|
||||
Client library:
|
||||
- Fix reconnect backoff for the situation where connections are dropped rather
|
||||
than refused. Closes #737.
|
||||
- Fix missing locks on `mosq->state`. Closes #1374.
|
||||
|
||||
Documentation:
|
||||
- Improve details on global/per listener options in the mosquitto.conf man page.
|
||||
Closes #274.
|
||||
- Clarify behaviour when clients exceed the `message_size_limit`. Closes #448.
|
||||
- Improve documentation for `max_inflight_bytes`, `max_inflight_messages`,
|
||||
and `max_queued_messages`.
|
||||
|
||||
Build:
|
||||
- Fix missing function warnings on NetBSD.
|
||||
- Fix WITH_STATIC_LIBRARIES using CMake on Windows. Closes #1369.
|
||||
- Guard ssize_t definition on Windows. Closes #522.
|
||||
|
||||
|
||||
1.6.4 - 20190801
|
||||
================
|
||||
|
||||
|
||||
@@ -13,10 +13,15 @@ add_executable(mosquitto_pub pub_client.c pub_shared.c ${shared_src})
|
||||
add_executable(mosquitto_sub sub_client.c sub_client_output.c ${shared_src})
|
||||
add_executable(mosquitto_rr rr_client.c pub_shared.c sub_client_output.c ${shared_src})
|
||||
|
||||
|
||||
target_link_libraries(mosquitto_pub libmosquitto)
|
||||
target_link_libraries(mosquitto_sub libmosquitto)
|
||||
target_link_libraries(mosquitto_rr libmosquitto)
|
||||
if (WITH_STATIC_LIBRARIES)
|
||||
target_link_libraries(mosquitto_pub libmosquitto_static)
|
||||
target_link_libraries(mosquitto_sub libmosquitto_static)
|
||||
target_link_libraries(mosquitto_rr libmosquitto_static)
|
||||
else()
|
||||
target_link_libraries(mosquitto_pub libmosquitto)
|
||||
target_link_libraries(mosquitto_sub libmosquitto)
|
||||
target_link_libraries(mosquitto_rr libmosquitto)
|
||||
endif()
|
||||
|
||||
if (QNX)
|
||||
target_link_libraries(mosquitto_pub socket)
|
||||
|
||||
+7
-5
@@ -147,11 +147,13 @@ void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_c
|
||||
|
||||
UNUSED(obj);
|
||||
|
||||
if(!cfg.quiet) printf("Subscribed (mid: %d): %d", mid, granted_qos[0]);
|
||||
for(i=1; i<qos_count; i++){
|
||||
if(!cfg.quiet) printf(", %d", granted_qos[i]);
|
||||
if(cfg.debug){
|
||||
if(!cfg.quiet) printf("Subscribed (mid: %d): %d", mid, granted_qos[0]);
|
||||
for(i=1; i<qos_count; i++){
|
||||
if(!cfg.quiet) printf(", %d", granted_qos[i]);
|
||||
}
|
||||
if(!cfg.quiet) printf("\n");
|
||||
}
|
||||
if(!cfg.quiet) printf("\n");
|
||||
|
||||
if(cfg.exit_after_sub){
|
||||
mosquitto_disconnect_v5(mosq, 0, cfg.disconnect_props);
|
||||
@@ -324,8 +326,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if(cfg.debug){
|
||||
mosquitto_log_callback_set(mosq, my_log_callback);
|
||||
mosquitto_subscribe_callback_set(mosq, my_subscribe_callback);
|
||||
}
|
||||
mosquitto_subscribe_callback_set(mosq, my_subscribe_callback);
|
||||
mosquitto_connect_v5_callback_set(mosq, my_connect_callback);
|
||||
mosquitto_message_v5_callback_set(mosq, my_message_callback);
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ WITH_COVERAGE:=no
|
||||
|
||||
# Also bump lib/mosquitto.h, CMakeLists.txt,
|
||||
# installer/mosquitto.nsi, installer/mosquitto64.nsi
|
||||
VERSION=1.6.4
|
||||
VERSION=1.6.7
|
||||
|
||||
# Client library SO version. Bump if incompatible API/ABI changes are made.
|
||||
SOVERSION=1
|
||||
|
||||
@@ -9,5 +9,6 @@ RUN apk --no-cache add mosquitto=1.4.12-r0 && \
|
||||
chown -R mosquitto:mosquitto /mosquitto
|
||||
|
||||
COPY docker-entrypoint.sh /
|
||||
EXPOSE 1883
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["/usr/sbin/mosquitto", "-c", "/mosquitto/config/mosquitto.conf"]
|
||||
|
||||
@@ -3,8 +3,8 @@ FROM alpine:3.8
|
||||
LABEL maintainer="Roger Light <roger@atchoo.org>" \
|
||||
description="Eclipse Mosquitto MQTT Broker"
|
||||
|
||||
ENV VERSION=1.5.8 \
|
||||
DOWNLOAD_SHA256=78d7e70c3794dc3a1d484b4f2f8d3addebe9c2da3f5a1cebe557f7d13beb0da4 \
|
||||
ENV VERSION=1.5.9 \
|
||||
DOWNLOAD_SHA256=d7b62aa0ca680b0d869d6883373903362f98326a6465fc6cd01a0b9e0e8f0333 \
|
||||
GPG_KEYS=A0D6EEA1DCAE49A635A3B2F0779B22DFB3E717B7 \
|
||||
LWS_VERSION=2.4.2
|
||||
|
||||
@@ -59,7 +59,6 @@ RUN set -x && \
|
||||
LDFLAGS="-L/build/lws/lib -flto" \
|
||||
WITH_ADNS=no \
|
||||
WITH_DOCS=no \
|
||||
WITH_MEMORY_TRACKING=no \
|
||||
WITH_SHARED_LIBRARIES=no \
|
||||
WITH_SRV=no \
|
||||
WITH_STRIP=yes \
|
||||
@@ -84,5 +83,6 @@ VOLUME ["/mosquitto/data", "/mosquitto/log"]
|
||||
|
||||
# Set up the entry point script and default command
|
||||
COPY docker-entrypoint.sh /
|
||||
EXPOSE 1883
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["/usr/sbin/mosquitto", "-c", "/mosquitto/config/mosquitto.conf"]
|
||||
|
||||
@@ -3,8 +3,8 @@ FROM alpine:3.8
|
||||
LABEL maintainer="Roger Light <roger@atchoo.org>" \
|
||||
description="Eclipse Mosquitto MQTT Broker"
|
||||
|
||||
ENV VERSION=1.6.4 \
|
||||
DOWNLOAD_SHA256=a3d5822c249f6a6e13311b1b09eff6807ea01608a5a77934e1769842e9d146ef \
|
||||
ENV VERSION=1.6.7 \
|
||||
DOWNLOAD_SHA256=bcd31a8fbbd053fee328986fadd8666d3058357ded56b9782f7d4f19931d178e \
|
||||
GPG_KEYS=A0D6EEA1DCAE49A635A3B2F0779B22DFB3E717B7 \
|
||||
LWS_VERSION=2.4.2
|
||||
|
||||
@@ -59,7 +59,6 @@ RUN set -x && \
|
||||
LDFLAGS="-L/build/lws/lib" \
|
||||
WITH_ADNS=no \
|
||||
WITH_DOCS=no \
|
||||
WITH_MEMORY_TRACKING=yes \
|
||||
WITH_SHARED_LIBRARIES=yes \
|
||||
WITH_SRV=no \
|
||||
WITH_STRIP=yes \
|
||||
@@ -86,5 +85,6 @@ VOLUME ["/mosquitto/data", "/mosquitto/log"]
|
||||
|
||||
# Set up the entry point script and default command
|
||||
COPY docker-entrypoint.sh /
|
||||
EXPOSE 1883
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["/usr/sbin/mosquitto", "-c", "/mosquitto/config/mosquitto.conf"]
|
||||
|
||||
@@ -66,5 +66,6 @@ VOLUME ["/mosquitto/config", "/mosquitto/data", "/mosquitto/log"]
|
||||
|
||||
# Set up the entry point script and default command
|
||||
COPY docker-entrypoint.sh /
|
||||
EXPOSE 1883
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["/usr/sbin/mosquitto", "-c", "/mosquitto/config/mosquitto.conf"]
|
||||
|
||||
@@ -40,7 +40,6 @@ RUN set -x && \
|
||||
LDFLAGS="-L/build/lws/lib" \
|
||||
WITH_ADNS=no \
|
||||
WITH_DOCS=no \
|
||||
WITH_MEMORY_TRACKING=yes \
|
||||
WITH_SHARED_LIBRARIES=yes \
|
||||
WITH_SRV=no \
|
||||
WITH_STRIP=yes \
|
||||
@@ -67,5 +66,6 @@ VOLUME ["/mosquitto/data", "/mosquitto/log"]
|
||||
|
||||
# Set up the entry point script and default command
|
||||
COPY docker-entrypoint.sh /
|
||||
EXPOSE 1883
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["/usr/sbin/mosquitto", "-c", "/mosquitto/config/mosquitto.conf"]
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
!define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
|
||||
|
||||
Name "Eclipse Mosquitto"
|
||||
!define VERSION 1.6.4
|
||||
!define VERSION 1.6.7
|
||||
OutFile "mosquitto-${VERSION}-install-windows-x86.exe"
|
||||
|
||||
InstallDir "$PROGRAMFILES\mosquitto"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
!define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
|
||||
|
||||
Name "Eclipse Mosquitto"
|
||||
!define VERSION 1.6.4
|
||||
!define VERSION 1.6.7
|
||||
OutFile "mosquitto-${VERSION}-install-windows-x64.exe"
|
||||
|
||||
!include "x64.nsh"
|
||||
|
||||
+1
-3
@@ -1,5 +1,3 @@
|
||||
option(WITH_STATIC_LIBRARIES "Build static versions of the libmosquitto/pp libraries?" OFF)
|
||||
option(WITH_PIC "Build the static library with PIC (Position Independent Code) enabled archives?" OFF)
|
||||
add_subdirectory(cpp)
|
||||
|
||||
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/lib
|
||||
@@ -102,7 +100,7 @@ if (WITH_STATIC_LIBRARIES)
|
||||
target_link_libraries(libmosquitto_static ${LIBRARIES})
|
||||
|
||||
set_target_properties(libmosquitto_static PROPERTIES
|
||||
OUTPUT_NAME mosquitto
|
||||
OUTPUT_NAME mosquitto_static
|
||||
VERSION ${VERSION}
|
||||
)
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ ifeq ($(WITH_STATIC_LIBRARIES),yes)
|
||||
endif
|
||||
$(INSTALL) -d "${DESTDIR}${incdir}/"
|
||||
$(INSTALL) mosquitto.h "${DESTDIR}${incdir}/mosquitto.h"
|
||||
$(INSTALL) mqtt_protocol.h "${DESTDIR}${incdir}/mqtt_protocol.h"
|
||||
$(INSTALL) -d "${DESTDIR}${libdir}/pkgconfig"
|
||||
$(INSTALL) -m644 ../libmosquitto.pc.in "${DESTDIR}${libdir}/pkgconfig/libmosquitto.pc"
|
||||
sed -i -e "s#@CMAKE_INSTALL_PREFIX@#${prefix}#" -e "s#@VERSION@#${VERSION}#" "${DESTDIR}${libdir}/pkgconfig/libmosquitto.pc"
|
||||
|
||||
+14
-35
@@ -54,7 +54,7 @@ static int mosquitto__connect_init(struct mosquitto *mosq, const char *host, int
|
||||
mosq->id[1] = 'o';
|
||||
mosq->id[2] = 's';
|
||||
mosq->id[3] = 'q';
|
||||
mosq->id[4] = '/';
|
||||
mosq->id[4] = '-';
|
||||
|
||||
rc = util__random_bytes(&mosq->id[5], 18);
|
||||
if(rc) return rc;
|
||||
@@ -120,9 +120,7 @@ int mosquitto_connect_bind_v5(struct mosquitto *mosq, const char *host, int port
|
||||
rc = mosquitto__connect_init(mosq, host, port, keepalive, bind_address);
|
||||
if(rc) return rc;
|
||||
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
mosq->state = mosq_cs_new;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
mosquitto__set_state(mosq, mosq_cs_new);
|
||||
|
||||
return mosquitto__reconnect(mosq, true, properties);
|
||||
}
|
||||
@@ -139,10 +137,6 @@ int mosquitto_connect_bind_async(struct mosquitto *mosq, const char *host, int p
|
||||
int rc = mosquitto__connect_init(mosq, host, port, keepalive, bind_address);
|
||||
if(rc) return rc;
|
||||
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
mosq->state = mosq_cs_connect_async;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
|
||||
return mosquitto__reconnect(mosq, false, NULL);
|
||||
}
|
||||
|
||||
@@ -164,6 +158,7 @@ static int mosquitto__reconnect(struct mosquitto *mosq, bool blocking, const mos
|
||||
const mosquitto_property *outgoing_properties = NULL;
|
||||
mosquitto_property local_property;
|
||||
int rc;
|
||||
|
||||
if(!mosq) return MOSQ_ERR_INVAL;
|
||||
if(!mosq->host || mosq->port <= 0) return MOSQ_ERR_INVAL;
|
||||
if(mosq->protocol != mosq_p_mqtt5 && properties) return MOSQ_ERR_NOT_SUPPORTED;
|
||||
@@ -181,17 +176,6 @@ static int mosquitto__reconnect(struct mosquitto *mosq, bool blocking, const mos
|
||||
if(rc) return rc;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
#ifdef WITH_SOCKS
|
||||
if(mosq->socks5_host){
|
||||
mosq->state = mosq_cs_socks5_new;
|
||||
}else
|
||||
#endif
|
||||
{
|
||||
mosq->state = mosq_cs_new;
|
||||
}
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
|
||||
pthread_mutex_lock(&mosq->msgtime_mutex);
|
||||
mosq->last_msg_in = mosquitto_time();
|
||||
mosq->next_msg_out = mosq->last_msg_in + mosq->keepalive;
|
||||
@@ -215,28 +199,26 @@ static int mosquitto__reconnect(struct mosquitto *mosq, bool blocking, const mos
|
||||
}else
|
||||
#endif
|
||||
{
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
mosq->state = mosq_cs_connecting;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
rc = net__socket_connect(mosq, mosq->host, mosq->port, mosq->bind_address, blocking);
|
||||
}
|
||||
if(rc>0){
|
||||
mosquitto__set_state(mosq, mosq_cs_connect_pending);
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef WITH_SOCKS
|
||||
if(mosq->socks5_host){
|
||||
mosquitto__set_state(mosq, mosq_cs_socks5_new);
|
||||
return socks5__send(mosq);
|
||||
}else
|
||||
#endif
|
||||
{
|
||||
mosquitto__set_state(mosq, mosq_cs_connected);
|
||||
rc = send__connect(mosq, mosq->keepalive, mosq->clean_start, outgoing_properties);
|
||||
if(rc){
|
||||
packet__cleanup_all(mosq);
|
||||
net__socket_close(mosq);
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
mosq->state = mosq_cs_new;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
mosquitto__set_state(mosq, mosq_cs_new);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@@ -269,21 +251,18 @@ int mosquitto_disconnect_v5(struct mosquitto *mosq, int reason_code, const mosqu
|
||||
if(rc) return rc;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
mosq->state = mosq_cs_disconnecting;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
|
||||
if(mosq->sock == INVALID_SOCKET) return MOSQ_ERR_NO_CONN;
|
||||
return send__disconnect(mosq, reason_code, outgoing_properties);
|
||||
mosquitto__set_state(mosq, mosq_cs_disconnected);
|
||||
if(mosq->sock == INVALID_SOCKET){
|
||||
return MOSQ_ERR_NO_CONN;
|
||||
}else{
|
||||
return send__disconnect(mosq, reason_code, outgoing_properties);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void do_client_disconnect(struct mosquitto *mosq, int reason_code, const mosquitto_property *properties)
|
||||
{
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
mosq->state = mosq_cs_disconnecting;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
|
||||
mosquitto__set_state(mosq, mosq_cs_disconnected);
|
||||
net__socket_close(mosq);
|
||||
|
||||
/* Free data and reset values */
|
||||
|
||||
@@ -29,7 +29,7 @@ if (WITH_STATIC_LIBRARIES)
|
||||
target_link_libraries(mosquittopp_static ${LIBRARIES})
|
||||
|
||||
set_target_properties(mosquittopp_static PROPERTIES
|
||||
OUTPUT_NAME mosquittopp
|
||||
OUTPUT_NAME mosquittopp_static
|
||||
VERSION ${VERSION}
|
||||
)
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ Contributors:
|
||||
#ifndef MOSQUITTOPP_H
|
||||
#define MOSQUITTOPP_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(LIBMOSQUITTO_STATIC)
|
||||
# ifdef mosquittopp_EXPORTS
|
||||
# define mosqpp_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
|
||||
@@ -31,6 +31,9 @@ Contributors:
|
||||
static void connack_callback(struct mosquitto *mosq, uint8_t reason_code, uint8_t connect_flags, const mosquitto_property *properties)
|
||||
{
|
||||
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s received CONNACK (%d)", mosq->id, reason_code);
|
||||
if(reason_code == MQTT_RC_SUCCESS){
|
||||
mosq->reconnects = 0;
|
||||
}
|
||||
pthread_mutex_lock(&mosq->callback_mutex);
|
||||
if(mosq->on_connect){
|
||||
mosq->in_callback = true;
|
||||
@@ -108,7 +111,7 @@ int handle__connack(struct mosquitto *mosq)
|
||||
case 0:
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
if(mosq->state != mosq_cs_disconnecting){
|
||||
mosq->state = mosq_cs_connected;
|
||||
mosq->state = mosq_cs_active;
|
||||
}
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
message__retry_check(mosq);
|
||||
|
||||
+8
-2
@@ -37,9 +37,12 @@ Contributors:
|
||||
|
||||
int handle__pingreq(struct mosquitto *mosq)
|
||||
{
|
||||
int state;
|
||||
|
||||
assert(mosq);
|
||||
|
||||
if(mosq->state != mosq_cs_connected){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state != mosq_cs_active){
|
||||
return MOSQ_ERR_PROTOCOL;
|
||||
}
|
||||
|
||||
@@ -53,9 +56,12 @@ int handle__pingreq(struct mosquitto *mosq)
|
||||
|
||||
int handle__pingresp(struct mosquitto *mosq)
|
||||
{
|
||||
int state;
|
||||
|
||||
assert(mosq);
|
||||
|
||||
if(mosq->state != mosq_cs_connected){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state != mosq_cs_active){
|
||||
return MOSQ_ERR_PROTOCOL;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,10 +47,12 @@ int handle__pubackcomp(struct mosquitto *mosq, const char *type)
|
||||
int rc;
|
||||
mosquitto_property *properties = NULL;
|
||||
int qos;
|
||||
int state;
|
||||
|
||||
assert(mosq);
|
||||
|
||||
if(mosq->state != mosq_cs_connected){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state != mosq_cs_active){
|
||||
return MOSQ_ERR_PROTOCOL;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,12 @@ int handle__publish(struct mosquitto *mosq)
|
||||
uint16_t mid;
|
||||
int slen;
|
||||
mosquitto_property *properties = NULL;
|
||||
int state;
|
||||
|
||||
assert(mosq);
|
||||
|
||||
if(mosq->state != mosq_cs_connected){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state != mosq_cs_active){
|
||||
return MOSQ_ERR_PROTOCOL;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -41,10 +41,12 @@ int handle__pubrec(struct mosquitto_db *db, struct mosquitto *mosq)
|
||||
uint16_t mid;
|
||||
int rc;
|
||||
mosquitto_property *properties = NULL;
|
||||
int state;
|
||||
|
||||
assert(mosq);
|
||||
|
||||
if(mosq->state != mosq_cs_connected){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state != mosq_cs_active){
|
||||
return MOSQ_ERR_PROTOCOL;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -45,10 +45,12 @@ int handle__pubrel(struct mosquitto_db *db, struct mosquitto *mosq)
|
||||
#endif
|
||||
int rc;
|
||||
mosquitto_property *properties = NULL;
|
||||
int state;
|
||||
|
||||
assert(mosq);
|
||||
|
||||
if(mosq->state != mosq_cs_connected){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state != mosq_cs_active){
|
||||
return MOSQ_ERR_PROTOCOL;
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -29,6 +29,7 @@ Contributors:
|
||||
#include "mqtt_protocol.h"
|
||||
#include "packet_mosq.h"
|
||||
#include "property_mosq.h"
|
||||
#include "util_mosq.h"
|
||||
|
||||
|
||||
int handle__suback(struct mosquitto *mosq)
|
||||
@@ -40,10 +41,12 @@ int handle__suback(struct mosquitto *mosq)
|
||||
int i = 0;
|
||||
int rc;
|
||||
mosquitto_property *properties = NULL;
|
||||
int state;
|
||||
|
||||
assert(mosq);
|
||||
|
||||
if(mosq->state != mosq_cs_connected){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state != mosq_cs_active){
|
||||
return MOSQ_ERR_PROTOCOL;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,10 +42,12 @@ int handle__unsuback(struct mosquitto *mosq)
|
||||
uint16_t mid;
|
||||
int rc;
|
||||
mosquitto_property *properties = NULL;
|
||||
int state;
|
||||
|
||||
assert(mosq);
|
||||
|
||||
if(mosq->state != mosq_cs_connected){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state != mosq_cs_active){
|
||||
return MOSQ_ERR_PROTOCOL;
|
||||
}
|
||||
|
||||
|
||||
+18
-26
@@ -47,6 +47,9 @@ int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets)
|
||||
char pairbuf;
|
||||
int maxfd = 0;
|
||||
time_t now;
|
||||
#ifdef WITH_SRV
|
||||
int state;
|
||||
#endif
|
||||
|
||||
if(!mosq || max_packets < 1) return MOSQ_ERR_INVAL;
|
||||
#ifndef WIN32
|
||||
@@ -83,17 +86,15 @@ int mosquitto_loop(struct mosquitto *mosq, int timeout, int max_packets)
|
||||
}else{
|
||||
#ifdef WITH_SRV
|
||||
if(mosq->achan){
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
if(mosq->state == mosq_cs_connect_srv){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state == mosq_cs_connect_srv){
|
||||
rc = ares_fds(mosq->achan, &readfds, &writefds);
|
||||
if(rc > maxfd){
|
||||
maxfd = rc;
|
||||
}
|
||||
}else{
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
return MOSQ_ERR_NO_CONN;
|
||||
}
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
}
|
||||
#else
|
||||
return MOSQ_ERR_NO_CONN;
|
||||
@@ -194,24 +195,19 @@ int mosquitto_loop_forever(struct mosquitto *mosq, int timeout, int max_packets)
|
||||
{
|
||||
int run = 1;
|
||||
int rc;
|
||||
unsigned int reconnects = 0;
|
||||
unsigned long reconnect_delay;
|
||||
#ifndef WIN32
|
||||
struct timespec req, rem;
|
||||
#endif
|
||||
int state;
|
||||
|
||||
if(!mosq) return MOSQ_ERR_INVAL;
|
||||
|
||||
if(mosq->state == mosq_cs_connect_async){
|
||||
mosquitto_reconnect(mosq);
|
||||
}
|
||||
mosq->reconnects = 0;
|
||||
|
||||
while(run){
|
||||
do{
|
||||
rc = mosquitto_loop(mosq, timeout, max_packets);
|
||||
if (reconnects !=0 && rc == MOSQ_ERR_SUCCESS){
|
||||
reconnects = 0;
|
||||
}
|
||||
}while(run && rc == MOSQ_ERR_SUCCESS);
|
||||
/* Quit after fatal errors. */
|
||||
switch(rc){
|
||||
@@ -236,18 +232,15 @@ int mosquitto_loop_forever(struct mosquitto *mosq, int timeout, int max_packets)
|
||||
}
|
||||
do{
|
||||
rc = MOSQ_ERR_SUCCESS;
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
if(mosq->state == mosq_cs_disconnecting){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state == mosq_cs_disconnecting || state == mosq_cs_disconnected){
|
||||
run = 0;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
}else{
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
|
||||
if(mosq->reconnect_delay_max > mosq->reconnect_delay){
|
||||
if(mosq->reconnect_exponential_backoff){
|
||||
reconnect_delay = mosq->reconnect_delay*(reconnects+1)*(reconnects+1);
|
||||
reconnect_delay = mosq->reconnect_delay*(mosq->reconnects+1)*(mosq->reconnects+1);
|
||||
}else{
|
||||
reconnect_delay = mosq->reconnect_delay*(reconnects+1);
|
||||
reconnect_delay = mosq->reconnect_delay*(mosq->reconnects+1);
|
||||
}
|
||||
}else{
|
||||
reconnect_delay = mosq->reconnect_delay;
|
||||
@@ -256,7 +249,7 @@ int mosquitto_loop_forever(struct mosquitto *mosq, int timeout, int max_packets)
|
||||
if(reconnect_delay > mosq->reconnect_delay_max){
|
||||
reconnect_delay = mosq->reconnect_delay_max;
|
||||
}else{
|
||||
reconnects++;
|
||||
mosq->reconnects++;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -269,12 +262,10 @@ int mosquitto_loop_forever(struct mosquitto *mosq, int timeout, int max_packets)
|
||||
}
|
||||
#endif
|
||||
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
if(mosq->state == mosq_cs_disconnecting){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state == mosq_cs_disconnecting || state == mosq_cs_disconnected){
|
||||
run = 0;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
}else{
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
rc = mosquitto_reconnect(mosq);
|
||||
}
|
||||
}
|
||||
@@ -295,13 +286,14 @@ int mosquitto_loop_misc(struct mosquitto *mosq)
|
||||
|
||||
static int mosquitto__loop_rc_handle(struct mosquitto *mosq, int rc)
|
||||
{
|
||||
int state;
|
||||
|
||||
if(rc){
|
||||
net__socket_close(mosq);
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
if(mosq->state == mosq_cs_disconnecting){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state == mosq_cs_disconnecting || state == mosq_cs_disconnected){
|
||||
rc = MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
pthread_mutex_lock(&mosq->callback_mutex);
|
||||
if(mosq->on_disconnect){
|
||||
mosq->in_callback = true;
|
||||
|
||||
+1
-5
@@ -340,10 +340,6 @@ int message__out_update(struct mosquitto *mosq, uint16_t mid, enum mosquitto_msg
|
||||
|
||||
int mosquitto_max_inflight_messages_set(struct mosquitto *mosq, unsigned int max_inflight_messages)
|
||||
{
|
||||
if(!mosq) return MOSQ_ERR_INVAL;
|
||||
|
||||
mosq->send_maximum = max_inflight_messages;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
return mosquitto_int_option(mosq, MOSQ_OPT_SEND_MAXIMUM, max_inflight_messages);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ Contributors:
|
||||
#include <string.h>
|
||||
#ifndef WIN32
|
||||
#include <sys/time.h>
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "mosquitto.h"
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ extern "C" {
|
||||
|
||||
#define LIBMOSQUITTO_MAJOR 1
|
||||
#define LIBMOSQUITTO_MINOR 6
|
||||
#define LIBMOSQUITTO_REVISION 4
|
||||
#define LIBMOSQUITTO_REVISION 7
|
||||
/* LIBMOSQUITTO_VERSION_NUMBER looks like 1002001 for e.g. version 1.2.1. */
|
||||
#define LIBMOSQUITTO_VERSION_NUMBER (LIBMOSQUITTO_MAJOR*1000000+LIBMOSQUITTO_MINOR*1000+LIBMOSQUITTO_REVISION)
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ enum mosquitto_client_state {
|
||||
mosq_cs_new = 0,
|
||||
mosq_cs_connected = 1,
|
||||
mosq_cs_disconnecting = 2,
|
||||
mosq_cs_connect_async = 3,
|
||||
mosq_cs_active = 3,
|
||||
mosq_cs_connect_pending = 4,
|
||||
mosq_cs_connect_srv = 5,
|
||||
mosq_cs_disconnect_ws = 6,
|
||||
@@ -107,7 +107,6 @@ enum mosquitto_client_state {
|
||||
mosq_cs_socks5_userpass_reply = 13,
|
||||
mosq_cs_socks5_send_userpass = 14,
|
||||
mosq_cs_expiring = 15,
|
||||
mosq_cs_connecting = 16,
|
||||
mosq_cs_duplicate = 17, /* client that has been taken over by another with the same id */
|
||||
mosq_cs_disconnect_with_will = 18,
|
||||
mosq_cs_disused = 19, /* client that has been added to the disused list to be freed */
|
||||
@@ -326,6 +325,7 @@ struct mosquitto {
|
||||
char *host;
|
||||
int port;
|
||||
char *bind_address;
|
||||
unsigned int reconnects;
|
||||
unsigned int reconnect_delay;
|
||||
unsigned int reconnect_delay_max;
|
||||
bool reconnect_exponential_backoff;
|
||||
@@ -334,8 +334,6 @@ struct mosquitto {
|
||||
# ifdef WITH_SRV
|
||||
ares_channel achan;
|
||||
# endif
|
||||
uint16_t send_maximum;
|
||||
uint16_t receive_maximum;
|
||||
#endif
|
||||
uint8_t maximum_qos;
|
||||
|
||||
|
||||
+1
-1
@@ -210,7 +210,7 @@ int net__socket_close(struct mosquitto *mosq)
|
||||
if(mosq->wsi)
|
||||
{
|
||||
if(mosq->state != mosq_cs_disconnecting){
|
||||
context__set_state(mosq, mosq_cs_disconnect_ws);
|
||||
mosquitto__set_state(mosq, mosq_cs_disconnect_ws);
|
||||
}
|
||||
libwebsocket_callback_on_writable(mosq->ws_context, mosq->wsi);
|
||||
}else
|
||||
|
||||
+5
-2
@@ -17,10 +17,13 @@ Contributors:
|
||||
#define NET_MOSQ_H
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
# include <winsock2.h>
|
||||
# ifndef _SSIZE_T_DEFINED
|
||||
typedef SSIZE_T ssize_t;
|
||||
# define _SSIZE_T_DEFINED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "mosquitto_internal.h"
|
||||
|
||||
+10
-2
@@ -409,14 +409,22 @@ int mosquitto_int_option(struct mosquitto *mosq, enum mosq_opt_t option, int val
|
||||
if(value < 0 || value > 65535){
|
||||
return MOSQ_ERR_INVAL;
|
||||
}
|
||||
mosq->receive_maximum = value;
|
||||
if(value == 0){
|
||||
mosq->msgs_in.inflight_maximum = 65535;
|
||||
}else{
|
||||
mosq->msgs_in.inflight_maximum = value;
|
||||
}
|
||||
break;
|
||||
|
||||
case MOSQ_OPT_SEND_MAXIMUM:
|
||||
if(value < 0 || value > 65535){
|
||||
return MOSQ_ERR_INVAL;
|
||||
}
|
||||
mosq->send_maximum = value;
|
||||
if(value == 0){
|
||||
mosq->msgs_out.inflight_maximum = 65535;
|
||||
}else{
|
||||
mosq->msgs_out.inflight_maximum = value;
|
||||
}
|
||||
break;
|
||||
|
||||
case MOSQ_OPT_SSL_CTX_WITH_DEFAULTS:
|
||||
|
||||
+15
-5
@@ -34,6 +34,7 @@ Contributors:
|
||||
#include "net_mosq.h"
|
||||
#include "packet_mosq.h"
|
||||
#include "read_handle.h"
|
||||
#include "util_mosq.h"
|
||||
#ifdef WITH_BROKER
|
||||
# include "sys_tree.h"
|
||||
# include "send_mosq.h"
|
||||
@@ -202,6 +203,7 @@ int packet__write(struct mosquitto *mosq)
|
||||
{
|
||||
ssize_t write_length;
|
||||
struct mosquitto__packet *packet;
|
||||
int state;
|
||||
|
||||
if(!mosq) return MOSQ_ERR_INVAL;
|
||||
if(mosq->sock == INVALID_SOCKET) return MOSQ_ERR_NO_CONN;
|
||||
@@ -217,10 +219,11 @@ int packet__write(struct mosquitto *mosq)
|
||||
}
|
||||
pthread_mutex_unlock(&mosq->out_packet_mutex);
|
||||
|
||||
state = mosquitto__get_state(mosq);
|
||||
#if defined(WITH_TLS) && !defined(WITH_BROKER)
|
||||
if((mosq->state == mosq_cs_connect_pending) || mosq->want_connect){
|
||||
if((state == mosq_cs_connect_pending) || mosq->want_connect){
|
||||
#else
|
||||
if(mosq->state == mosq_cs_connect_pending){
|
||||
if(state == mosq_cs_connect_pending){
|
||||
#endif
|
||||
pthread_mutex_unlock(&mosq->current_out_packet_mutex);
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
@@ -239,7 +242,11 @@ int packet__write(struct mosquitto *mosq)
|
||||
#ifdef WIN32
|
||||
errno = WSAGetLastError();
|
||||
#endif
|
||||
if(errno == EAGAIN || errno == COMPAT_EWOULDBLOCK){
|
||||
if(errno == EAGAIN || errno == COMPAT_EWOULDBLOCK
|
||||
#ifdef WIN32
|
||||
|| errno == WSAENOTCONN
|
||||
#endif
|
||||
){
|
||||
pthread_mutex_unlock(&mosq->current_out_packet_mutex);
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else{
|
||||
@@ -312,6 +319,7 @@ int packet__read(struct mosquitto *mosq)
|
||||
uint8_t byte;
|
||||
ssize_t read_length;
|
||||
int rc = 0;
|
||||
int state;
|
||||
|
||||
if(!mosq){
|
||||
return MOSQ_ERR_INVAL;
|
||||
@@ -319,7 +327,9 @@ int packet__read(struct mosquitto *mosq)
|
||||
if(mosq->sock == INVALID_SOCKET){
|
||||
return MOSQ_ERR_NO_CONN;
|
||||
}
|
||||
if(mosq->state == mosq_cs_connect_pending){
|
||||
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state == mosq_cs_connect_pending){
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -344,7 +354,7 @@ int packet__read(struct mosquitto *mosq)
|
||||
#ifdef WITH_BROKER
|
||||
G_BYTES_RECEIVED_INC(1);
|
||||
/* Clients must send CONNECT as their first command. */
|
||||
if(!(mosq->bridge) && mosq->state == mosq_cs_new && (byte&0xF0) != CMD_CONNECT){
|
||||
if(!(mosq->bridge) && mosq->state == mosq_cs_connected && (byte&0xF0) != CMD_CONNECT){
|
||||
return MOSQ_ERR_PROTOCOL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,10 @@ Contributors:
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef WIN32
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "logging_mosq.h"
|
||||
#include "memory_mosq.h"
|
||||
#include "mqtt_protocol.h"
|
||||
|
||||
+20
-20
@@ -37,6 +37,7 @@ Contributors:
|
||||
#include "net_mosq.h"
|
||||
#include "packet_mosq.h"
|
||||
#include "send_mosq.h"
|
||||
#include "util_mosq.h"
|
||||
|
||||
#define SOCKS_AUTH_NONE 0x00
|
||||
#define SOCKS_AUTH_GSS 0x01
|
||||
@@ -112,8 +113,11 @@ int socks5__send(struct mosquitto *mosq)
|
||||
struct in6_addr addr_ipv6;
|
||||
int ipv4_pton_result;
|
||||
int ipv6_pton_result;
|
||||
int state;
|
||||
|
||||
if(mosq->state == mosq_cs_socks5_new){
|
||||
state = mosquitto__get_state(mosq);
|
||||
|
||||
if(state == mosq_cs_socks5_new){
|
||||
packet = mosquitto__calloc(1, sizeof(struct mosquitto__packet));
|
||||
if(!packet) return MOSQ_ERR_NOMEM;
|
||||
|
||||
@@ -134,9 +138,7 @@ int socks5__send(struct mosquitto *mosq)
|
||||
packet->payload[2] = SOCKS_AUTH_NONE;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
mosq->state = mosq_cs_socks5_start;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
mosquitto__set_state(mosq, mosq_cs_socks5_start);
|
||||
|
||||
mosq->in_packet.pos = 0;
|
||||
mosq->in_packet.packet_length = 2;
|
||||
@@ -149,7 +151,7 @@ int socks5__send(struct mosquitto *mosq)
|
||||
}
|
||||
|
||||
return packet__queue(mosq, packet);
|
||||
}else if(mosq->state == mosq_cs_socks5_auth_ok){
|
||||
}else if(state == mosq_cs_socks5_auth_ok){
|
||||
packet = mosquitto__calloc(1, sizeof(struct mosquitto__packet));
|
||||
if(!packet) return MOSQ_ERR_NOMEM;
|
||||
|
||||
@@ -201,9 +203,7 @@ int socks5__send(struct mosquitto *mosq)
|
||||
packet->payload[1] = 0x01;
|
||||
packet->payload[2] = 0x00;
|
||||
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
mosq->state = mosq_cs_socks5_request;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
mosquitto__set_state(mosq, mosq_cs_socks5_request);
|
||||
|
||||
mosq->in_packet.pos = 0;
|
||||
mosq->in_packet.packet_length = 5;
|
||||
@@ -216,7 +216,7 @@ int socks5__send(struct mosquitto *mosq)
|
||||
}
|
||||
|
||||
return packet__queue(mosq, packet);
|
||||
}else if(mosq->state == mosq_cs_socks5_send_userpass){
|
||||
}else if(state == mosq_cs_socks5_send_userpass){
|
||||
packet = mosquitto__calloc(1, sizeof(struct mosquitto__packet));
|
||||
if(!packet) return MOSQ_ERR_NOMEM;
|
||||
|
||||
@@ -232,9 +232,7 @@ int socks5__send(struct mosquitto *mosq)
|
||||
packet->payload[2+ulen] = plen;
|
||||
memcpy(&(packet->payload[3+ulen]), mosq->socks5_password, plen);
|
||||
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
mosq->state = mosq_cs_socks5_userpass_reply;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
mosquitto__set_state(mosq, mosq_cs_socks5_userpass_reply);
|
||||
|
||||
mosq->in_packet.pos = 0;
|
||||
mosq->in_packet.packet_length = 2;
|
||||
@@ -256,8 +254,10 @@ int socks5__read(struct mosquitto *mosq)
|
||||
ssize_t len;
|
||||
uint8_t *payload;
|
||||
uint8_t i;
|
||||
int state;
|
||||
|
||||
if(mosq->state == mosq_cs_socks5_start){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state == mosq_cs_socks5_start){
|
||||
while(mosq->in_packet.to_process > 0){
|
||||
len = net__read(mosq, &(mosq->in_packet.payload[mosq->in_packet.pos]), mosq->in_packet.to_process);
|
||||
if(len > 0){
|
||||
@@ -289,17 +289,17 @@ int socks5__read(struct mosquitto *mosq)
|
||||
switch(mosq->in_packet.payload[1]){
|
||||
case SOCKS_AUTH_NONE:
|
||||
packet__cleanup(&mosq->in_packet);
|
||||
mosq->state = mosq_cs_socks5_auth_ok;
|
||||
mosquitto__set_state(mosq, mosq_cs_socks5_auth_ok);
|
||||
return socks5__send(mosq);
|
||||
case SOCKS_AUTH_USERPASS:
|
||||
packet__cleanup(&mosq->in_packet);
|
||||
mosq->state = mosq_cs_socks5_send_userpass;
|
||||
mosquitto__set_state(mosq, mosq_cs_socks5_send_userpass);
|
||||
return socks5__send(mosq);
|
||||
default:
|
||||
packet__cleanup(&mosq->in_packet);
|
||||
return MOSQ_ERR_AUTH;
|
||||
}
|
||||
}else if(mosq->state == mosq_cs_socks5_userpass_reply){
|
||||
}else if(state == mosq_cs_socks5_userpass_reply){
|
||||
while(mosq->in_packet.to_process > 0){
|
||||
len = net__read(mosq, &(mosq->in_packet.payload[mosq->in_packet.pos]), mosq->in_packet.to_process);
|
||||
if(len > 0){
|
||||
@@ -330,7 +330,7 @@ int socks5__read(struct mosquitto *mosq)
|
||||
}
|
||||
if(mosq->in_packet.payload[1] == 0){
|
||||
packet__cleanup(&mosq->in_packet);
|
||||
mosq->state = mosq_cs_socks5_auth_ok;
|
||||
mosquitto__set_state(mosq, mosq_cs_socks5_auth_ok);
|
||||
return socks5__send(mosq);
|
||||
}else{
|
||||
i = mosq->in_packet.payload[1];
|
||||
@@ -355,7 +355,7 @@ int socks5__read(struct mosquitto *mosq)
|
||||
}
|
||||
return MOSQ_ERR_PROXY;
|
||||
}
|
||||
}else if(mosq->state == mosq_cs_socks5_request){
|
||||
}else if(state == mosq_cs_socks5_request){
|
||||
while(mosq->in_packet.to_process > 0){
|
||||
len = net__read(mosq, &(mosq->in_packet.payload[mosq->in_packet.pos]), mosq->in_packet.to_process);
|
||||
if(len > 0){
|
||||
@@ -423,7 +423,7 @@ int socks5__read(struct mosquitto *mosq)
|
||||
if(mosq->in_packet.payload[1] == 0){
|
||||
/* Auth passed */
|
||||
packet__cleanup(&mosq->in_packet);
|
||||
mosq->state = mosq_cs_new;
|
||||
mosquitto__set_state(mosq, mosq_cs_new);
|
||||
if(mosq->socks5_host){
|
||||
int rc = net__socket_connect_step3(mosq, mosq->host);
|
||||
if(rc) return rc;
|
||||
@@ -432,7 +432,7 @@ int socks5__read(struct mosquitto *mosq)
|
||||
}else{
|
||||
i = mosq->in_packet.payload[1];
|
||||
packet__cleanup(&mosq->in_packet);
|
||||
mosq->state = mosq_cs_socks5_new;
|
||||
mosquitto__set_state(mosq, mosq_cs_socks5_new);
|
||||
switch(i){
|
||||
case SOCKS_REPLY_CONNECTION_NOT_ALLOWED:
|
||||
return MOSQ_ERR_AUTH;
|
||||
|
||||
+2
-3
@@ -28,6 +28,7 @@ Contributors:
|
||||
#include "memory_mosq.h"
|
||||
#include "mosquitto_internal.h"
|
||||
#include "mosquitto.h"
|
||||
#include "util_mosq.h"
|
||||
|
||||
#ifdef WITH_SRV
|
||||
static void srv_callback(void *arg, int status, int timeouts, unsigned char *abuf, int alen)
|
||||
@@ -91,9 +92,7 @@ int mosquitto_connect_srv(struct mosquitto *mosq, const char *host, int keepaliv
|
||||
mosquitto__free(h);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
mosq->state = mosq_cs_connect_srv;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
mosquitto__set_state(mosq, mosq_cs_connect_srv);
|
||||
|
||||
mosq->keepalive = keepalive;
|
||||
|
||||
|
||||
+2
-7
@@ -22,6 +22,7 @@ Contributors:
|
||||
|
||||
#include "mosquitto_internal.h"
|
||||
#include "net_mosq.h"
|
||||
#include "util_mosq.h"
|
||||
|
||||
void *mosquitto__thread_main(void *obj);
|
||||
|
||||
@@ -89,9 +90,7 @@ void *mosquitto__thread_main(void *obj)
|
||||
if(!mosq) return NULL;
|
||||
|
||||
do{
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
state = mosq->state;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state == mosq_cs_new){
|
||||
#ifdef WIN32
|
||||
Sleep(10);
|
||||
@@ -103,10 +102,6 @@ void *mosquitto__thread_main(void *obj)
|
||||
}
|
||||
}while(1);
|
||||
|
||||
if(state == mosq_cs_connect_async){
|
||||
mosquitto_reconnect(mosq);
|
||||
}
|
||||
|
||||
if(!mosq->keepalive){
|
||||
/* Sleep for a day if keepalive disabled. */
|
||||
mosquitto_loop_forever(mosq, 1000*86400, 1);
|
||||
|
||||
+32
-4
@@ -68,6 +68,7 @@ int mosquitto__check_keepalive(struct mosquitto *mosq)
|
||||
#ifndef WITH_BROKER
|
||||
int rc;
|
||||
#endif
|
||||
int state;
|
||||
|
||||
assert(mosq);
|
||||
#if defined(WITH_BROKER) && defined(WITH_BRIDGE)
|
||||
@@ -88,7 +89,8 @@ int mosquitto__check_keepalive(struct mosquitto *mosq)
|
||||
if(mosq->keepalive && mosq->sock != INVALID_SOCKET &&
|
||||
(now >= next_msg_out || now - last_msg_in >= mosq->keepalive)){
|
||||
|
||||
if(mosq->state == mosq_cs_connected && mosq->ping_t == 0){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state == mosq_cs_active && mosq->ping_t == 0){
|
||||
send__pingreq(mosq);
|
||||
/* Reset last msg times to give the server time to send a pingresp */
|
||||
pthread_mutex_lock(&mosq->msgtime_mutex);
|
||||
@@ -100,13 +102,12 @@ int mosquitto__check_keepalive(struct mosquitto *mosq)
|
||||
net__socket_close(db, mosq);
|
||||
#else
|
||||
net__socket_close(mosq);
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
if(mosq->state == mosq_cs_disconnecting){
|
||||
state = mosquitto__get_state(mosq);
|
||||
if(state == mosq_cs_disconnecting){
|
||||
rc = MOSQ_ERR_SUCCESS;
|
||||
}else{
|
||||
rc = MOSQ_ERR_KEEPALIVE;
|
||||
}
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
pthread_mutex_lock(&mosq->callback_mutex);
|
||||
if(mosq->on_disconnect){
|
||||
mosq->in_callback = true;
|
||||
@@ -352,3 +353,30 @@ int util__random_bytes(void *bytes, int count)
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
int mosquitto__set_state(struct mosquitto *mosq, enum mosquitto_client_state state)
|
||||
{
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
#ifdef WITH_BROKER
|
||||
if(mosq->state != mosq_cs_disused)
|
||||
#endif
|
||||
{
|
||||
mosq->state = state;
|
||||
}
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
enum mosquitto_client_state mosquitto__get_state(struct mosquitto *mosq)
|
||||
{
|
||||
enum mosquitto_client_state state;
|
||||
|
||||
pthread_mutex_lock(&mosq->state_mutex);
|
||||
state = mosq->state;
|
||||
pthread_mutex_unlock(&mosq->state_mutex);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ int mosquitto__check_keepalive(struct mosquitto *mosq);
|
||||
uint16_t mosquitto__mid_generate(struct mosquitto *mosq);
|
||||
FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read);
|
||||
|
||||
int mosquitto__set_state(struct mosquitto *mosq, enum mosquitto_client_state state);
|
||||
enum mosquitto_client_state mosquitto__get_state(struct mosquitto *mosq);
|
||||
|
||||
#ifdef WITH_TLS
|
||||
int mosquitto__hex2bin_sha1(const char *hex, unsigned char **bin);
|
||||
int mosquitto__hex2bin(const char *hex, unsigned char *bin, int bin_max_len);
|
||||
|
||||
@@ -49,14 +49,25 @@ Contributors:
|
||||
int mosquitto_pub_topic_check(const char *str)
|
||||
{
|
||||
int len = 0;
|
||||
#ifdef WITH_BROKER
|
||||
int hier_count = 0;
|
||||
#endif
|
||||
while(str && str[0]){
|
||||
if(str[0] == '+' || str[0] == '#'){
|
||||
return MOSQ_ERR_INVAL;
|
||||
}
|
||||
#ifdef WITH_BROKER
|
||||
else if(str[0] == '/'){
|
||||
hier_count++;
|
||||
}
|
||||
#endif
|
||||
len++;
|
||||
str = &str[1];
|
||||
}
|
||||
if(len > 65535) return MOSQ_ERR_INVAL;
|
||||
#ifdef WITH_BROKER
|
||||
if(hier_count > TOPIC_HIERARCHY_LIMIT) return MOSQ_ERR_INVAL;
|
||||
#endif
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
@@ -64,6 +75,9 @@ int mosquitto_pub_topic_check(const char *str)
|
||||
int mosquitto_pub_topic_check2(const char *str, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
#ifdef WITH_BROKER
|
||||
int hier_count = 0;
|
||||
#endif
|
||||
|
||||
if(len > 65535) return MOSQ_ERR_INVAL;
|
||||
|
||||
@@ -71,7 +85,15 @@ int mosquitto_pub_topic_check2(const char *str, size_t len)
|
||||
if(str[i] == '+' || str[i] == '#'){
|
||||
return MOSQ_ERR_INVAL;
|
||||
}
|
||||
#ifdef WITH_BROKER
|
||||
else if(str[i] == '/'){
|
||||
hier_count++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef WITH_BROKER
|
||||
if(hier_count > TOPIC_HIERARCHY_LIMIT) return MOSQ_ERR_INVAL;
|
||||
#endif
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
@@ -87,6 +109,10 @@ int mosquitto_sub_topic_check(const char *str)
|
||||
{
|
||||
char c = '\0';
|
||||
int len = 0;
|
||||
#ifdef WITH_BROKER
|
||||
int hier_count = 0;
|
||||
#endif
|
||||
|
||||
while(str && str[0]){
|
||||
if(str[0] == '+'){
|
||||
if((c != '\0' && c != '/') || (str[1] != '\0' && str[1] != '/')){
|
||||
@@ -97,11 +123,19 @@ int mosquitto_sub_topic_check(const char *str)
|
||||
return MOSQ_ERR_INVAL;
|
||||
}
|
||||
}
|
||||
#ifdef WITH_BROKER
|
||||
else if(str[0] == '/'){
|
||||
hier_count++;
|
||||
}
|
||||
#endif
|
||||
len++;
|
||||
c = str[0];
|
||||
str = &str[1];
|
||||
}
|
||||
if(len > 65535) return MOSQ_ERR_INVAL;
|
||||
#ifdef WITH_BROKER
|
||||
if(hier_count > TOPIC_HIERARCHY_LIMIT) return MOSQ_ERR_INVAL;
|
||||
#endif
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
@@ -110,6 +144,9 @@ int mosquitto_sub_topic_check2(const char *str, size_t len)
|
||||
{
|
||||
char c = '\0';
|
||||
size_t i;
|
||||
#ifdef WITH_BROKER
|
||||
int hier_count = 0;
|
||||
#endif
|
||||
|
||||
if(len > 65535) return MOSQ_ERR_INVAL;
|
||||
|
||||
@@ -123,8 +160,16 @@ int mosquitto_sub_topic_check2(const char *str, size_t len)
|
||||
return MOSQ_ERR_INVAL;
|
||||
}
|
||||
}
|
||||
#ifdef WITH_BROKER
|
||||
else if(str[i] == '/'){
|
||||
hier_count++;
|
||||
}
|
||||
#endif
|
||||
c = str[i];
|
||||
}
|
||||
#ifdef WITH_BROKER
|
||||
if(hier_count > TOPIC_HIERARCHY_LIMIT) return MOSQ_ERR_INVAL;
|
||||
#endif
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
+168
-29
@@ -132,7 +132,7 @@
|
||||
for the topic keyword, but using pattern as the
|
||||
keyword.</para>
|
||||
<para><code>pattern [read|write|readwrite] <topic></code></para>
|
||||
|
||||
|
||||
<para>The patterns available for substition are:</para>
|
||||
<itemizedlist mark="circle">
|
||||
<listitem><para>%c to match the client id of the client</para></listitem>
|
||||
@@ -151,6 +151,13 @@
|
||||
<para>If the first character of a line of the ACL file is a
|
||||
# it is treated as a comment.</para>
|
||||
|
||||
<para>If <option>per_listener_settings</option> is
|
||||
<replaceable>true</replaceable>, this option applies to
|
||||
the current listener being configured only. If
|
||||
<option>per_listener_settings</option> is
|
||||
<replaceable>false</replaceable>, this option applies
|
||||
to all listeners.</para>
|
||||
|
||||
<para>Reloaded on reload signal. The currently loaded ACLs
|
||||
will be freed and reloaded. Existing subscriptions will
|
||||
be affected after the reload.</para>
|
||||
@@ -171,6 +178,14 @@
|
||||
username/password or TLS-PSK checks, then
|
||||
<option>allow_anonymous</option> defaults to
|
||||
<replaceable>false</replaceable>.</para>
|
||||
|
||||
<para>If <option>per_listener_settings</option> is
|
||||
<replaceable>true</replaceable>, this option applies to
|
||||
the current listener being configured only. If
|
||||
<option>per_listener_settings</option> is
|
||||
<replaceable>false</replaceable>, this option applies
|
||||
to all listeners.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -196,17 +211,28 @@
|
||||
correctly deal with duplicate messages even when then
|
||||
have QoS=2.</para>
|
||||
<para>Defaults to <replaceable>true</replaceable>.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>allow_zero_length_clientid</option> [ true | false ]</term>
|
||||
<listitem>
|
||||
<para>MQTT 3.1.1 allows clients to connect with a zero
|
||||
<para>MQTT 3.1.1 and MQTT 5 allow clients to connect with a zero
|
||||
length client id and have the broker generate a client
|
||||
id for them. Use this option to allow/disallow this
|
||||
behaviour. Defaults to true.</para>
|
||||
<para>See also the <option>auto_id_prefix</option> option.</para>
|
||||
|
||||
<para>If <option>per_listener_settings</option> is
|
||||
<replaceable>true</replaceable>, this option applies to
|
||||
the current listener being configured only. If
|
||||
<option>per_listener_settings</option> is
|
||||
<replaceable>false</replaceable>, this option applies
|
||||
to all listeners.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -214,7 +240,9 @@
|
||||
<term><option>auth_opt_*</option> <replaceable>value</replaceable></term>
|
||||
<listitem>
|
||||
<para>Options to be passed to the auth plugin. See the
|
||||
specific plugin instructions. </para>
|
||||
specific plugin instructions.</para>
|
||||
|
||||
<para>Applies to the current authentication plugin being configured.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@@ -256,6 +284,8 @@
|
||||
checks delivered to your plugin by setting this option
|
||||
to <replaceable>false</replaceable>.</para>
|
||||
<para>Defaults to <replaceable>true</replaceable>.</para>
|
||||
|
||||
<para>Applies to the current authentication plugin being configured.</para>
|
||||
<para>Not currently reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -267,6 +297,14 @@
|
||||
to set a string that will be prefixed to the
|
||||
automatically generated client ids to aid visibility in
|
||||
logs. Defaults to <option>auto-</option>.</para>
|
||||
|
||||
<para>If <option>per_listener_settings</option> is
|
||||
<replaceable>true</replaceable>, this option applies to
|
||||
the current listener being configured only. If
|
||||
<option>per_listener_settings</option> is
|
||||
<replaceable>false</replaceable>, this option applies
|
||||
to all listeners.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -280,6 +318,9 @@
|
||||
SIGUSR1 signal. Note that this setting only has an
|
||||
effect if persistence is enabled. Defaults to 1800
|
||||
seconds (30 minutes).</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -295,6 +336,9 @@
|
||||
the in-memory database to disk by treating
|
||||
<option>autosave_interval</option> as a time in
|
||||
seconds.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -325,6 +369,9 @@
|
||||
"secure-" here would mean a client "secure-client"
|
||||
could connect but another with clientid "mqtt"
|
||||
couldn't. By default, all client ids are valid.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal. Note that currently
|
||||
connected clients will be unaffected by any
|
||||
changes.</para>
|
||||
@@ -337,6 +384,9 @@
|
||||
will include entries when clients connect and
|
||||
disconnect. If set to <replaceable>false</replaceable>,
|
||||
these entries will not appear.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -501,23 +551,31 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
<varlistentry>
|
||||
<term><option>max_inflight_bytes</option> <replaceable>count</replaceable></term>
|
||||
<listitem>
|
||||
<para>QoS 1 and 2 messages will be allowed in flight until this byte
|
||||
limit is reached. Defaults to 0. (No limit)
|
||||
See also the <option>max_inflight_messages</option> option.
|
||||
</para>
|
||||
<para>Outgoing QoS 1 and 2 messages will be allowed in flight until this byte
|
||||
limit is reached. This allows control of outgoing message rate based on
|
||||
message size rather than message count. If the limit is set to 100,
|
||||
messages of over 100 bytes are still allowed, but only a single message
|
||||
can be in flight at once. Defaults to 0. (No limit).</para>
|
||||
<para>See also the <option>max_inflight_messages</option> option.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>max_inflight_messages</option> <replaceable>count</replaceable></term>
|
||||
<listitem>
|
||||
<para>The maximum number of QoS 1 or 2 messages that can be
|
||||
<para>The maximum number of outgoing QoS 1 or 2 messages that can be
|
||||
in the process of being transmitted simultaneously.
|
||||
This includes messages currently going through
|
||||
handshakes and messages that are being retried.
|
||||
Defaults to 20. Set to 0 for no maximum. If set to 1,
|
||||
this will guarantee in-order delivery of
|
||||
messages.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -537,6 +595,9 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
max_keepalive. This only applies to MQTT v5 clients.
|
||||
The maximum value allowable, and default value, is
|
||||
65535. Do not set below 10 seconds.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -556,22 +617,36 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
using, but v3.1.1 and earlier clients will of course
|
||||
not have received the maximum packet size information.
|
||||
Defaults to no limit.</para>
|
||||
|
||||
<para>This option applies to all clients, not just those
|
||||
using MQTT v5, but it is not possible to notify clients
|
||||
using MQTT v3.1.1 or MQTT v3.1 of the limit.</para>
|
||||
|
||||
<para>Setting below 20 bytes is forbidden because it is
|
||||
likely to interfere with normal client operation even
|
||||
with small payloads.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>max_queued_bytes</option> <replaceable>count</replaceable></term>
|
||||
<listitem>
|
||||
<para>QoS 1 and 2 messages above those currently in-flight will be
|
||||
queued (per client) until this limit is exceeded.
|
||||
Defaults to 0. (No maximum) See also the
|
||||
<para>The number of outgoing QoS 1 and 2 messages above those currently in-flight will be
|
||||
queued (per client) by the broker. Once this limit has been reached, subsequent
|
||||
messages will be silently dropped. This is an important option if you are sending
|
||||
messages at a high rate and/or have clients who are slow to respond or may be offline
|
||||
for extended periods of time. Defaults to 0. (No maximum).</para>
|
||||
<para>See also the
|
||||
<option>max_queued_messages</option> option.
|
||||
If both max_queued_messages and max_queued_bytes are specified,
|
||||
packets will be queued until the first limit is reached.
|
||||
</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -583,8 +658,10 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
in flight. Defaults to 100. Set to 0 for no maximum (not
|
||||
recommended). See also the
|
||||
<option>queue_qos0_messages</option> and
|
||||
<option>max_queued_bytes</option> options.
|
||||
</para>
|
||||
<option>max_queued_bytes</option> options.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -611,10 +688,19 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
<listitem>
|
||||
<para>This option sets the maximum publish payload size
|
||||
that the broker will allow. Received messages that
|
||||
exceed this size will not be accepted by the broker.
|
||||
The default value is 0, which means that all valid MQTT
|
||||
exceed this size will not be accepted by the broker. This means that the
|
||||
message will not be forwarded on to subscribing clients, but the QoS flow
|
||||
will be completed for QoS 1 or QoS 2 messages. MQTT v5 clients using QoS 1
|
||||
or QoS 2 will receive a PUBACK or PUBREC with the "implementation specific
|
||||
error" reason code.</para>
|
||||
|
||||
<para>The default value is 0, which means that all valid MQTT
|
||||
messages are accepted. MQTT imposes a maximum payload
|
||||
size of 268435455 bytes.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@@ -638,6 +724,14 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
valid and could be used with acl_file to have e.g. read
|
||||
only guest/anonymous accounts and defined users that
|
||||
can publish.</para>
|
||||
|
||||
<para>If <option>per_listener_settings</option> is
|
||||
<replaceable>true</replaceable>, this option applies to
|
||||
the current listener being configured only. If
|
||||
<option>per_listener_settings</option> is
|
||||
<replaceable>false</replaceable>, this option applies
|
||||
to all listeners.</para>
|
||||
|
||||
<para>Reloaded on reload signal. The currently loaded
|
||||
username and password data will be freed and reloaded.
|
||||
Clients that are already connected will not be
|
||||
@@ -693,6 +787,9 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
copy of the persistence file before installing a new
|
||||
version so that they can roll back to an earlier version
|
||||
if necessary.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -701,6 +798,9 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
<listitem>
|
||||
<para>The filename to use for the persistent database.
|
||||
Defaults to mosquitto.db.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -710,6 +810,9 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
<para>The path where the persistence database should be
|
||||
stored. Must end in a trailing slash. If not given,
|
||||
then the current directory is used.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -735,6 +838,9 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
</itemizedlist>
|
||||
<para>As this is a non-standard option, the default if not
|
||||
set is to never expire persistent clients.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -765,6 +871,14 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
listener that has PSK support enabled must provide a
|
||||
matching identity and PSK to allow the encrypted
|
||||
connection to proceed.</para>
|
||||
|
||||
<para>If <option>per_listener_settings</option> is
|
||||
<replaceable>true</replaceable>, this option applies to
|
||||
the current listener being configured only. If
|
||||
<option>per_listener_settings</option> is
|
||||
<replaceable>false</replaceable>, this option applies
|
||||
to all listeners.</para>
|
||||
|
||||
<para>Reloaded on reload signal. The currently loaded
|
||||
identity and key data will be freed and reloaded.
|
||||
Clients that are already connected will not be
|
||||
@@ -781,6 +895,9 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
<para>Note that the MQTT v3.1.1 spec states that only QoS 1
|
||||
and 2 messages should be saved in this situation so
|
||||
this is a non-standard option.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -791,6 +908,9 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
supported. Clients that send a message with the retain
|
||||
bit will be disconnected if this option is set to
|
||||
false. Defaults to true.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -810,6 +930,9 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
has the effect of reducing latency of some messages
|
||||
at potentially increasing the number of TCP packets
|
||||
being sent. Defaults to false.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -822,6 +945,9 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
seconds.</para>
|
||||
<para>Set to 0 to disable publishing the $SYS hierarchy
|
||||
completely.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -838,6 +964,9 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
subscription. This is a non-standard option not
|
||||
provided for by the spec. Defaults to
|
||||
<replaceable>false</replaceable>.</para>
|
||||
|
||||
<para>This option applies globally.</para>
|
||||
|
||||
<para>Reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -879,8 +1008,14 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
to restrict access to certain network interfaces.
|
||||
To restrict access to mosquitto to the local host
|
||||
only, use "bind_address localhost". This only
|
||||
applies to the default listener. Use the listener
|
||||
variable to control other listeners.</para>
|
||||
applies to the default listener. Use the
|
||||
<option>listener</option> option to control other
|
||||
listeners.</para>
|
||||
|
||||
<para>It is recommended to use an explicit
|
||||
<option>listener</option> rather than rely on the
|
||||
implicit default listener options like this.</para>
|
||||
|
||||
<para>Not reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -958,7 +1093,7 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
<varlistentry>
|
||||
<term><option>maximum_qos</option> <replaceable>count</replaceable></term>
|
||||
<listitem>
|
||||
<para>Limit the QoS value allowed when using this
|
||||
<para>Limit the QoS value allowed for clients connecting to this
|
||||
listener. Defaults to 2, which means any QoS can be
|
||||
used. Set to 0 or 1 to limit to those QoS values.
|
||||
This makes use of an MQTT v5 feature to notify
|
||||
@@ -973,9 +1108,9 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
<term><option>max_topic_alias</option> <replaceable>number</replaceable></term>
|
||||
<listitem>
|
||||
<para>This option sets the maximum number topic aliases
|
||||
that an MQTT v5 client is allowed to create. It
|
||||
that an MQTT v5 client is allowed to create. This option
|
||||
applies per listener. Defaults to 10. Set to 0 to
|
||||
disallow topic aliases.</para>
|
||||
disallow topic aliases. The maximum value possible is 65535.</para>
|
||||
<para>Not reloaded on reload signal.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -1001,12 +1136,16 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
<para>Set the network port for the default listener to
|
||||
listen on. Defaults to 1883.</para>
|
||||
<para>Not reloaded on reload signal.</para>
|
||||
|
||||
<para>It is recommended to use an explicit
|
||||
<option>listener</option> rather than rely on the
|
||||
implicit default listener options like this.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>protocol</option> <replaceable>value</replaceable></term>
|
||||
<listitem>
|
||||
<para>Set the protocol to accept for this listener. Can
|
||||
<para>Set the protocol to accept for the current listener. Can
|
||||
be <option>mqtt</option>, the default, or
|
||||
<option>websockets</option> if available.</para>
|
||||
<para>Websockets support is currently disabled by
|
||||
@@ -1098,7 +1237,7 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
<term><option>cafile</option> <replaceable>file path</replaceable></term>
|
||||
<listitem>
|
||||
<para>At least one of <option>cafile</option> or
|
||||
<option>capath</option> must be provided to allow
|
||||
<option>capath</option> must be provided to enable
|
||||
SSL support.</para>
|
||||
<para><option>cafile</option> is used to define the
|
||||
path to a file containing the PEM encoded CA
|
||||
@@ -1109,7 +1248,7 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
|
||||
<term><option>capath</option> <replaceable>directory path</replaceable></term>
|
||||
<listitem>
|
||||
<para>At least one of <option>cafile</option> or
|
||||
<option>capath</option> must be provided to allow
|
||||
<option>capath</option> must be provided to enable
|
||||
SSL support.</para>
|
||||
<para><option>capath</option> is used to define a
|
||||
directory that contains PEM encoded CA certificates
|
||||
@@ -1173,11 +1312,11 @@ openssl dhparam -out dhparam.pem 2048</programlisting>
|
||||
trusted certificate. The overall aim is encryption
|
||||
of the network traffic. By setting
|
||||
<option>require_certificate</option> to
|
||||
<replaceable>true</replaceable>, the client must
|
||||
provide a valid certificate in order for the
|
||||
network connection to proceed. This allows access
|
||||
to the broker to be controlled outside of the
|
||||
mechanisms provided by MQTT.</para>
|
||||
<replaceable>true</replaceable>, a client connecting
|
||||
to this listener must provide a valid certificate in
|
||||
order for the network connection to proceed. This
|
||||
allows access to the broker to be controlled outside
|
||||
of the mechanisms provided by MQTT.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@@ -1465,7 +1604,7 @@ openssl dhparam -out dhparam.pem 2048</programlisting>
|
||||
<term><option>notifications_local_only</option> [ true | false ]</term>
|
||||
<listitem>
|
||||
<para>If set to <replaceable>true</replaceable>, only publish
|
||||
notification messages to the local broker giving
|
||||
notification messages to the local broker giving
|
||||
information about the state of the bridge connection.
|
||||
Defaults to <replaceable>false</replaceable>.</para>
|
||||
</listitem>
|
||||
|
||||
+10
-4
@@ -116,7 +116,7 @@
|
||||
<para>The options below may be given on the command line, but may also
|
||||
be placed in a config file located at
|
||||
<option>$XDG_CONFIG_HOME/mosquitto_pub</option> or
|
||||
<option>$HOME/.config/mosquitto_sub</option> with one pair of
|
||||
<option>$HOME/.config/mosquitto_pub</option> with one pair of
|
||||
<option>-option <replaceable>value</replaceable></option>
|
||||
per line. The values in the config file will be used as defaults
|
||||
and can be overridden by using the command line. The exceptions to
|
||||
@@ -254,9 +254,15 @@
|
||||
<term><option>-i</option></term>
|
||||
<term><option>--id</option></term>
|
||||
<listitem>
|
||||
<para>The id to use for this client. If not given, defaults
|
||||
to mosquitto_pub_ appended with the process id of the
|
||||
client. Cannot be used at the same time as the
|
||||
<para>The id to use for this client. If not given, a client id will
|
||||
be generated depending on the MQTT version being used. For v3.1.1/v3.1,
|
||||
the client generates a client id in the format
|
||||
<option>mosq-XXXXXXXXXXXXXXXXXX</option>, where the
|
||||
<option>X</option> are replaced with random alphanumeric
|
||||
characters. For v5.0, the client sends a zero length client id, and the
|
||||
server will generate a client id for the client.</para>
|
||||
|
||||
<para>This option cannot be used at the same time as the
|
||||
<option>--id-prefix</option> argument.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -272,9 +272,15 @@
|
||||
<term><option>-i</option></term>
|
||||
<term><option>--id</option></term>
|
||||
<listitem>
|
||||
<para>The id to use for this client. If not given, defaults
|
||||
to mosquitto_rr_ appended with the process id of the
|
||||
client. Cannot be used at the same time as the
|
||||
<para>The id to use for this client. If not given, a client id will
|
||||
be generated depending on the MQTT version being used. For v3.1.1/v3.1,
|
||||
the client generates a client id in the format
|
||||
<option>mosq-XXXXXXXXXXXXXXXXXX</option>, where the
|
||||
<option>X</option> are replaced with random alphanumeric
|
||||
characters. For v5.0, the client sends a zero length client id, and the
|
||||
server will generate a client id for the client.</para>
|
||||
|
||||
<para>This option cannot be used at the same time as the
|
||||
<option>--id-prefix</option> argument.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -295,9 +295,15 @@
|
||||
<term><option>-i</option></term>
|
||||
<term><option>--id</option></term>
|
||||
<listitem>
|
||||
<para>The id to use for this client. If not given, defaults
|
||||
to mosquitto_sub_ appended with the process id of the
|
||||
client. Cannot be used at the same time as the
|
||||
<para>The id to use for this client. If not given, a client id will
|
||||
be generated depending on the MQTT version being used. For v3.1.1/v3.1,
|
||||
the client generates a client id in the format
|
||||
<option>mosq-XXXXXXXXXXXXXXXXXX</option>, where the
|
||||
<option>X</option> are replaced with random alphanumeric
|
||||
characters. For v5.0, the client sends a zero length client id, and the
|
||||
server will generate a client id for the client.</para>
|
||||
|
||||
<para>This option cannot be used at the same time as the
|
||||
<option>--id-prefix</option> argument.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
MAJOR=1
|
||||
MINOR=6
|
||||
REVISION=4
|
||||
REVISION=7
|
||||
|
||||
sed -i "s/^VERSION=.*/VERSION=${MAJOR}.${MINOR}.${REVISION}/" config.mk
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
name: mosquitto
|
||||
version: 1.6.4
|
||||
version: 1.6.7
|
||||
summary: Eclipse Mosquitto MQTT broker
|
||||
description: This is a message broker that supports version 3.1 and 3.1.1 of the MQTT
|
||||
protocol.
|
||||
|
||||
+6
-4
@@ -100,6 +100,8 @@ int bridge__new(struct mosquitto_db *db, struct mosquitto__bridge *bridge)
|
||||
new_context->tls_version = new_context->bridge->tls_version;
|
||||
new_context->tls_insecure = new_context->bridge->tls_insecure;
|
||||
new_context->tls_alpn = new_context->bridge->tls_alpn;
|
||||
new_context->tls_engine = db->config->default_listener.tls_engine;
|
||||
new_context->tls_keyform = db->config->default_listener.tls_keyform;
|
||||
#ifdef FINAL_WITH_TLS_PSK
|
||||
new_context->tls_psk_identity = new_context->bridge->tls_psk_identity;
|
||||
new_context->tls_psk = new_context->bridge->tls_psk;
|
||||
@@ -137,7 +139,7 @@ int bridge__connect_step1(struct mosquitto_db *db, struct mosquitto *context)
|
||||
|
||||
if(!context || !context->bridge) return MOSQ_ERR_INVAL;
|
||||
|
||||
context__set_state(context, mosq_cs_new);
|
||||
mosquitto__set_state(context, mosq_cs_new);
|
||||
context->sock = INVALID_SOCKET;
|
||||
context->last_msg_in = mosquitto_time();
|
||||
context->next_msg_out = mosquitto_time() + context->bridge->keepalive;
|
||||
@@ -257,7 +259,7 @@ int bridge__connect_step2(struct mosquitto_db *db, struct mosquitto *context)
|
||||
HASH_ADD(hh_sock, db->contexts_by_sock, sock, sizeof(context->sock), context);
|
||||
|
||||
if(rc == MOSQ_ERR_CONN_PENDING){
|
||||
context__set_state(context, mosq_cs_connect_pending);
|
||||
mosquitto__set_state(context, mosq_cs_connect_pending);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@@ -316,7 +318,7 @@ int bridge__connect(struct mosquitto_db *db, struct mosquitto *context)
|
||||
|
||||
if(!context || !context->bridge) return MOSQ_ERR_INVAL;
|
||||
|
||||
context__set_state(context, mosq_cs_new);
|
||||
mosquitto__set_state(context, mosq_cs_new);
|
||||
context->sock = INVALID_SOCKET;
|
||||
context->last_msg_in = mosquitto_time();
|
||||
context->next_msg_out = mosquitto_time() + context->bridge->keepalive;
|
||||
@@ -410,7 +412,7 @@ int bridge__connect(struct mosquitto_db *db, struct mosquitto *context)
|
||||
|
||||
return rc;
|
||||
}else if(rc == MOSQ_ERR_CONN_PENDING){
|
||||
context__set_state(context, mosq_cs_connect_pending);
|
||||
mosquitto__set_state(context, mosq_cs_connect_pending);
|
||||
}
|
||||
|
||||
HASH_ADD(hh_sock, db->contexts_by_sock, sock, sizeof(context->sock), context);
|
||||
|
||||
+4
-10
@@ -25,6 +25,7 @@ Contributors:
|
||||
#include "packet_mosq.h"
|
||||
#include "property_mosq.h"
|
||||
#include "time_mosq.h"
|
||||
#include "util_mosq.h"
|
||||
#include "will_mosq.h"
|
||||
|
||||
#include "uthash.h"
|
||||
@@ -38,7 +39,7 @@ struct mosquitto *context__init(struct mosquitto_db *db, mosq_sock_t sock)
|
||||
if(!context) return NULL;
|
||||
|
||||
context->pollfd_index = -1;
|
||||
context__set_state(context, mosq_cs_new);
|
||||
mosquitto__set_state(context, mosq_cs_new);
|
||||
context->sock = sock;
|
||||
context->last_msg_in = mosquitto_time();
|
||||
context->next_msg_out = mosquitto_time() + 60;
|
||||
@@ -209,14 +210,14 @@ void context__disconnect(struct mosquitto_db *db, struct mosquitto *context)
|
||||
}else{
|
||||
session_expiry__add(db, context);
|
||||
}
|
||||
context__set_state(context, mosq_cs_disconnected);
|
||||
mosquitto__set_state(context, mosq_cs_disconnected);
|
||||
}
|
||||
|
||||
void context__add_to_disused(struct mosquitto_db *db, struct mosquitto *context)
|
||||
{
|
||||
if(context->state == mosq_cs_disused) return;
|
||||
|
||||
context__set_state(context, mosq_cs_disused);
|
||||
mosquitto__set_state(context, mosq_cs_disused);
|
||||
|
||||
if(context->id){
|
||||
context__remove_from_by_id(db, context);
|
||||
@@ -274,10 +275,3 @@ void context__remove_from_by_id(struct mosquitto_db *db, struct mosquitto *conte
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void context__set_state(struct mosquitto *context, enum mosquitto_client_state state)
|
||||
{
|
||||
if(context->state != mosq_cs_disused){
|
||||
context->state = state;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user