mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
refactor: extract region.autotag.max.hops cap into a named constant
Replace the magic 8 used in both the load-time sanitize and the CLI set handler with REGION_AUTOTAG_MAX_HOPS_LIMIT, and surface the cap in the "Error, range is 0-N" reply so the CLI and the constant can never drift apart. Also expand the docs to call out the range explicitly, the clamp-on- load behaviour, and the rationale for the 8 upper bound (well below flood.max so auto-tagging can't silently scope distant traffic).
This commit is contained in:
parent
e5d9eb7c67
commit
b2d80391bb
3 changed files with 8 additions and 4 deletions
|
|
@ -738,7 +738,9 @@ This document provides an overview of CLI commands that can be sent to MeshCore
|
|||
- `set region.autotag.max.hops <value>`
|
||||
|
||||
**Parameters:**
|
||||
- `value`: Maximum path hash count (0-8). `0` means only auto-tag packets without scope received directly (zero-hop); higher values also auto-tag packets without scope that already traversed that many repeaters.
|
||||
- `value`: Maximum path hash count. `0` means only auto-tag packets without scope received directly (zero-hop); higher values also auto-tag packets without scope that already traversed that many repeaters.
|
||||
|
||||
**Range:** `0` to `8` (inclusive). Values outside this range are rejected by `set` and clamped to this range on load. The upper bound of `8` is intentionally well below the default `flood.max` of `64`, because auto-tagging packets from far across the mesh almost always produces incorrect region assignments — the limit exists to keep admins honest about the geographic scope they can actually account for.
|
||||
|
||||
**Default:** `1`
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
|
|||
// sanitise settings
|
||||
_prefs->rx_boosted_gain = constrain(_prefs->rx_boosted_gain, 0, 1); // boolean
|
||||
_prefs->region_autotag = constrain(_prefs->region_autotag, 0, 1); // boolean
|
||||
_prefs->region_autotag_max_hops = constrain(_prefs->region_autotag_max_hops, 0, 8);
|
||||
_prefs->region_autotag_max_hops = constrain(_prefs->region_autotag_max_hops, 0, REGION_AUTOTAG_MAX_HOPS_LIMIT);
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
|
@ -630,12 +630,12 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
|||
strcpy(reply, "OK");
|
||||
} else if (memcmp(config, "region.autotag.max.hops ", 24) == 0) {
|
||||
int h = atoi(&config[24]);
|
||||
if (h >= 0 && h <= 8) {
|
||||
if (h >= 0 && h <= REGION_AUTOTAG_MAX_HOPS_LIMIT) {
|
||||
_prefs->region_autotag_max_hops = (uint8_t)h;
|
||||
savePrefs();
|
||||
strcpy(reply, "OK");
|
||||
} else {
|
||||
strcpy(reply, "Error, range is 0-8");
|
||||
sprintf(reply, "Error, range is 0-%d", REGION_AUTOTAG_MAX_HOPS_LIMIT);
|
||||
}
|
||||
} else if (memcmp(config, "region.autotag ", 15) == 0) {
|
||||
_prefs->region_autotag = memcmp(&config[15], "on", 2) == 0;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
#define ADVERT_LOC_SHARE 1
|
||||
#define ADVERT_LOC_PREFS 2
|
||||
|
||||
#define REGION_AUTOTAG_MAX_HOPS_LIMIT 8 // upper bound for region.autotag.max.hops pref
|
||||
|
||||
#define LOOP_DETECT_OFF 0
|
||||
#define LOOP_DETECT_MINIMAL 1
|
||||
#define LOOP_DETECT_MODERATE 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue