Skip to content
Snippets Groups Projects
  1. Feb 11, 2024
  2. Jan 20, 2024
    • Rob Swindell's avatar
      The great BOOL->bool conversion in xpdev · 118984e9
      Rob Swindell authored
      Still using BOOL where we need Win32 API compatibility.
      Using JSBool instead of BOOL or bool where it matters.
      Changed most relevant TRUE/FALSE to true/false too (though it's not as critical).
      
      You shouldn't need to #include <stdbool.h> anywhere now - gen_defs.h should do that automatically/correctly based on the language/version/tool. In C23, stdbool.h isn't even needed for bool/true/false definitions (they're keywords), so we don't bother including stdbool.h in that case.
      Microsoft didn't define __STDC_VERSION__ in their older tool chains (even though they were C99 compatible and had stdbool.h), so we use a _MSC_VER check to know that there's a stdbool.h we should use in that case.
      
      For other/old compilers (e.g. Borland C) we #define bool/true/false following the pattern of stdbool.h (doesn't use a typedef).
      
      I didn't convert UIFC yet.
      
      This addresses issue #698
      118984e9
  3. Jan 13, 2024
    • Rob Swindell's avatar
      Check for shutdown and recycle semaphores even while clients are connected · 75c5c9e5
      Rob Swindell authored
      We have checks/loops/timeouts waiting for active clients to disconnect and
      child thread threads to terminate whenever shutting down or recycling already,
      so this should be safe. This pretty simple change fixes issue #236 (can't
      terminate server under heavy load).
      
      Also as part of this commit, introduced the ability to "pause" a server
      (prevent it from accepting new connections) with the ctrl/pause semaphore
      file or via the MQTT server/pause (and resume) topics. This feature is useful
      when debugging server issues where you don't necessarily want to fully
      shutdown/terminate the server, but don't want any new connections to be
      accepted (the listen backlog will fill up with incoming connections though).
      Unlike a server shutdown, a server pause can be "undone" via MQTT (by
      publishing a message to the "resume" topic).
      
      The "pause" semaphore file is just an "existence" semaphore file - its
      date/time stamp doesn't matter. If the file exists, the server will enter
      a paused state (and periodically log messages to that fact) until the semfile
      is deleted.
      
      This server pause feature is not the same as the pause button function in
      sbbsctrl, which just pauses server log output.
      75c5c9e5
  4. Dec 29, 2023
  5. Dec 19, 2023
  6. Dec 14, 2023
    • Rob Swindell's avatar
      Change the MQTT broker-connect ... successful log message to DEBUG-level · 0a49e951
      Rob Swindell authored
      Since we're logging at INFO level when the connect is attempted, we can assume
      success when we start logging additional init messages.
      0a49e951
    • Rob Swindell's avatar
      Fix crash after failing to connect to MQTT broker · c66f0887
      Rob Swindell authored
      We need to call mqtt_shutdown() instead of mqtt_close() to have the mosquitto
      (loop) thread stopped.
      
      Upon connect failure, call the mqtt_shutdown() *before* calling lprintf->lputs,
      which would eventually try to MQTT-publish the log message.
      
      The call to mqtt_connect() can block for a while, so raise the log severity
      of the "connecting to broker" message from DEBUG to INFO. Otherwise, a bad
      MQTT broker address or port would make the servers just appear to hang during
      initialization, for no reason.
      c66f0887
  7. Sep 13, 2023
    • Rob Swindell's avatar
      Fix log topic publishing when using MQTT v3 · 6e35116b
      Rob Swindell authored
      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.
      6e35116b
    • Rob Swindell's avatar
      Always publish log messages to both .../logs and .../logs/<level> topics · cb58a718
      Rob Swindell authored
      ... 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?
      cb58a718
  8. Sep 09, 2023
  9. Aug 31, 2023
    • Rob Swindell's avatar
      Remove MQTT message publishing from mqtt_connect_callback() · b4aaddb8
      Rob Swindell authored
      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.
      b4aaddb8
  10. Aug 20, 2023
  11. Aug 11, 2023
  12. Aug 10, 2023
    • Rob Swindell's avatar
    • Rob Swindell's avatar
      Allow a msg value of "0" to clear/unset the node/+/set/# topics/flags · 9d897b88
      Rob Swindell authored
      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.
      9d897b88
    • Rob Swindell's avatar
      New MQTT topics that the terminal server will subscribe to for node changes · cbf4f61f
      Rob Swindell authored
      <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)
      cbf4f61f
  13. Mar 02, 2023
  14. Feb 16, 2023
  15. Feb 03, 2023
  16. Jan 31, 2023
  17. Jan 30, 2023
    • Rob Swindell's avatar
    • Rob Swindell's avatar
    • Rob Swindell's avatar
      The 3rd great MQTT data scheme update (sorry Nelgin) · e94281e6
      Rob Swindell authored
      - Most published messages (besides log entries) have a timestamp (in ISO8601 format) prepended and tab-separated
      - The order and number of elements in client messages (list and activities) has been updated, now includes user number
      - Server client lists are now published to .../SERVER/client/list
      - Server client activities (connect, disconnect, update) are now published to .../SERVER/client/action/#
      - Server client count is now published to .../SERVER/client (with the maximum client count, if applicable)
      - Server states are now just represented by name (e.g. initializing, ready, stopping, stopped) and not number
      - BBS errors are logged to sbbs/BBS/action/error/LEVEL (where LEVEL is the log level name, e.g. "critical" or "error')
      - All server hack-attempts, SPAM attempts, logins, logouts, uploads, downloads, are published to sbbs/BBS/action/ACTION/*
      - Chat pages are published to sbbs/BBS/action/page/node/#
      - New users (on the terminal server) are published to sbbs/BBS/action/newuser
      - Posted messages and executed external programs (on the terminal server) are published to sbbs/BBS/action/ACTION/CODE topic
      - The event thread started/stopped status is published to .../SERVER/event
      
      Yeah, the wiki will get updated soon to reflect/document all these changes
      e94281e6
  18. Jan 24, 2023
  19. Jan 21, 2023
    • Rob Swindell's avatar
      Refactor mqtt_client_on() · e3bb1aee
      Rob Swindell authored
      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.
      e3bb1aee
  20. Jan 09, 2023
    • Rob Swindell's avatar
      Log to log/# topic only when MQTT protocol version is < 5 · 8383af2c
      Rob Swindell authored
      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.
      8383af2c
  21. Jan 05, 2023
  22. Jan 04, 2023
    • Rob Swindell's avatar
      d2320849
    • Rob Swindell's avatar
      Publish some topics directly to topic levels · 066d6a8d
      Rob Swindell authored
      <server>/state is now published directly to the <sever> topic level (the "state" topic goes away).
      
      Moved <bbs-id>/node# topics to <bbs-id>/nodes/# (allows better wild-card subscription per MQTT standards).
      Publishing total node count to <bbs-id>/nodes rather than <bbs-id>/node_count
      
      Introduced "publish verbosity" control (defaults to "High") - if you want nice human readable (and sometimes redundant) topic messages, leave this set to "High". To reduce traffic, set to "Low". It's expected that purpose-built Synchronet/MQTT clients should work equally-well with either setting, but when using generic MQTT clients/browser, "high" verbosity is nice. The human-readable node status is only published when "high" verbosity is enabled.
      
      Publishing the BBS name to the <bbs-id> topic, the instance hostname (as configured in sbbs.ini) to the <host> topic. Makes the hierarchy much more clear when using an MQTT browser like MQTT Explorer.
      066d6a8d
    • Rob Swindell's avatar
      Public hack, spam, and error logs at the MQTT BBS-ID topic depth · 7ce24b48
      Rob Swindell authored
      This is more consistent with how these events are logged in a BBS-common log file in data/*.log.
      
      This change also restores the server abbreviation to the error log entries that used to be there until recently.
      7ce24b48
    • Rob Swindell's avatar
      Over-overhaul of MQTT support · 916fdacb
      Rob Swindell authored
      Each Synchronet server is now its own MQTT client. This means there's no
      longer any MQTT logic in the Synchronet "hosts" (e.g. sbbscon.c, ctrl/*.cpp)
      and none needed for SBBS NT services (they'll "just work" with MQTT).
      
      This also means that just about everything (except for nodes, spam and hack)
      is now published per-server (in the sbbs/BBS-ID/hostname/server/ topic branch)
      and if you want aggregated totals or client lists, you'll have to do that in
      your own MQTT client or dashboard.
      
      I also removed the publishing of thread_count and socket_count topics as
      they weren't universally supported across all servers and are of questionable
      value. They can be added back later if determined to be useful.
      916fdacb
  23. Jan 03, 2023
  24. Jan 02, 2023
Loading