mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Add configurable max hops filter for auto-add contacts
Filter auto-add of new contacts by hop count (issues #1533, #1546). Setting is configurable from the companion app via extended CMD_SET/GET_AUTOADD_CONFIG protocol (0 = no limit, 1-63 = max hops). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
06ab9f7f6b
commit
00566741f6
6 changed files with 23 additions and 1 deletions
|
|
@ -141,6 +141,15 @@ void BaseChatMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id,
|
|||
return;
|
||||
}
|
||||
|
||||
// check hop limit for new contacts (0 = no limit)
|
||||
uint8_t max_hops = getAutoAddMaxHops();
|
||||
if (max_hops > 0 && packet->getPathHashCount() > max_hops) {
|
||||
ContactInfo ci;
|
||||
populateContactFromAdvert(ci, id, parser, timestamp);
|
||||
onDiscoveredContact(ci, true, packet->path_len, packet->path); // let UI know
|
||||
return;
|
||||
}
|
||||
|
||||
from = allocateContactSlot();
|
||||
if (from == NULL) {
|
||||
ContactInfo ci;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue