Commit Graph

524 Commits

Author SHA1 Message Date
Roger A. Light
f952ae3a67 Fixed durable clients being unable to receive messages when offline.
This occurred when per_listener_settings was set to true.

Closes #1081. Thanks to dwin-wangjt.
2019-02-08 13:01:07 +00:00
Roger A. Light
d6a690aa8d Fix Will not being sent for Websockets clients.
Closes #1143. Thanks to salcedo.
2019-02-08 13:01:07 +00:00
Roger A. Light
ab8b57ff54 Allow broker to always restart on Windows when using log_dest file.
Closes #1080. Thanks to lcouz.
2019-02-08 13:01:07 +00:00
Roger Light
5236295159 Handle mismatched handshakes properly.
For example, a QoS1 PUBLISH with QoS2 reply.
2019-02-08 13:01:07 +00:00
Matthias Stone
4325c44baf Don't clear SSL context when TLS connection is closed.
Previous behaviour would clear the external SSL_CTX provided by
MOSQ_OPT_SSL_CTX. This required the user to reset the SSL_CTX every
disconnect, and trust that they were not leaking references.

Recreating the SSL context for every connection is not necessary, and the
SSL context is freed in mosquitto_destroy, which is sufficient.

Signed-off-by: Matthias Stone <matthias@bellstone.ca>
2019-02-08 13:01:07 +00:00
Roger A. Light
e8320cbf19 Fix TLS connections not working over SOCKS.
Thanks to Mark Oeltjenbruns.
2019-02-08 13:01:07 +00:00
Roger A. Light
be9c1071b0 Fix compilation when openssl deprecated APIs are not available.
Closes #1094. Thanks to Rosen Penev.
2019-02-08 13:01:07 +00:00
Roger A. Light
70c4097b6f Fix comparison of boolean values in CMake build.
Closes #1101. Thanks to Mojca Miklavec and Andrew L. Moore.
2019-02-08 13:01:07 +00:00
Maksym Ruchko
f6943b006a Fixed threaded enum lost in merges
Change was part of the original commit e8185ddaa7
"[166] Don't cancel external threads."
and then lost during code reorganizing and subsequent merge,
commits 970ba58da6 81cb7ab547

Signed-off-by: Maksym Ruchko <mruchko@advantech-bb.com>
2019-02-08 13:01:07 +00:00
Roger A. Light
e1976739b8 Fix duplicate error values.
Closes #1109. Thanks to Tifaifai.
2019-01-23 16:37:48 +00:00
Roger A. Light
ca3782b38d Test and fixes for will message expiry interval. 2019-01-22 17:51:57 +00:00
Roger A. Light
6a59e92db8 Set remaining message expiry interval when republishing. 2019-01-22 12:43:52 +00:00
Roger A. Light
f9a17e2782 Add alias support to the broker. 2019-01-18 21:30:34 +00:00
Roger Light
8513af4da5 Tests and fixes for shortened DISCONNECT packets. 2019-01-17 18:51:23 +00:00
Roger Light
4b97a90ef9 Tests and fixes for truncated PUB* packets
For the cases where reason_code is 0, or properties are missing.
2019-01-17 17:24:31 +00:00
Roger A. Light
326292681a Add maximum-qos support to broker and client.
This comes in the form of:

* Per listener maximum_qos option, which can be in the range 0-2.
* Changes to mosquitto_publish*() to return MOSQ_ERR_QOS_NOT_SUPPORTED
  if attempting to publish with a higher QoS than supported.
* Bridges will downgrade messages to match the maximum QoS.

More tests on the broker side (specifically bridges) are required. This
needs bridge support for MQTT 5 first.
2019-01-09 18:03:01 +00:00
Roger Light
930a314caf Add reason_code to on_publish_v5 callback. 2019-01-09 17:06:43 +00:00
Roger Light
740a128769 Support PUBREC reason code >=0x80 as partial qos2 flow. 2019-01-09 15:00:12 +00:00
Roger A. Light
aeba5b5d0d Fix and tests for client side receive-maximum. 2019-01-09 12:21:15 +00:00
Roger Light
84660e1cbe Send maximum limits for QoS>0.
This needs more work on the broker front to simplify the design.
2019-01-08 18:38:47 +00:00
Roger Light
67c1d4453e Receive maximum support for clients. 2019-01-08 14:24:41 +00:00
Roger Light
0546e7bebc Add mosquitto_int_option and mosquitto_void_option
This deprecates mosquitto_opts_set().
2019-01-08 14:21:02 +00:00
Roger A. Light
16e83bfe5d Process receive maximum (as max_inflight_messages). 2018-12-30 21:53:50 +00:00
Roger A. Light
659cd2a3b1 Read reason code for PUBREC/PUBREL. 2018-12-23 21:49:39 +00:00
Roger A. Light
7c3666d593 Subscription identifier support. 2018-12-20 15:32:43 +00:00
Roger A. Light
fcf4cd0b27 Merge branch 'master' into mqtt5 2018-12-19 14:11:11 +00:00
Roger A. Light
94fdc9cb44 Disallow UTF-8 control characters. 2018-12-18 10:15:28 +00:00
Roger A. Light
bc1349c0d7 Tests for user facing mosquitto_string_to_property_info function. 2018-12-14 19:31:49 +00:00
Roger A. Light
db7901884f Retain-as-published support. 2018-12-14 13:36:02 +00:00
Roger A. Light
4933f889ff Fix missing header. 2018-12-14 12:56:49 +00:00
Roger A. Light
a8ca5c83af Bump version. 2018-12-11 11:13:09 +00:00
Roger A. Light
afe011866c Remove unused variables. 2018-12-11 10:55:42 +00:00
Roger A. Light
a00dd29af8 Fix building where TLS-PSK is not available.
Closes #68.
2018-12-11 10:55:31 +00:00
Roger A. Light
f90ba23738 Retain handling support. 2018-12-06 22:25:45 +00:00
Roger A. Light
4fe75b1af0 Make user functions for reading properties easier to use. 2018-12-06 16:59:53 +00:00
Roger A. Light
73c46174f8 Don't call on_disconnect() twice if keepalive tests fail.
Closes #1067. Thanks to xingchen02.

Bug: https://github.com/eclipse/mosquitto/issues/1067
2018-12-06 10:45:57 +00:00
Roger A. Light
6ef2c79e9a Add max_keepalive, for limiting keepalives of MQTT v5 clients. 2018-12-06 08:49:02 +00:00
Roger A. Light
29846d282d Client library now reads its assigned client id. 2018-12-05 21:58:31 +00:00
Roger A. Light
fda66e8311 Add broker test for assigned client id. 2018-12-05 20:26:43 +00:00
Tamaki Nishino
d07864939a Check SSL_DATA_PENDING in mosquitto_loop_read()
Signed-off-by: Tamaki Nishino <otamachan@gmail.com>
2018-12-05 11:39:50 +00:00
Roger A. Light
5d02f58151 Fix reconnect delay backoff behaviour.
Closes #1027. Thanks to Harm Verhagen.

Bug: https://github.com/eclipse/mosquitto/issues/1027
2018-12-04 17:19:31 +00:00
Roger A. Light
e169f1c7c2 When using ADNS, don't ask for all network protocols when connecting.
This can lead to confusing "Protocol not supported" errors if the
network is down, because UDP sockets are provided.

Thanks to jsaak.

Closes #1062.

Bug: https://github.com/eclipse/mosquitto/issues/1062
2018-12-04 12:39:00 +00:00
Roger A. Light
867fe80e0e Properties are now freed after the callback. 2018-11-29 16:51:48 +00:00
Roger A. Light
1b854e250e Function for copying property lists. 2018-11-28 17:09:17 +00:00
Roger A. Light
d5108956bf Process session-expiry-interval on CONNECT and DISCONNECT.
Add test to check for invalid values.
2018-11-27 12:23:21 +00:00
Roger A. Light
54db895cb3 Rename clean_session to clean_start for v5. 2018-11-27 10:02:10 +00:00
Roger A. Light
0123ff1efe Rename *_with_properties() -> *_v5(). 2018-11-22 18:55:04 +00:00
Roger Light
f809ecbcbe Add DISCONNECT handling to library. 2018-11-22 18:13:18 +00:00
Roger Light
236e967161 Pass properties when disconnecting clients. 2018-11-22 18:09:31 +00:00
Roger Light
f7dc097f82 Move client disconnect code to own function. 2018-11-22 17:31:17 +00:00
Roger Light
3cb8a52ef3 Add reason code to mosquitto_disconnect_with_properties() 2018-11-22 16:56:17 +00:00
Roger Light
14c2f528cf Add reason code to send__disconnect(). 2018-11-22 16:52:39 +00:00
Roger A. Light
d64ce2e242 Make mosquitto_reason_string public. 2018-11-22 10:17:16 +00:00
Roger A. Light
94631ae68b Don't free properties any more, we use them. 2018-11-20 17:54:44 +00:00
Roger A. Light
59b3fdfdf8 Add client property value reading functions. 2018-11-20 17:54:26 +00:00
Roger A. Light
158189393e Add v5 client callbacks. 2018-11-20 14:36:18 +00:00
Roger A. Light
098a1c8ecf Fix subscribe_multiple datatypes. 2018-11-13 14:05:03 +00:00
Roger A. Light
beb96c6b8b Merge branch 'master' into develop 2018-11-11 21:41:44 +00:00
Roger A. Light
e81db23ce4 Bump version number. 2018-11-08 12:12:27 +00:00
Roger A. Light
71b8c4d892 Fix TLS connections when using an external event loop.
Affects the use of mosquitto_loop_read() and mosquitto_write().
Closes #990.
2018-11-07 21:08:10 +00:00
Iblis Lin
0368a8c01d add socket headers for FreeBSD
Signed-off-by: Iblis Lin <iblis@hs.ntnu.edu.tw>
2018-11-07 10:28:26 +00:00
Bartosz Taczała
e86b27a2da Adding support for QNX7.0.0
Change-Id: Id01e2880aa5cadc0e93a46b95fe675e1938051fa
Signed-off-by: Bartosz Taczała <bartosz.taczala@mobica.com>
2018-11-06 23:11:09 +00:00
Roger A. Light
f77c1ca91b private struct mqtt5__property -> public mosquitto_property. 2018-11-01 23:50:54 +00:00
Roger A. Light
f9e0fa246a Validate properties coming into client library. 2018-11-01 18:53:06 +00:00
Roger A. Light
8aa936936e Library and client support for topic-alias. 2018-11-01 15:47:21 +00:00
Roger A. Light
de3a9af1f7 Client+library support for unsubscribe properties. 2018-11-01 14:12:52 +00:00
Roger A. Light
741a8a9cc3 Client disconnect property support, plus disconnect packet fix. 2018-11-01 11:57:47 +00:00
Roger A. Light
383608613a Client+lib will property support. 2018-11-01 11:37:57 +00:00
Roger A. Light
12cba75c73 Client support for adding properties. 2018-10-31 12:38:39 +00:00
Roger A. Light
b462115fa6 Add reason code to PUBACK/REC/REL/COMP. 2018-10-31 08:24:28 +00:00
Roger A. Light
ba874c6014 Merge branch 'mqtt5' of gitlab.com:ralight/mosquitto-private into mqtt5 2018-10-30 14:58:57 +00:00
Roger A. Light
446ad6290a Add mosquitto_string_to_property_info. 2018-10-30 11:54:36 +00:00
Roger A. Light
c19b3598c0 Add mosquitto_string_to_command. 2018-10-30 11:40:06 +00:00
Roger A. Light
63a479564b Add mosquitto_property_command_check() 2018-10-30 11:32:37 +00:00
Roger A. Light
636e813d1c Load of constant renames ahead of making mqtt_protocol.h public. 2018-10-30 11:11:31 +00:00
Roger A. Light
9eebcf6704 Rename property__free_all->mosquitto_property_free_all
Make public function.
2018-10-30 10:16:42 +00:00
Roger A. Light
be5602be28 Add sections to mosquitto.h. 2018-10-30 10:03:08 +00:00
Roger A. Light
5aa983c210 Fix copy/paste error. 2018-10-25 20:41:34 +01:00
Roger A. Light
b6c667689d Write properties for all commands apart from AUTH. 2018-10-25 13:21:42 +01:00
Roger A. Light
8077376a79 Add read support for AUTH packets. 2018-10-25 12:54:17 +01:00
Roger A. Light
ca40255720 mid == 0 is a protocol error. 2018-10-25 12:12:57 +01:00
Roger A. Light
eefa7f7604 All existing commands read properties. 2018-10-25 12:11:00 +01:00
Roger A. Light
723d9c2782 Check whether properties are on the correct commands. 2018-10-25 11:23:04 +01:00
Roger A. Light
267178bd99 User properties are copied from PUBLISH to PUBLISH. 2018-10-25 10:24:19 +01:00
Roger A. Light
0baf358cf8 Add properties member to will struct. 2018-10-24 14:07:09 +01:00
majekw
7f1419e4de Fix mosquitto_pub -l if compiled using cmake.
Since dde005ef92 mosquito_pub is throwing error
that 'threading support has not been compiled' when compiled using cmake.
It looks like WITH_THREADING flag is not set at top level Makefile and used
only in lib/ directory, so library is correctly compiled with threading.
But for client this flag is undefined, so it gives error on '-l' option.

This commit moves part related to WITH_THREADING flag out of lib/CMakeLists.txt
to top levele CMakeLists.txt, so it could be accessible to all subdirectories.

Signed-off-by: Marek Wodzinski <majek@w7i.pl>
2018-10-23 18:56:00 +01:00
Roger A. Light
0a9ee5b4cf Fix memory leak when reconnecting with TLS errors.
Fix memory leak that occurred if mosquitto_reconnect() was used when TLS
errors were present.

Closes #592. Thanks to smartdabao and aaronovz1.
2018-10-23 10:46:55 +01:00
Roger A. Light
35dea07dcd Merge branch 'master' 2018-10-23 10:39:20 +01:00
Roger A. Light
40ed672ecf Fix topic matching tests and function. 2018-10-16 22:49:13 +01:00
Roger A. Light
77099bb58c Add property write tests. 2018-10-16 21:32:13 +01:00
Roger A. Light
4daaaaf4a7 Add property writing support, untested. 2018-10-16 14:35:37 +01:00
Roger A. Light
262ac3fb5b Fix varint length reporting. 2018-10-10 17:53:19 +01:00
Roger A. Light
6609bbac10 Move topic matching tests to unit tests. Needs improving. 2018-10-10 17:52:41 +01:00
Roger A. Light
c0ff424082 Add property__get_length_all() and property__get_length().
For getting the number of bytes needed for writing a property list.
2018-10-10 14:50:30 +01:00
Roger A. Light
8210c1fa7a All outgoing packets now write property length for MQTT 5.
At the moment this only writes a 0 property length, i.e. no properties.
It does mean that output packets are more correct than before.
2018-10-10 12:42:27 +01:00
Roger A. Light
e5eb03b2e6 Allow building without shared library. 2018-10-07 00:56:42 +01:00
Roger A. Light
abb3fee1f8 Coverage reporting for whole broker. 2018-10-06 21:56:48 +01:00
Roger A. Light
8e793f68e1 Simplify prop validation. 2018-10-04 22:58:46 +01:00
Roger A. Light
bc1caedc32 Some property string read tests. 2018-10-04 22:49:34 +01:00
Roger A. Light
f59526a014 Property read in16 tests. 2018-10-04 21:16:46 +01:00
Roger A. Light
e14b613a02 Property read int32 tests. 2018-10-04 19:04:21 +01:00
Roger A. Light
f4b2838574 Property reading, and tests for byte properties. 2018-10-04 17:18:57 +01:00
Roger A. Light
05b40b90db Add reason strings. 2018-10-04 12:43:43 +01:00
Roger A. Light
75b6851c76 Property identifer is a varint. 2018-10-04 10:44:11 +01:00
Roger A. Light
572be268e5 Fix signedness of varint reading. 2018-10-04 09:53:30 +01:00
Roger A. Light
366744bad7 Fix subscribe_multiple datatypes. 2018-10-04 09:46:51 +01:00
Roger A. Light
c9d9ad8e72 UTF-8 validation tests and fixes. 2018-10-04 09:03:54 +01:00
Roger A. Light
72131c84ce Binary data read functions and tests. 2018-10-03 21:35:33 +01:00
Roger A. Light
debf7493ad UTF-8 validation tests and fixes. 2018-10-03 18:42:15 +01:00
Roger A. Light
400db91166 Handle UTF-8 validation in packet__read_string. 2018-10-03 15:04:24 +01:00
Roger A. Light
b6b8da1fa6 Variable Byte Integer reading tests. 2018-10-03 11:57:20 +01:00
Roger A. Light
99a1c0e43a Move simple datatype reading functions to own file.
This facilitates easier testing.
2018-10-03 10:23:58 +01:00
Roger A. Light
1488992ea8 Naive reading of MQTT 5 properties. No processing done. 2018-10-02 16:43:40 +01:00
Roger A. Light
17b3709790 Fix varint reading. 2018-10-02 14:07:23 +01:00
Roger Light
6c9e8d51c2 Merge branch 'develop' into mqtt5 2018-10-02 11:28:03 +01:00
Roger A. Light
1867f30785 Merge branch 'master'
Conflicts:
	ChangeLog.txt
2018-10-02 08:31:54 +01:00
Roger A. Light
cf9a72d8db Add mosquitto_subscribe_multiple. 2018-09-27 22:05:15 +01:00
Roger A. Light
c78003cacf Bump version number, add CVE details. 2018-09-25 16:26:28 +01:00
Roger A. Light
f9c9f3d396 Fix incorrect hash usage with duplicate clients.
Fix duplicate clients being added to by_id hash before the old client
was removed.

Closes #645.
2018-09-25 14:25:54 +01:00
Roger A. Light
59bd07627d Various build improvements to help packaging. 2018-09-25 14:25:54 +01:00
Roger A. Light
dd0e0d91b0 Fix build on Windows. 2018-09-20 10:38:35 +01:00
Roger A. Light
3f87232065 Bump version number. 2018-09-19 18:09:43 +01:00
Roger A. Light
4ee6941188 Primitive v5 CONNACK support - no properties. 2018-09-19 11:13:50 +01:00
Roger A. Light
561513fdd4 Very simple v5 CONNECT support - no properties. 2018-09-19 11:00:15 +01:00
Roger A. Light
ccc97d8c96 Function for reading variable length ints from packet. 2018-09-19 10:59:57 +01:00
Roger A. Light
33a523eea9 Add identifiers for v5.
Clients know about v5, just need library support...
2018-09-19 10:59:41 +01:00
Roger A. Light
a127c93a5a Property identifiers. 2018-09-19 10:59:31 +01:00
Roger A. Light
99c6ec7f6e Protocol name will never be changed from MQTT. 2018-09-19 10:58:36 +01:00
Roger A. Light
5dc88fe8f3 Add v5 return codes 2018-09-19 10:58:23 +01:00
Roger A. Light
0bacff11df Rename mqtt3_protocol.h -> mqtt_protocol.h. 2018-09-19 10:58:12 +01:00
Roger A. Light
48f096bc1c Read/write new 32 bit ints from packets. 2018-09-19 10:57:16 +01:00
Michael Heimpold
a459e93498 Install pkg-config files also for non-CMake builds
At the moment, pkg-config hint files are only installed when CMake is
used as build system. However, it is very convenient for programs using
libmosquitto to have these files always in place, so let's add it
here, too.

Signed-off-by: Michael Heimpold <michael.heimpold@i2se.com>
2018-09-18 15:25:22 +01:00
Fredrik Fornwall
915e91d9be Fix build with OPENSSL_NO_ENGINE
Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
2018-09-18 15:02:32 +01:00
Roger A. Light
ae45bd3d40 Update changelog and fixes to #927 PR. 2018-09-18 14:57:13 +01:00
yzhivik
96e62d596f fix SOCKS5 username and password set
fix SOCKS5 request wrt IP4/IP6/FQDN

Signed-off-by: yzhivik <yuriy.zhyvytsya@gmail.com>
2018-09-18 14:34:31 +01:00
Roger A. Light
a9da3c263d Bump version number.
Signed-off-by: Roger A. Light <roger@atchoo.org>
2018-08-16 17:01:08 +01:00
Roger A. Light
4ccc68d2df Revert incorrect change. 2018-08-16 11:33:06 +01:00
Roger A. Light
9d30625622 Build fix for Windows. 2018-08-16 11:16:16 +01:00
Roger A. Light
88765a5e80 Consistent use of config.h across the project. 2018-08-16 11:14:51 +01:00
Roger A. Light
a199cac69e Don't confuse expiring and duplicate clients. 2018-08-15 17:27:59 +01:00
Roger A. Light
0ec090f31a Fixes for building on FreeBSD. 2018-08-15 17:02:56 +01:00
Roger A. Light
10b19a42ed Fixes for building on NetBSD.
Closes #258.

Thanks to Daniel Ölschlegel.
2018-08-09 15:21:40 +01:00
Roger A. Light
c757cb0912 Remove incorrect comment. 2018-08-09 15:01:39 +01:00
Roger A. Light
e185d18917 Better fix for #851.
Ensure all sockets that are closed are set to INVALID_SOCKET.

Signed-off-by: Roger A. Light <roger@atchoo.org>
2018-08-08 15:23:03 +01:00
Roger A. Light
7f0b4d6271 Fix connection problems when using mosquitto_connect_async().
The connection wouldn't always complete if mosquitto_loop_start() was
called before mosquitto_connect_async(). Closes #848.

Thanks to Ian Gough.

Bug: https://github.com/eclipse/mosquitto/issues/848

Signed-off-by: Roger A. Light <roger@atchoo.org>
2018-08-08 09:21:19 +01:00
Roger A. Light
575dce91f0 Fix segfault on startup if bridge CA certificates could not be read.
Closes #851.

Thanks to chelliwell.

Signed-off-by: Roger A. Light <roger@atchoo.org>
2018-08-02 15:06:09 +01:00
Roger A. Light
4bacbecb1b Fix some places where return codes were incorrect.
Closes #850.

Signed-off-by: Roger A. Light <roger@atchoo.org>
2018-08-02 14:41:04 +01:00
Roger A. Light
bcf76b9cb6 Remove use of AI_ADDRCONFIG.
Closes #869, #901.

Thanks to Alex Richman.

Signed-off-by: Roger A. Light <roger@atchoo.org>
2018-08-02 01:11:31 +01:00
Roger A. Light
286400abcf Use AF_UNSPEC etc. instead of PF_UNSPEC to comply with POSIX.
Closes #863.

Thanks to denigmus and Patrick TJ McPhee.

Signed-off-by: Roger A. Light <roger@atchoo.org>
2018-08-02 00:27:52 +01:00
Roger A. Light
5e60136449 Merge branch 'develop' 2018-05-03 07:55:45 +01:00