simple_repeater: filter hash throttle + opt-in message age limit (tth #3)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e3029de6e4
commit
548b96d15c
8 files changed
+370
-29
No files matched your search
@@ -76,6 +76,7 @@ void MyMesh::channelsInit() {
|
||||
memset(known_channel_flags, 0, sizeof(known_channel_flags));
|
||||
#ifdef FILTER_CHANNEL_PSKS
|
||||
filter_dropped = 0;
|
||||
filter_age_dropped = 0;
|
||||
{
|
||||
// comma-separated hex PSKs
|
||||
const char* seg = FILTER_CHANNEL_PSKS;
|
||||
@@ -110,7 +111,6 @@ void MyMesh::onGroupDataRecv(mesh::Packet* packet, uint8_t type, const mesh::Gro
|
||||
uint8_t* data, size_t len) {
|
||||
if (type != PAYLOAD_TYPE_GRP_TXT) return; // GRP_DATA (telemetry etc.) is not ours
|
||||
if (len < 5) return;
|
||||
if ((data[4] >> 2) != 0) return; // only plain text, per BaseChatMesh.cpp:374
|
||||
|
||||
// which registry entry decrypted this? (the caller passes a COPY, not our slot)
|
||||
int chan_idx = -1;
|
||||
@@ -122,6 +122,25 @@ void MyMesh::onGroupDataRecv(mesh::Packet* packet, uint8_t type, const mesh::Gro
|
||||
}
|
||||
if (chan_idx < 0) return;
|
||||
|
||||
#ifdef FILTER_CHANNEL_PSKS
|
||||
// `filter age` (ChannelFilter.h): any group text, not only plain ones -- the
|
||||
// timestamp leads every GRP_TXT. Same veto as the deny list below.
|
||||
if (known_channel_flags[chan_idx] & CHAN_FLAG_FILTER) {
|
||||
uint32_t sender_ts;
|
||||
memcpy(&sender_ts, data, 4);
|
||||
if (msgAgeCheck(sender_ts, getRTCClock()->getCurrentTime(), _prefs.filter_age_min) == MSG_AGE_OLD) {
|
||||
filter_age_dropped++;
|
||||
if (!_prefs.filter_dry_run) {
|
||||
packet->markDoNotRetransmit();
|
||||
MESH_DEBUG_PRINTLN("filter: drop fwd, zprava starsi nez %u min", _prefs.filter_age_min);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((data[4] >> 2) != 0) return; // only plain text, per BaseChatMesh.cpp:374
|
||||
|
||||
// Work on a bounded copy. Upstream NUL-terminates the caller's buffer in place
|
||||
// (data[len] = 0), which is fine there but relies on headroom this function
|
||||
// cannot verify -- and every other parse in this fork is bounds-checked.
|
||||
@@ -152,9 +171,11 @@ void MyMesh::onChannelText(mesh::Packet* packet, int chan_idx, const char* sende
|
||||
// (Mesh.cpp:357). Local processing already happened (rxlog/pktfeed capture
|
||||
// on receive), so the observer evidence trail is intact; the node just
|
||||
// refuses to re-air it. And the bot must not answer a denied sender either.
|
||||
packet->markDoNotRetransmit();
|
||||
filter_dropped++;
|
||||
MESH_DEBUG_PRINTLN("filter: drop fwd, sender na deny listu");
|
||||
if (!_prefs.filter_dry_run) { // dry-run: counted, but forwarded
|
||||
packet->markDoNotRetransmit();
|
||||
MESH_DEBUG_PRINTLN("filter: drop fwd, sender na deny listu");
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user