Commit Graph

905 Commits (4a7da066e0c81a2daacb5fbe99805151d95a3b26)

Author SHA1 Message Date
Roger A. Light 6b32cf61b2 CMake build fixes, including sqlite support. 4 years ago
Roger A. Light 306215db39 Split library actions.c for easier discoverability. 4 years ago
Roger A. Light b5c77f264f Build fixes 4 years ago
Roger A. Light 4e731d2ac7 Fix lws based websockets connections. 4 years ago
Roger A. Light 75fa83976c Fix `seconds` part of mosquitto_time_ns() on Windows. 4 years ago
Roger A. Light 73f03983fb Socks proxy test plus fixes. 4 years ago
Roger A. Light fa9c2d0285 Fix incorrect header position. 4 years ago
Roger A. Light aa96c2d922 Check accept key with websockets clients. 4 years ago
Roger A. Light f5625f499f Client HTTP request size configurable. 4 years ago
Roger A. Light 0a0f4ead42 Plugin interface interface and test improvements. 4 years ago
Roger A. Light d546ba461a Test fixes. 4 years ago
Roger A. Light 500542351d Set pointers to NULL after freeing. 4 years ago
Roger A. Light 0f8733627a Plugin persistence interface. 4 years ago
Roger A. Light 2501a64035 Merge branch 'master' into develop 4 years ago
Roger A. Light eafa848180 Add client message stats to xtreport. 4 years ago
Roger A. Light affe6ece83 Add client msg int to allow easier ordering for plugins. 4 years ago
Roger A. Light 3b8a2e827e Fix compile flags. 4 years ago
Roger A. Light 94fcd470d0 Fix incorrect subscribe_callback in mosquittopp.h.
Closes #2367. Thanks to Jens Alfke.
4 years ago
Roger A. Light 11975332d4 Fix mosquitto_topic_matches_sub2() not using the length parameters.
Closes #2364. Thanks to Jens Alfke.
4 years ago
Roger A. Light f3590f3020 Don't pass NULL to printf %s.
This is undefined behaviour, and some platforms don't like it.

Issue #2355. Thanks to CJ Lee.
4 years ago
Roger Light 68504da4a6
Merge pull request #2372 from podsvirov/install-libmosquitto-archive
Set ARCHIVE DESTINATION for mosquitto library
4 years ago
Roger A. Light 65d20271a7 Better string 4 years ago
Konstantin Podsvirov b34817cfab Set ARCHIVE DESTINATION for mosquitto library
Signed-off-by: Konstantin Podsvirov <konstantin@podsvirov.pro>
4 years ago
Konstantin Podsvirov 6187143384 Set ARCHIVE DESTINATION for mosquittopp library
Signed-off-by: Konstantin Podsvirov <konstantin@podsvirov.pro>
4 years ago
Roger Light cd07f1136b Bump copyrights. 4 years ago
Roger A. Light 8ac11929cc Merge branch 'master' into develop 4 years ago
Roger Light 92f3db92d7 Windows build fixes. 4 years ago
Roger A. Light 7b614b3b59 Move to end of file on append, when on Windows. 4 years ago
Roger A. Light 91e8344a3e Windows build fixes. 4 years ago
Roger Light 51eda2bf79 Add more efficient keepalive check. 4 years ago
Roger A. Light 21ded3df0d Build fix 4 years ago
Roger A. Light 799cdead15 Experimental custom websockets support. 4 years ago
Roger A. Light be80a3f4d0 Fix client id not showing in log on failed connections, where possible. 4 years ago
Roger A. Light a1a190b482 Pointless whitespace tidy. 4 years ago
Roger A. Light 0ce167c472 Fix log file being truncated on Windows. 4 years ago
Roger Light 3f62e80300
Merge pull request #2317 from doragasu/fixes_discon_cb_on_tls_err
Call disconnect callback on TLS error.
4 years ago
Roger A. Light 0f2f77c945 Improve idle / mux timeout performance. 4 years ago
Roger Light 88dfac8e88 Windows threading support for the library. 4 years ago
Roger A. Light 9e28eea0a2 Initialise sockpairR/W to invalid in `mosquitto_reinitialise()`
This avoids closing invalid sockets in `mosquitto_destroy()` on error.

Closes #2326. Thanks to Arrigo Zanette.
4 years ago
Roger A. Light 330bf6efdc Various fixes around inflight quota management.
Closes #2306. Thanks to canique.
4 years ago
doragasu 4471ee9e47 Call disconnect callback on TLS error.
When using the library asynchronously, TLS errors caused e.g. because
of the date/time not set correctly, cause the connection to be silently
dropped without the disconnection callback being invoked, as described
in issue #1052.

This commit fixes the issue, returning the behavior to the one the
library had previous to version 1.5.4, if a TLS error occurs, the
disconnect callback will be invoked for the client to get notified of
the error.

Signed-off-by: doragasu <doragasu@protonmail.com>
4 years ago
Roger A. Light aa29b45e70 Merge branch 'master' into develop 4 years ago
Roger A. Light d09591d92e Fix reconnecting in some cases when using MOSQ_OPT_TLS_USE_OS_CERTS.
Fix reconnecting failing when MOSQ_OPT_TLS_USE_OS_CERTS was in use, but none
of capath, cafile, psk, nor MOSQ_OPT_SSL_CTX were set, and
MOSQ_OPT_SSL_CTX_WITH_DEFAULTS was set to the default value of true.

Closes #2288. Thanks to Poltorak Serguei.
4 years ago
Roger A. Light 605131502b Fix MOSQ_OPT_SSL_CTX not being able to be set to NULL.
Closes #2289. Thanks to Poltorak Serguei.
4 years ago
Roger A. Light 9d6a73f9f7 Fix CONNECT performance with many user-properties.
An MQTT v5 client connecting with a large number of user-property properties
could cause excessive CPU usage, leading to a loss of performance and
possible denial of service. This has been fixed.
4 years ago
Roger Light 32af599c81 Fix $share subscriptions not being recovered for durable clients.
If a plugin had granted ACL subscription access to a
durable/non-clean-session client, then removed that access, the client would
keep its existing subscription. This has been fixed.
4 years ago
Roger A. Light 376226c129 Build warning fixes. 4 years ago
Roger A. Light 9b25dd3b0d libressl build fixes.
Closes #2198. Thanks to Theo Buehler.
4 years ago
Roger A. Light 0d1837ebe3 Deconfigure thread mode when the loop thread ends.
Threaded mode is deconfigured when the mosquitto_loop_start() thread ends,
which allows mosquitto_loop_start() to be called again.

Closes #2242. Thanks to Timo Lange.
4 years ago
Roger A. Light 9526b4cf23 Check for file==dir only when reading. 4 years ago
Roger Light ba2ca33671 Strict protocol compliance fixes, and extensive test suite. 4 years ago
Roger Light 723b5d7081 Fix listener mount_point not being removed on outgoing messages.
Closes #2244. Thanks to alflexRH.
4 years ago
Roger Light 6608e852a1 Fix broker not quiting if `password_file` is specified as a directory.
Closes #2241. Thanks to Bryan Pearson.
4 years ago
Roger Light 93b2232bb9 Apply max_keepalive to MQTT v3.1.1 and v3.1 clients. 4 years ago
Roger A. Light ea371564e7 Disable TLS 1.3 when using TLS-PSK, because it isn't correctly config'd. 4 years ago
Roger A. Light a37c8e65d2 TLS-PSK mismatch fix.
Produce an error if a TLS-PSK client tries to connect to a broker
that is not configured with TLS-PSK.
4 years ago
Roger A. Light 79542158f4 Fix `max_connections` option not being correctly counted. 4 years ago
Roger A. Light 9a97a5afc4 Improve client protocol version number logging.
Protocol version numbers reported in the log when a client connects now
match the MQTT protocol version numbers, not internal Mosquitto values.
4 years ago
Roger A. Light 4e146b7b53 Fix possible out of bounds memory reads when reading configuration.
This would happen with a corrupt/crafted configuration file. Unless your
configuration file is writable by untrusted users this is not a risk.

Closes #567213. Thanks to Roland Sako.
4 years ago
Roger Light cad11de873
Merge pull request #2249 from cdelston0/develop-transitive-topics
Swap bridge topic storage from array to linked-list
4 years ago
Roger A. Light 49065f03a8 Merge remote-tracking branch 'origin/fixes' into develop 4 years ago
Chris Elston aa5233fc85 Swap bridge topic array to linked list
Bridge topics are added on startup to an allocated array which is
reallocated with each new topic.  This change alters bridge topic
storage to use a singly linked list.

This is to facilitate upcoming changes to support bridge topic
add/remove operations.
4 years ago
Roger A. Light a02aad0a9c Add mosquitto_sub_matches_acl_with_pattern. 4 years ago
Roger A. Light f90e55bd36 Reduce memory allocations when sending packets. 4 years ago
Roger A. Light e0309acebc Add mosquitto_sub_matches_acl()
This moves the sub matching sub code from the dynsec plugin to the library and broker, and removes all of the malloc calls at the same time.
4 years ago
Roger A. Light b3045d1adf Fix pattern matching with invalid prefix. 4 years ago
Roger A. Light 6502d6e5f4 Add mosquitto_topic_matches_sub_with_pattern()
And use it in the default security checks.
4 years ago
Roger A. Light dfd5dc5b92 Remove unused struct member. 4 years ago
Roger A. Light e0bcf8cda4 Simplify SSL accept/connect. 4 years ago
Roger A. Light 8416f928df Revert premature want_connect fix. 4 years ago
Roger A. Light 403691ce40 Add missing return types. 4 years ago
Roger A. Light 104b94db57 Fix non-reachable bridge blocking the broker on Windows.
Closes #2172. Thanks to Niclas Lindgren.
4 years ago
Roger A. Light 625e2a5060 Refactor to remove duplicate code. 4 years ago
Roger A. Light 906a515704 Simplify client message properties, only one is used. 4 years ago
Roger Light f934230251 Simplify out packet mutex use. 4 years ago
Roger A. Light 214feb8f6b Merge branch 'fixes' into develop 4 years ago
Roger A. Light 0d3870585b Plugin delayed authentication. 4 years ago
Roger A. Light 16fb0025a7 Improve QoS 0 outgoing packet queueing. 4 years ago
Roger Light 9bb58a88fc Cleanup messsage before return.
Coverity scan #1451483.
4 years ago
Roger Light 9c9ca33d63 Fix two potential leaks. 4 years ago
Roger Light 0a90e62f93 CMake tidy. 4 years ago
Roger Light 931c590a37
Merge pull request #2156 from abiliojr/improve_tls
add cipher settings for bridge, and support for TLS 1.3 ciphers
4 years ago
Roger A. Light a2ab20df13 Don't call read() if sockpairR < 0.
Coverity #1450782.
4 years ago
Roger A. Light b7b3a42e75 Strict build fixes. 4 years ago
Roger A. Light 8a03b5ad5c Function for checking if a context is connected. 4 years ago
Roger Light b4c86df6f5 Fix missing control path.
Closes #2190. Thanks to RengeRenge.
4 years ago
Roger Light e1c8f09372 Remove C++ style comments. 4 years ago
Roger Light ef7662ca8e Merge branch 'master' into develop 4 years ago
Christian Beier fe10226cc9 Fix building with Visual Studio 2008
This older Microsoft compiler does not support mixing declarations and
code and misses some error defines. This commit enables building with
VS2008 by moving up some variable declarations and defining error
codes to their WinSock counterparts in case they're not defined.

Signed-off-by: Christian Beier <info@christianbeier.net>
5 years ago
Roger Light 6ebbb4d654 Fix possible socket leak.
This would occur if a client was using `mosquitto_loop_start()`, then if
the connection failed due to the remote server being inaccessible they
called `mosquitto_loop_stop(, true)` and recreated the mosquitto object.

See: https://www.eclipse.org/forums/index.php?t=rview&goto=1839865#msg_1839865
5 years ago
Abilio Marques c637a192a3 add support for tlsv1.3 ciphers
Signed-off-by: Abilio Marques <abiliojr@gmail.com>
5 years ago
Roger A. Light 3cc6630d64 alias_mosq.c must be part of the cmake lib build. 5 years ago
Roger A. Light de9780343b Add support for MQTT v5 broker->client topic aliases.
This is on a first-come-first-served basis for now.
Also broker to bridge topic aliases.
5 years ago
Roger Light 0f9e5795a2
Merge pull request #2145 from abiliojr/empty_sockpairR
Fully empty sockpairR on interruptible_sleep
5 years ago
Abilio Marques dd4a64b049 fully empty socketpairR on interruptible_sleep
Signed-off-by: Abilio Marques <abiliojr@gmail.com>
5 years ago
Abilio Marques 91f34e084f fix duplication of messages during connect
Signed-off-by: Abilio Marques <abiliojr@gmail.com>
5 years ago
Roger Light 2de8c15bc9 Minor build fixes. 5 years ago
Roger Light cca41d176d Fix inconsistent sign in log__printf declaration. 5 years ago
Roger Light 898da756ed Remove unused message timestamp member. 5 years ago
Roger Light dd890ff0ee Add missing header. 5 years ago
Roger Light 1e94e08843 Callbacks no longer block other callbacks.
The can also be set from within a callback.

Closes #2127. Thanks to Weston Schmidt.
5 years ago
Roger A. Light f8838243fb Fix connections retrying very rapidly in some situations.
Thanks to Abilio Marques.
5 years ago
Roger A. Light b7a08d5c40 Fix TLS bridge/lib incorrectly connecting on invalid CA file.
Closes #2130. Thanks to becz.
5 years ago
Roger A. Light fd036b9435 Merge branch 'fixes' into develop 5 years ago
Roger A. Light abc288a435 Experimental kqueue support. 5 years ago
Roger A. Light e401def06d Fix QoS 0 messages not being delivered when max_queued_bytes was configured.
Closes #2123. Thanks to quackgizmo.
5 years ago
Roger A. Light 2190e98b20 Fix memory tracking not being available on FreeBSD or macOS.
Closes #2096. Thanks to blusewang.
5 years ago
Roger A. Light 3f84ad006d Add `on_pre_connect()` callback.
This allows clients to update usernames/passwords/TLS parameters prior
to reconnecting.
5 years ago
Roger A. Light 9b08faf0bd Fix mosquitto_{pub|sub}_topic_check() function returns.
The would not return MOSQ_ERR_INVAL on topic == NULL.
5 years ago
Roger A. Light e98cc28cd3 Move check after current_out_packet is updated. 5 years ago
Przemek Zygmunt 18bad1ff32 Unconditionally adding an event to the epoll causes 100% CPU usage. This happens when the connection to the server is established and the client has not sent any data yet.
Signed-off-by: Przemek Zygmunt <p.zygmunt@acsoftware.pl>
5 years ago
Roger A. Light 6e3738dcf0 Fix bridges not always connecting on Windows.
Closes #2043. Thanks to ttsorensen.
5 years ago
Roger A. Light 706a1f3f29 Fix more minor compiler warnings. 5 years ago
Roger A. Light a4389fc9ce Fix SPDX identifiers: EDL-1.0 -> BSD-3-Clause.
The two licenses are the same.
5 years ago
Roger A. Light c9aa3ca847 Add MOSQ_OPT_DISABLE_SOCKETPAIR. 5 years ago
Roger A. Light 370cec5edd Fixes for lots of minor build warnings highlighted by Visual Studio. 5 years ago
Roger A. Light fabdfcc060 Further fix for large packets not being sent in a timely fashion. 5 years ago
Roger Light c604cf8fd0 net__write buf should be const. 5 years ago
Roger A. Light b2da540c64 Fix large packets not being completely published to slow clients.
Also fix bridge connection not relinquishing POLLOUT after messages are
sent.

Closes #1977. Thanks to marchaesen.
Closes #1979. Thanks to GorazdKikelj.
5 years ago
Roger A. Light 2db9aecac4 Do not reset bind address option if passed NULL.
mosquitto_connect_bind_async() and mosquitto_connect_bind_v5() should not
reset the bind address option if called with bind_address == NULL.

Otherwise calling mosquitto_connect_async() will *force* the bind
address to be reset, even if previously set with
mosquitto_string_option().
5 years ago
Roger A. Light e02b5a2775 Fix $SYS/broker/publish/messages/+ counters not being updated for QoS 1, 2
Closes #1968. Thanks to promahn.
5 years ago
Roger A. Light 757902bcf8 Improve struct packing. 5 years ago
Roger A. Light d8dcfd75fe lib: Fix DH group not being set for TLS connections.
This meant ciphers using DHE couldn't be used.

Closes #1925. Closes #1476. Thanks to Jonathan Sönnerup, Valerii
Demeshko, and sectokia.
5 years ago
Nikolay Raspopov 71845d28ac
Fixed some VS2017 compilation error and warnings (#1916)
* Fixed some VS2017 compilation errors and warnings.

Signed-off-by: raspopov <raspopov@cherubicsoft.com>
5 years ago
Roger A. Light 828e7ae130 More conversion fixes. 5 years ago
Roger A. Light df1802d8f1 Fix client state conversion warnings. 5 years ago
Roger A. Light 232a759320 Log client port on new connections.
Closes #1911. Thanks to twegener-embertec.
5 years ago
Roger A. Light 3731535298 Add SPDX license identifiers. 5 years ago
Roger A. Light 04c110183c Bridge support for MQTT v5 maximum-qos. 5 years ago
Roger A. Light e030ca45cd Fix connack error printing. 5 years ago
Roger A. Light 0c22f475ff Fix bridges incorrectly setting Wills to manage remote notifications.
This is for when `notifications_local_only` was set true.

Closes #1902. Thanks to marcinkowskip.
5 years ago
Roger A. Light b34dcd2a67 Final remove support for legacy libwebsockets
This means libwebsockets < 2.4.0.
5 years ago
Roger A. Light 29c771cdd4 Add lib and client support for OS CA certs
- Add `MOSQ_OPT_TLS_USE_OS_CERTS` option, to instruct the client to load and  trust OS provided CA certificates for use with TLS connections.
- All clients now load OS provided CA certificates if used with `-L
  mqtts://...`, or if port is set to 8883 and no other CA certificates are
  used. Closes #1824.
- Add the `--tls-use-os-certs` option to all clients.

Closes #1824. Thanks to Jens Reimann.
5 years ago
Roger A. Light a3258f7d82 Packet cleanup without locks
Prevents use of invalid mutexes during mosquitto_destroy.

Closes #1914. Thanks to Nikolay Raspopov.
5 years ago
Roger A. Light 584cf51ba7 Update to EPL-2.0 5 years ago
Roger A. Light dac841a342 Better outgoing QoS 0 limiting. 5 years ago
Roger A. Light 2755fe3c4c Apply limits to QoS 0 outgoing messages. 5 years ago
Roger A. Light 4da1f15b41 Fix Coverity Scan errors.
1436854
1436844
5 years ago
Roger A. Light d26534e22b Fix Coverity scan issues.
1302840
1353078
1431131
1431134
1431135
1436826
1436827
1436828
1436830
1436831
1436834
1436835
1436838
1436839
1436840
1436844
1436846
1436853
1436854
1436859
1436860
1436861
1436863
1436867
5 years ago
Roger A. Light 4e3b8ed2b5 Fix cherry picked commit. 5 years ago
Roger A. Light 10ecae6275 Fix bridge sock not being removed from sock hash on error
Prior to this, duplicate entries could be added to the sock hash, which caused an infinite loop. Only affects bridges with bad settings on startup, and only when compiled using WITH_ADNS=yes.

Closes #1897. Thanks to Rodolfo Ochoa.
5 years ago
Franz Auernigg 18a6d79ab8 Fix cmake if condition in lib/CMakeLists.txt
Signed-off-by: Franz Auernigg <f.auernigg@commend.com>
5 years ago
Roger A. Light b816d46508 Use db as a global var instead of passing to functions.
This allows a big swath of ifdefs to be removed. It also means savings as the db var is not passed around all of the time, and makes it easier to remove the final broker call to mosquitto_time() call in packet_mosq.c. In one test this reduced the calls to mosquitto_time() from 295k to 48k.
5 years ago
Roger A. Light 108b23ce6d Reduce use of mosquitto_time() and time(). 5 years ago
Roger A. Light c2651cf005 Remove deprecation warning on libmosquittopp. 5 years ago
Roger A. Light 23d3c2641e Optimise epoll event to context/listener mapping. Allows quicker lookups. 5 years ago
Roger A. Light 4d6384c758 Build and conversion fixes for build variants. 5 years ago
Roger A. Light 8e7e4a9d9a Clients: Give warning if keepalive too low. 5 years ago
Arenoros 9c3a214a01 In android ndk doesn't exist librt and libpthread
Signed-off-by: Arenoros <arenoros@gmail.com>
5 years ago
raspopov add355a78b QNX has no pselect() either.
Signed-off-by: raspopov <raspopov@cherubicsoft.com>
5 years ago