• exec/broker.js

    From Deuc¿@VERT to Git commit to main/sbbs/master on Fri Jan 31 12:36:17 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/93915f2047473b600a068628
    Added Files:
    exec/broker.js
    Log Message:
    Add a pure-JS MQTT broker

    This is not nearly ready for full-time yet, but it seems to mostly
    limp along fine... there's some issues with the callbacks and such,
    and the TLS support isn't currently usable by Synchronet.

    Worth committing though.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/master on Fri Jan 31 12:50:57 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/dd197ac84a0b6a25ab8228c2
    Modified Files:
    exec/broker.js
    Log Message:
    After receiving all packet data, receive the next packet.

    This appears to be why it was hanging. :D

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/master on Fri Jan 31 13:05:31 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/dfd5de5ebbc84a6b1c8ba240
    Modified Files:
    exec/broker.js
    Log Message:
    Log who packets are going to/from, fix potential leak in previous commit

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/master on Fri Jan 31 14:26:49 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/a7077e521bce216f23b7d19e
    Modified Files:
    exec/broker.js
    Log Message:
    More fixes... it seems broadly usefulish now

    - Increment bytes required for every extra VBI byte we learn about
    - If sock is null, don't look at sock.connection
    - Set sock to null after close
    - Don't read from sock unless we need some bytes
    - If we already have some bytes, parse them

    There's a couple hacks in here that should be refactored though.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/master on Fri Jan 31 14:27:49 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/0f70b2c035d9bc39794571ea
    Modified Files:
    exec/broker.js
    Log Message:
    Set sock to null *after* closing it.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/master on Fri Jan 31 14:28:34 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/a0b9a6db486a0be43e52520f
    Modified Files:
    exec/broker.js
    Log Message:
    ... But only if it's not null already.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/master on Fri Jan 31 14:59:34 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/86e9f99ac0330efea3bcf3ed
    Modified Files:
    exec/broker.js
    Log Message:
    Do some of that refactor

    Add a nextPacket() method that will get the next packet
    Add a Connection.parseBytes() method to consume the rx_buf
    Simplify Packet.newBytes() to only do socket recv()
    Clear RX buffer when closing socket

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/master on Fri Jan 31 16:11:17 2025
    https://gitlab.synchro.net/main/sbbs/-/commit/50dbbce372274f5830d91620
    Modified Files:
    exec/broker.js
    Log Message:
    Fix inverted comparisons in SUB and UNSUB messages

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT 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.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/master on Fri Jan 31 23:57:09 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.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT 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.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/master on Sun Feb 2 19:09:45 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.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¨@VERT 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>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¿@VERT to Git commit to main/sbbs/master on Thu May 7 02:03:23 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>

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuc¨@VERT 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>

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