• exec/broker.js

    From Deucе@1:103/705 to Git commit to main/sbbs/master on Fri Jan 31 20:46:08 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/39cfd9f8907867a961d1a651
    Modified Files:
    exec/broker.js
    Log Message:
    Make broker.js capable of running as a static service.
    --- SBBSecho 3.23-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Deucе@1:103/705 to Git commit to main/sbbs/master on Fri Jan 31 23:57:08 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/c5aaba6c72b31b74e3179f87
    Modified Files:
    exec/broker.js
    Log Message:
    Add some documentation about how the script works.

    As always when writing documentation, fix things that aren't quite
    right... we now schedule nextPacket, but run each packet to
    completion as long as we have all the bytes.
    --- SBBSecho 3.23-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Deucе@1:103/705 to Git commit to main/sbbs/master on Sat Feb 1 12:41:46 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/7907e9a5c6fce570b1f4cf0b
    Modified Files:
    exec/broker.js
    Log Message:
    Call client_add()/client_remove() as appropriate

    For when running as a service.
    --- SBBSecho 3.23-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Deucе@1:103/705 to Git commit to main/sbbs/master on Sun Feb 2 19:09:44 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/94a109ca3acb0db20f314926
    Modified Files:
    exec/broker.js
    Log Message:
    Support uid/pw only auth

    There are now two ways to authenticate with the broker:
    1) TLS PSK with a sysop account, and set the password field at the
    MQTT level to the system password (user field, if present is
    ignored). This is the prefered method as it provides mutual
    authentication and you simply can't steal credentials with MITM.
    2) Synchronet TLS certificate, sysop username and the users password
    followed by a colon, followed by the system password. The server
    authentication will now depend on the appropriate trust chain in
    the client. If using a Let's Encrypt certificate for example,
    you can' securely connect to localhost with this method.

    tools and libraries tend to allow TLS-PSK with password at the MQTT
    level, many GUI tools do not allow TLS-PSK.
    --- SBBSecho 3.23-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Deucе@1:103/705 to Git commit to main/sbbs/master on Wed May 6 23:58:20 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/b524c0aa3fea3ee8a720de34
    Modified Files:
    exec/broker.js
    Log Message:
    broker.js: fix PUBLISH payload framing and subscription ID handling

    serializePayload() was wrapping the payload with encodeBinaryData() or encodeUTF8String(), both of which prepend a 2-byte length prefix. MQTT
    PUBLISH payloads are raw — the length is implicit from the fixed header's remaining length field. This caused all forwarded messages to have garbage bytes prepended.

    dupeForSubscriptions() was collecting topic filter strings (the object
    keys from the subscriber map) instead of the subscription_id from
    each Subscription object. Also skip null/zero subscription IDs rather
    than encoding them as property 11 value 0, which violates the MQTT 5.0
    spec (SubscriptionIdentifier must be in the range 1-268435455).

    Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
    --- SBBSecho 3.37-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Deucе@1:103/705 to Git commit to main/sbbs/master on Thu May 7 02:03:22 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/a57da0ce23000622e8aec090
    Modified Files:
    exec/broker.js
    Log Message:
    broker.js: fix subscriber registration for existing topics

    The Subscription constructor was writing to
    topics[i][this.client_id] (a dangling property on the Topic object
    with this.client_id being undefined) instead of topics[i].subscribers[conn.client_id]. This meant subscribers were
    never registered in the .subscribers map for topics that already
    existed at subscribe time. Retained messages still worked because
    they were sent directly from the constructor, but live publishes
    never found the subscriber.

    Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
    --- SBBSecho 3.37-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Deucе@1:103/705 to Git commit to main/sbbs/master on Thu May 7 11:11:34 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/7b9c37f55f2dffb461610ac2
    Modified Files:
    exec/broker.js
    Log Message:
    broker.js: fix memory leaks from subscription references

    Subscription.remove() used topics[i][this.client_id] instead of topics[i].subscribers[this.conn.client_id] — the same property-path
    bug fixed in the constructor (a8a6bfebe). Subscriptions were never
    actually removed from Topic subscriber maps, keeping Connection
    objects alive through circular references indefinitely.

    Added removeAllSubscriptions() method and call it from:
    - tearDown() when session_expiry is 0 (no session persistence)
    - expireSession() before deleting from broker.disconnected
    - handleCONNECT when clean_start replaces an old connection

    Also clean up empty subscriber entries from topic maps after the
    last subscription for a client is removed.

    Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
    --- SBBSecho 3.37-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)