fairness: limity podle reálného provozu, 00/ff odesílatelé nejsou rezervovaní

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-10-06 22:33:05 +02:00
1 parent f79ea79a13
commit 4cc830e70b
3 files changed
+33 -36

No files matched your search

+20 -9
View File
@@ -19,8 +19,10 @@
#include <Packet.h>
#include <stdint.h>
// For senders 0x00 and 0xFF are reserved (Identity.cpp rejects them as path
// hash prefixes). Group channel hashes are pure sha256, so no reserved values.
// Sender hashes 0x00 and 0xFF are NOT special here: repeaters, room servers
// and sensors re-roll such identities, but companions do not, so real users
// send with them (~1 in 128). Denying them always (as the original branch did)
// dropped every flood DM/PATH/REQ of those users.
// Note: mask, cap and refill interval are highly connected parameters.
#define GROUP_MASK 0b00011111 // 5-bit address
#define SENDER_NORMAL_MASK 0b00111111 // 6-bit address
@@ -28,25 +30,34 @@
// Refill intervals: ONE token per bucket per interval. Steady-state rate is
// 1/interval, cap bounds the burst. Overridable per env from platformio ini.
//
// Sized from real traffic (6 Sep - 6 Oct 2026: 207k floods heard on the CZ
// mesh at one-site, replayed through this limiter). The zero-loss frontier
// over those 30 days was group 60 s/cap 60, sender 10 s/cap 60, advert 600 s/
// cap 12; the defaults below keep about 2x headroom on top. The busiest
// legitimate channel runs ~26 msg/h around the clock, so the limiter is a net
// for runaway floods (the bot that prompted it sent ~330 msg/h), not a quota.
// The earlier defaults (cap 20/30/4, refill 180 s/240 s/7200 s) would have
// shed 9 % of channel messages, 15 % of sender-keyed traffic and 15 % of adverts.
#ifndef FAIRNESS_GROUP_REFILL_MS
#define FAIRNESS_GROUP_REFILL_MS (3 * 60 * 1000)
#define FAIRNESS_GROUP_REFILL_MS (30 * 1000)
#endif
#ifndef FAIRNESS_SENDER_NORMAL_REFILL_MS
#define FAIRNESS_SENDER_NORMAL_REFILL_MS (4 * 60 * 1000)
#define FAIRNESS_SENDER_NORMAL_REFILL_MS (10 * 1000)
#endif
#ifndef FAIRNESS_SENDER_LOW_REFILL_MS
#define FAIRNESS_SENDER_LOW_REFILL_MS (120 * 60 * 1000)
#define FAIRNESS_SENDER_LOW_REFILL_MS (10 * 60 * 1000)
#endif
// Capacity (max burst) per bucket.
// Capacity (max burst) per bucket. uint8_t, so at most 255.
#ifndef FAIRNESS_GROUP_CAP
#define FAIRNESS_GROUP_CAP 20
#define FAIRNESS_GROUP_CAP 100
#endif
#ifndef FAIRNESS_SENDER_NORMAL_CAP
#define FAIRNESS_SENDER_NORMAL_CAP 30
#define FAIRNESS_SENDER_NORMAL_CAP 150
#endif
#ifndef FAIRNESS_SENDER_LOW_CAP
#define FAIRNESS_SENDER_LOW_CAP 4
#define FAIRNESS_SENDER_LOW_CAP 30
#endif
// Simply allow all direct messages?