• src/sbbs3/mqtt.c

    From Rob Swindell@VERT to Git commit to main/sbbs/master on Thursday, December 29, 2022 14:16:20
    https://gitlab.synchro.net/main/sbbs/-/commit/5eb8d99a03ecf04c8ee948a9
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Add TLS support

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Sunday, January 01, 2023 20:28:10
    https://gitlab.synchro.net/main/sbbs/-/commit/f2f5e8202a667a592d82cf9b
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Resolve GCC warning: enumeration value `SERVER_COUNT' not handled in switch

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Monday, January 02, 2023 15:13:54
    https://gitlab.synchro.net/main/sbbs/-/commit/1e97f8b666303a4b89d97721
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Resolve GCC warning about function prototype mismatch

    warning: passing argument 2 of `mosquitto_message_callback_set' from incompatible pointer type

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Monday, January 02, 2023 18:41:45
    https://gitlab.synchro.net/main/sbbs/-/commit/c69279b69b7ec59c469ae4ad
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Don't call mosquttio (MQTT lib) functions when disabled

    Should fix the new crash issues reported by Retros via #synchronet on irc.synchro.net

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Monday, January 02, 2023 18:52:44
    https://gitlab.synchro.net/main/sbbs/-/commit/fc89e9418884bbc9e8314b26
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    More support for running (without crashing) with MQTT disabled

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Monday, January 02, 2023 19:26:06
    https://gitlab.synchro.net/main/sbbs/-/commit/480a849a677a082f63523b10
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Fix total-disablement of MQTT support in previous crash-fix-commit

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Wednesday, January 04, 2023 16:30:22
    https://gitlab.synchro.net/main/sbbs/-/commit/7ef33bc8bdab0350f0fd32f5
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Fix crash in mqtt_errormsg() when MQTT is disabled

    Should fix the segfault reported by NeoArata_ in #synchronet

    Also include singular/plural error/s in server status messages.

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Wednesday, January 04, 2023 19:02:58
    https://gitlab.synchro.net/main/sbbs/-/commit/9c6c3b4cb913ff4591c443e3
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Prepend "server/" before server topics

    This solves the problem of subscribing to "sbbs/+/+/+" and getting node status in addition to server status (very different formatted messages).

    Also include a change for the singular-again "node" topic

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Monday, January 09, 2023 15:52:32
    https://gitlab.synchro.net/main/sbbs/-/commit/eb89e5ad130e37ab55c3cca2
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Log to log/# topic only when MQTT protocol version is < 5

    When MQTT protocol version is >= 5, just log to the */log topic
    (the level is a property).

    This means you can't subscribe only to specific log levels when using MQTT v5 so I may re-think this, but I don't want to keep publishing every single log message twice.

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Saturday, January 21, 2023 13:15:16
    https://gitlab.synchro.net/main/sbbs/-/commit/f3ec8613ad68bbfa38070414
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Refactor mqtt_client_on()

    This function has been causing somewhat rare crashes (e.g. one per week on a very active system with MQTT enabled) on both Windows and Linux (see issue #495). The root-cause is still unclear (possible heap corruption?). This function needed more robustification anyway (see previous TODO comment), so I'm refactoring here to no longer use strListAppendFormat, which uses vasprintf (the function where the rare crash was occurring) and instead just use snprintf and strListPush. The total client_list that's published (as a single string/message) is now dynamically allocated (this was the point of the previous TODO comment). This may not actually fix the issue if there's a heap corruption occurring somewhere else in this function or the call-chain that's reaching here (usually from the web server).

    Another change to mqtt_client_on(): don't incremented the server's 'served' counter until client disconnects (this is a past-tense statistic).

    Also:
    - mqtt_pub_strval() can now accept a null 'str' argument which is effectively the same as mqtt_pub_noval(), so the pub_noval() function is now just a thin wrapper around pub_strval().

    - mqtt_startup() now clears the client_list topic and sets the client_count topic to 0.

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Monday, January 23, 2023 19:04:31
    https://gitlab.synchro.net/main/sbbs/-/commit/f77f1984938bd8ec08f670a4
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Fix crash in mqtt_startup() when configured broker isn't reachable

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Sunday, January 29, 2023 20:23:59
    https://gitlab.synchro.net/main/sbbs/-/commit/54aec8bf75ff9d8bca6c25f1
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Fix accidental static storage for login/logout functions

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Monday, January 30, 2023 16:00:04
    https://gitlab.synchro.net/main/sbbs/-/commit/ae705bb6896a333130d2c4c2
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Lowercase the protocol name in action/login and logout topics

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Monday, January 30, 2023 17:36:02
    https://gitlab.synchro.net/main/sbbs/-/commit/02a3031aae2584171cde4253
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Convert spaces to underscores in MQTT topics

    e.g. "action/hack/smtp login" -> "smtp_login", best practices and all.

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Windows)@VERT to Git commit to main/sbbs/master on Thursday, February 02, 2023 18:09:10
    https://gitlab.synchro.net/main/sbbs/-/commit/56b07155c5a29f173f3071cf
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Don't include number of user's file uploads in action/[upload|download] msgs

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rick Parrish@VERT to Git commit to main/sbbs/master on Sunday, August 20, 2023 16:48:10
    https://gitlab.synchro.net/main/sbbs/-/commit/42dc70557ff497584096de22
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Add a connect callback handler.

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell@VERT to Git commit to main/sbbs/master on Sunday, August 20, 2023 16:48:10
    https://gitlab.synchro.net/main/sbbs/-/commit/49e007b73339cd3c6300959c
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Merge branch 'Ree/mqtt-connect-callback' into 'master'

    Add a connect callback handler.

    See merge request main/sbbs!320

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Windows)@VERT to Git commit to main/sbbs/master on Wednesday, August 30, 2023 18:12:59
    https://gitlab.synchro.net/main/sbbs/-/commit/622ffe3dceb089de77078f4d
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Remove MQTT message publishing from mqtt_connect_callback()

    A follow-up to commit 81d4575e

    Although I was not able to successfully reproduce the problem that Ree
    reported with his commit (even when changing the SCFG->Networks->MQTT->Publish QOS to 1: At least once) on Windows, I do see how this problem could theoretically happen. And like Ree said in the follow-up comment on the MR "maybe these two lines should have stayed in mqtt_startup", they don't really belong in the connection callback.

    The "client" topics only needs to be cleared upon startup or recycle (by publishing a null message) and it would be bad to clear these topics whenever the broker was reconnected (the server's clients didn't magically disconnect). So these "client" topic-clearing publishes are now only done during startup (again).

    The "recycle" topics don't really need to be published to here at all. I
    think I only did this for cases where someone published a non-null message to the topic and its stale message would remain afterward, appearing in MQTT browsers (like MQTT explorer) long after the server had recycled. The real solution to this cosmetic issue is to only publish null (0-length) messages to the "recycle" topics in the first place.

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Windows)@VERT to Git commit to main/sbbs/master on Saturday, September 09, 2023 17:02:11
    https://gitlab.synchro.net/main/sbbs/-/commit/789c71cd62692820df80c24d
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Add ability to send a node message via MQTT (to sbbs/+/node/+/msg topic)

    The node message should be terminated with a newline character.

    e.g.
    $ echo "Hey you" | mosquitto_pub -s -t sbbs/VERT/node/1/msg

    I'm considering the ability to send user message (telegrams) via MQTT too.

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Windows)@VERT to Git commit to main/sbbs/master on Tuesday, September 12, 2023 17:43:27
    https://gitlab.synchro.net/main/sbbs/-/commit/207ed413b77f6f8025b130d5
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Always publish log messages to both .../logs and .../logs/<level> topics

    ... regardless of the configured MQTT protocol version (v5 or v3.x).

    Also include an MQTT v5 user-property ("time") with the message's origination time/date stamp in ISO-8601 format in all log messages (to both topics).

    This will at least double the amount of MQTT log traffic to the broker. When MQTT v5 is used, the additional user-properties will increase it even a little more.

    Is this what you were suggesting Ree?

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Windows)@VERT to Git commit to main/sbbs/master on Tuesday, September 12, 2023 18:32:39
    https://gitlab.synchro.net/main/sbbs/-/commit/5cb96ad3b35e851222452b86
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Fix log topic publishing when using MQTT v3

    Apparently if you call mosquitto_publish_v5() with a non-NULL properties pointer, it'll only publish via protocol v5 and doesn't work if you're using protocol v3 connection.

    Thanks Ree.

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net