Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
af1714db08
commit
910bee899a
7 files changed
+351
-11
No files matched your search
@@ -94,7 +94,8 @@ void FairnessLimiter::refillSenderLow() {
|
||||
}
|
||||
}
|
||||
|
||||
bool FairnessLimiter::allowPacket(const mesh::Packet* pkt) {
|
||||
bool FairnessLimiter::allowPacket(const mesh::Packet* pkt, uint32_t now_ms) {
|
||||
last_shed = FAIR_SHED_NONE;
|
||||
// Don't limit versions we don't understand.
|
||||
if (pkt->getPayloadVer() != PAYLOAD_VER_1) {
|
||||
return true;
|
||||
@@ -110,11 +111,26 @@ bool FairnessLimiter::allowPacket(const mesh::Packet* pkt) {
|
||||
uint8_t hash[1] = { 0x00 };
|
||||
auto type = pkt->getPayloadType();
|
||||
|
||||
// Per-origin advert window -- flood adverts only, ahead of the buckets. The
|
||||
// payload starts with the origin's public key.
|
||||
if (type == PAYLOAD_TYPE_ADVERT && pkt->isRouteFlood() && pkt->payload_len >= ADVERT_WINDOW_KEY_LEN
|
||||
&& !advert_window.allow(pkt->payload, now_ms)) {
|
||||
denied_window++;
|
||||
MESH_DEBUG_PRINTLN("FAIR, advert window origin=%02X%02X%02X%02X dry=%u", (uint32_t)pkt->payload[0],
|
||||
(uint32_t)pkt->payload[1], (uint32_t)pkt->payload[2], (uint32_t)pkt->payload[3],
|
||||
(uint32_t)dry_run);
|
||||
return shed(FAIR_SHED_WINDOW);
|
||||
}
|
||||
|
||||
if (!buckets_enabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Packets by group channel hash
|
||||
if (type == PAYLOAD_TYPE_GRP_TXT || type == PAYLOAD_TYPE_GRP_DATA) {
|
||||
if (pkt->payload_len < 1) return true; // malformed, not ours to judge
|
||||
hash[0] = pkt->payload[0];
|
||||
return takeGroup(hash);
|
||||
return takeGroup(hash) || shed(FAIR_SHED_GROUP);
|
||||
}
|
||||
|
||||
// Packets with a plaintext 1-byte src hash at payload[1] (see Mesh.cpp,
|
||||
@@ -123,13 +139,13 @@ bool FairnessLimiter::allowPacket(const mesh::Packet* pkt) {
|
||||
type == PAYLOAD_TYPE_TXT_MSG || type == PAYLOAD_TYPE_ANON_REQ) {
|
||||
if (pkt->payload_len < 2) return true; // malformed, not ours to judge
|
||||
hash[0] = pkt->payload[1];
|
||||
return takeSenderNormal(hash);
|
||||
return takeSenderNormal(hash) || shed(FAIR_SHED_SENDER);
|
||||
}
|
||||
|
||||
if (type == PAYLOAD_TYPE_ADVERT) {
|
||||
if (pkt->payload_len < 1) return true; // malformed, not ours to judge
|
||||
hash[0] = pkt->payload[0]; // first byte of sender pub key
|
||||
return takeSenderLow(hash);
|
||||
return takeSenderLow(hash) || shed(FAIR_SHED_ADVERT);
|
||||
}
|
||||
|
||||
// Not classified (allowed through):
|
||||
|
||||
Reference in new issue
Block a user