feat(reflector): apply TG filter at fanout for events without inline TG

Disconnect, rx, and status messages don't carry a TG, so the sender
looks up the originating client's current TG via currentClientTg()
and tests it against each SatelliteLink's filter before emitting.
Connect events already have inline TG filtering inside
SatelliteLink::sendClientConnected.

If the lookup returns 0 (e.g. the client has just disconnected when
the fanout fires), default-allow rather than block — preserves the
event flow when the local client state is racing.

SatelliteClient and TwinLink have no filter today — they receive
unfiltered.
This commit is contained in:
Audric committed 2026-04-28 20:57:54 +02:00
1 parent 24a4bc98f9
commit b5b54cb8d6
3 files changed
+33 -4

No files matched your search

+23 -3
View File
@@ -3144,6 +3144,20 @@ void Reflector::publishClientStatus(ReflectorClient* client)
} /* Reflector::publishClientStatus */
uint32_t Reflector::currentClientTg(const std::string& callsign) const
{
for (const auto& it : m_client_con_map)
{
ReflectorClient* c = it.second;
if (c != nullptr && c->callsign() == callsign)
{
return c->currentTG();
}
}
return 0;
} /* Reflector::currentClientTg */
void Reflector::fanoutClientConnected(const std::string& callsign,
uint32_t tg,
const std::string& ip)
@@ -3168,9 +3182,11 @@ void Reflector::fanoutClientConnected(const std::string& callsign,
void Reflector::fanoutClientDisconnected(const std::string& callsign)
{
uint32_t tg = currentClientTg(callsign);
for (auto& kv : m_satellite_con_map)
{
if (kv.second != nullptr)
if (kv.second != nullptr &&
(tg == 0 || kv.second->filterPassesTg(tg)))
{
kv.second->sendClientDisconnected(callsign);
}
@@ -3192,9 +3208,11 @@ void Reflector::fanoutClientRx(const std::string& callsign,
Json::StreamWriterBuilder wb;
wb["indentation"] = "";
std::string s = Json::writeString(wb, rx_json);
uint32_t tg = currentClientTg(callsign);
for (auto& kv : m_satellite_con_map)
{
if (kv.second != nullptr)
if (kv.second != nullptr &&
(tg == 0 || kv.second->filterPassesTg(tg)))
{
kv.second->sendClientRx(callsign, s);
}
@@ -3216,9 +3234,11 @@ void Reflector::fanoutClientStatus(const std::string& callsign,
Json::StreamWriterBuilder wb;
wb["indentation"] = "";
std::string s = Json::writeString(wb, status_json);
uint32_t tg = currentClientTg(callsign);
for (auto& kv : m_satellite_con_map)
{
if (kv.second != nullptr)
if (kv.second != nullptr &&
(tg == 0 || kv.second->filterPassesTg(tg)))
{
kv.second->sendClientStatus(callsign, s);
}