blepwr/fairness: opravy z review-three

- `blepwr` parsuje striktně (strtol + kontrola celého argumentu a platné
  hodnoty) — `atoi` udělal z „216" −40 a z „abc" 0, a teď se to ukládá.
  Stará syntaxe `blepwr -20 hold` skončí ERR místo tichého uložení −20.
- „saved" jen když zápis do InternalFS opravdu prošel, jinak „NOT saved".
- mast-three env: RPT_BLE_CONN_TX_POWER=8, aby po flashi nenaběhl na 0 dBm,
  na kterých most z bridge-host přes zavřené okno padá.
- FairnessLimiter: opravené odůvodnění 0x00/0xFF — náš companion identitu
  přegeneruje, ale na CZ meshi za 30 dní prošlo 50 floodů od takových
  odesílatelů a u ANON_REQ je payload[1] bajt náhodného klíče (2/256 všech).
  Test přejmenován (cap 100 je teď pod defaultem).
- tools/fairness_replay.py: přehrání floodů z CoreScope přes model limiteru,
  odkud jsou výchozí hodnoty; pro přepočet, až se provoz změní.

Ověřeno na x1: 216/264/abc/„-20 hold"/1 → ERR; 6 → saved → reboot → 6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-10-06 23:46:40 +02:00
1 parent 29ef420486
commit 2386504e2d
4 files changed
+37 -15

No files matched your search

+10 -5
View File
@@ -19,10 +19,14 @@
#include <Packet.h>
#include <stdint.h>
// 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.
// Sender hashes 0x00 and 0xFF are NOT special here. Our firmware never creates
// such an identity (re-roll on create, validatePrivateKey() on import), but the
// mesh still carries them: over 30 days (Sep-Oct 2026, CZ mesh) 50 floods of
// REQ/PATH/TXT_MSG/RESPONSE came from 0x00/0xFF senders -- older identities and
// other implementations. And for ANON_REQ payload[1] is the first byte of a
// random ephemeral key, so "always deny" also dropped 2 in 256 anonymous
// requests from anyone. Denying them always (as the original branch did)
// dropped every such flood; now they are limited like any other bucket.
// 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
@@ -32,7 +36,8 @@
// 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
// mesh at one-site, replayed through this limiter with
// tools/fairness_replay.py -- rerun it when the traffic changes). 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