Merge jayReflector additions: per-trunk filters, node-list, PTY mute

Ports DJ1JAY / FM-Funknetz' jayReflector features (https://github.com/dj1jay/jayReflector)
into GeuReflector while keeping the in-process MqttPublisher.

Per-trunk config (TrunkLink): BLACKLIST_TGS, ALLOW_TGS, TG_MAP (with
explicit-route bypass of the prefix routing check), PEER_ID. New helpers
TgFilter.h provide exact / "24*" / "10-20" syntax shared across keys.

Wire protocol (additive, backward compatible — older peers ignore unknown
types): MsgTrunkNodeList (type 121) carries callsign + current_tg + optional
lat/lon/QTH; MsgTrunkFilter (type 122) reserved for satellite TG filters.

Reflector emits debounced (500 ms) MsgTrunkNodeList to all trunk peers on
local client login/logout/TG change. Inbound lists are republished via MQTT
under nodes/<peer_id>; the local list under nodes/local. New MQTT_NAME global
key inserts a path component so several reflectors can share a TOPIC_PREFIX.

PTY commands (Reflector): TRUNK MUTE|UNMUTE <section> <callsign>,
TRUNK RELOAD [<section>] re-reads BLACKLIST_TGS/ALLOW_TGS/TG_MAP without
restart, TRUNK STATUS [<section>] dumps a one-line summary per link.
Mute is applied on the inbound audio path.

Tests: 8 new integration tests (19-27) plus a TEST_PEER_FILTER fixture in
topology.py. Tests cover PEER_ID hello, BLACKLIST/ALLOW/TG_MAP semantics,
PTY MUTE/RELOAD/STATUS via docker exec, MQTT_NAME topic namespacing, and
node-list emission. Total now 27 tests.

Docs: docs/JAY-additions.md credits DJ1JAY / FM-Funknetz and lists every
merged feature with file pointers and the filter-evaluation order.
README.md links it. svxreflector.conf.in documents every new key.

Bumps SVXREFLECTOR to 1.3.99.13+trunk.
This commit is contained in:
Audric committed 2026-04-14 23:48:03 +02:00
1 parent 6f5138cd11
commit 5708e2d0e8
17 files changed
+1287 -58

No files matched your search

+54
View File
@@ -89,6 +89,16 @@ bool MqttPublisher::initialize(void)
m_topic_prefix.pop_back();
}
// Optional MQTT_NAME — appended as a path component so each reflector
// publishes under a unique sub-tree (TOPIC_PREFIX/MQTT_NAME/...).
string mqtt_name;
if (m_cfg.getValue("MQTT", "MQTT_NAME", mqtt_name) && !mqtt_name.empty())
{
while (!mqtt_name.empty() && mqtt_name.back() == '/') mqtt_name.pop_back();
while (!mqtt_name.empty() && mqtt_name.front() == '/') mqtt_name.erase(0, 1);
if (!mqtt_name.empty()) m_topic_prefix += "/" + mqtt_name;
}
// Read optional TLS config
string tls_str;
if (m_cfg.getValue("MQTT", "TLS_ENABLED", tls_str) && tls_str == "1")
@@ -283,3 +293,47 @@ void MqttPublisher::publishFullStatus(const Json::Value& status)
wb["indentation"] = "";
publish("status", Json::writeString(wb, status), true);
}
static Json::Value nodeListToJson(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes)
{
Json::Value arr(Json::arrayValue);
for (const auto& n : nodes)
{
Json::Value e;
e["callsign"] = n.callsign;
e["tg"] = n.tg;
if (n.lat != 0.0f || n.lon != 0.0f)
{
e["lat"] = n.lat;
e["lon"] = n.lon;
}
if (!n.qth_name.empty()) e["qth_name"] = n.qth_name;
arr.append(e);
}
Json::Value root;
root["nodes"] = arr;
root["timestamp"] = (Json::Int64)time(nullptr);
return root;
}
void MqttPublisher::publishLocalNodes(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes)
{
Json::StreamWriterBuilder wb;
wb["indentation"] = "";
publish("nodes/local",
Json::writeString(wb, nodeListToJson(nodes)), true);
}
void MqttPublisher::publishPeerNodes(const std::string& peer_id,
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes)
{
Json::StreamWriterBuilder wb;
wb["indentation"] = "";
publish("nodes/" + peer_id,
Json::writeString(wb, nodeListToJson(nodes)), true);
}