https://gitlab.synchro.net/main/sbbs/-/commit/128c1b6d5e4214e5884ace03
Added Files:
src/sbbs3/mqtt_broker.cpp mqtt_broker.h mqtt_broker_glue.cpp mqtt_protocol.cpp mqtt_protocol.h mqtt_topic.cpp mqtt_topic.h
Modified Files:
src/sbbs3/mqtt.c mqtt.h objects.mk src/sbbs3/scfg/scfgnet.c src/sbbs3/scfgdefs.h scfglib1.c scfgsave.c
Log Message:
mqtt: add optional experimental internal MQTT 5.0 broker
C++ implementation of an MQTT 5.0 broker that runs as an in-process
service, eliminating the libmosquitto dependency and solving the
broker.js startup ordering problem.
When InternalBroker=true in [MQTT], mqtt_startup() launches a broker
thread and registers each server as a local client. Publish and
subscribe calls go directly to the broker's routing engine without
network overhead. External clients (qtmonitor) connect via TLS-PSK
using the same Cryptlib infrastructure as other Synchronet servers.
Architecture:
- mqtt_protocol.h/.cpp: MQTT 5.0 wire codec (VBI, UTF-8, properties,
all packet types). Three-tier data model with shared_ptr messages.
- mqtt_topic.h/.cpp: trie-based topic tree with +/# wildcard matching,
retained message store with shared_ptr ownership and expiry.
- mqtt_broker.h/.cpp: broker thread with select() event loop, local
client interface (mutex-protected), network client handling, TLS-PSK
via Cryptlib, PSK table from sysop user list, session management,
QoS 0/1/2 state machines, will messages with delay, session expiry,
clean start/resume, keep-alive timeout.
- mqtt_broker_glue.cpp: C linkage bridge between mqtt.c and the C++
broker. Broker logs via startup->lputs for console and $SYS/broker/
topics for MQTT. Recursion guard prevents log→publish→log loops.
- mqtt.c: dual-path logic in all mqtt_pub_*/mqtt_subscribe functions.
mqtt_dispatch_message shared between mosquitto and internal broker.
- scfgdefs.h/scfglib1.c/scfgsave.c: InternalBroker config field.
- scfg/scfgnet.c: UI toggle, hides external broker settings when
internal broker is enabled.
$SYS/broker/version retained message set at startup with full version
string (broker_ver()). $SYS/broker/log/{level} for broker log messages.
Co-Authored-By: Claude Opus 4.6 (1M context) <
noreply@anthropic.com>
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net