• src/sbbs3/mqtt.c

    From Rob Swindell@VERT to Git commit to main/sbbs/master on Thu Dec 29 14:16:20 2022
    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 Sun Jan 1 20:28:10 2023
    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 Mon Jan 2 15:13:54 2023
    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 Mon Jan 2 18:41:45 2023
    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 Mon Jan 2 18:52:44 2023
    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 Mon Jan 2 19:26:06 2023
    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 Wed Jan 4 16:30:22 2023
    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 Wed Jan 4 19:02:58 2023
    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 Mon Jan 9 15:52:32 2023
    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 Sat Jan 21 13:15:16 2023
    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 Mon Jan 23 19:04:31 2023
    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 Sun Jan 29 20:23:59 2023
    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 Mon Jan 30 16:00:04 2023
    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 Mon Jan 30 17:36:02 2023
    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 Thu Feb 2 18:09:10 2023
    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 Rob Swindell (on Debian Linux)@VERT to Git commit to main/sbbs/master on Thu Mar 2 01:11:32 2023
    https://gitlab.synchro.net/main/sbbs/-/commit/c8cd09935276aa80d384fd14
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Re-publish the server error_count topic in mqtt_startup()

    Fixes a stale non-zero error_count retained topic.

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Windows)@VERT to Git commit to main/sbbs/master on Wed Aug 9 18:28:43 2023
    https://gitlab.synchro.net/main/sbbs/-/commit/bacc2eb16553c883400b3bf5
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    New MQTT topics that the terminal server will subscribe to for node changes

    <nelgin> can I push an intr instruction to a node with mqtt?

    node/#/set/status - set the node status value (to an integer)
    node/#/set/errors - set the node error counter (to an integer, e.g. "0") node/#/set/misc - set the node's miscellaneous attributes/flags value
    (hexadecimal values can be set by including "0x" prefix)

    The message (payload) doesn't matter for the following topics:
    node/#/set/lock - lock a node (no one but sysop can login)
    node/#/set/intr - interrupt a node (disconnect a user)
    node/#/set/down - down a node (not available for connections)
    node/#/set/rerun - rerun a node (reload config upon next connection)

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Windows)@VERT to Git commit to main/sbbs/master on Thu Aug 10 12:30:03 2023
    https://gitlab.synchro.net/main/sbbs/-/commit/e7b1b02ea4167743a8fa6b22
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Allow a msg value of "0" to clear/unset the node/+/set/# topics/flags

    e.g. publishing "0" to node/#/set/intr will clear the node-interrupt flag.
    Any non-zero message value will "set" the flag. Same is true for the
    lock, down, and rerun topics/flags.

    These node attributes (misc) flags could be cleared previously
    by setting the 'misc' topic (e.g. to 0), but since that's not an atomic read/modify/write operation, other set misc flags could be lost clearing flags in that manner.

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Windows)@VERT to Git commit to main/sbbs/master on Thu Aug 10 12:30:03 2023
    https://gitlab.synchro.net/main/sbbs/-/commit/7ae65021a8f4ffe3b47371ad
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Prioritize the node/+/input topics over the node/+/set/+ topics

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rob Swindell (on Windows)@VERT to Git commit to main/sbbs/master on Thu Aug 10 17:45:39 2023
    https://gitlab.synchro.net/main/sbbs/-/commit/64d5e8d6623ea3c09fe8319f
    Modified Files:
    src/sbbs3/mqtt.c
    Log Message:
    Allow triggering timed event or QWKnet call-out by publishing to MQTT topic

    - sbbs/BBSID/exec (publish the timed event's internal code)
    - sbbs/BBSID/call (publish the QWKnet hub's ID)

    The message contents are not case-sensitive.

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Rick Parrish@VERT to Git commit to main/sbbs/master on Sun Aug 20 16:48:10 2023
    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 Sun Aug 20 16:48:10 2023
    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 Wed Aug 30 18:12:59 2023
    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 Sat Sep 9 17:02:11 2023
    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 Tue Sep 12 17:43:27 2023
    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 Tue Sep 12 18:32:39 2023
    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