sync with vanilla dev

This commit is contained in:
liquidraver
2026-06-15 15:25:04 +02:00
parent b97d079e56
commit dc7a2827a3
2 changed files with 19 additions and 3 deletions
+9 -2
View File
@@ -1677,10 +1677,16 @@ bool CompanionMesh::handleProtocolFrame(const uint8_t *data, size_t len)
_contact_iter_since = 0;
}
// Send PACKET_CONTACT_START with total count (unfiltered)
// Send PACKET_CONTACT_START with total count (unfiltered, but excluding
// transient anon slots -- continueContactIteration() never streams those)
uint32_t total = 0;
for (int i = 0; i < getNumContacts(); i++) {
ContactInfo c;
if (getContactByIdx(i, c) && c.type != ADV_TYPE_NONE) total++;
}
uint8_t rsp[5];
rsp[0] = PACKET_CONTACT_START;
put_le32(&rsp[1], (uint32_t)getNumContacts());
put_le32(&rsp[1], total);
writeFrame(rsp, sizeof(rsp));
_contact_iter_idx = 0;
_contact_iter_lastmod = 0;
@@ -2975,6 +2981,7 @@ bool CompanionMesh::handleProtocolFrame(const uint8_t *data, size_t len)
memcpy(anon.id.pub_key, &data[1], PUB_KEY_SIZE);
anon.out_path_len = 0; // zero-hop direct by default
anon.type = ADV_TYPE_NONE; // transient/unknown
anon.lastmod = getRTCClock()->getCurrentTime(); // so slot recycling is LRU, not always slot 0
if (addContact(anon)) {
contact = lookupContactByPubKey(&data[1], PUB_KEY_SIZE);
}
+10 -1
View File
@@ -107,7 +107,11 @@ ContactInfo *BaseChatMesh::allocateContactSlot(bool transient_only)
}
}
if (oldest_idx >= 0) {
onContactOverwrite(contacts[oldest_idx].id.pub_key);
if (!transient_only) {
// recycling an anon slot isn't a "contact deleted" event -- the
// app was never told this transient pubkey existed
onContactOverwrite(contacts[oldest_idx].id.pub_key);
}
return &contacts[oldest_idx];
}
}
@@ -165,6 +169,11 @@ void BaseChatMesh::onAdvertRecv(mesh::Packet *packet, const mesh::Identity &id,
packet->header = save;
}
if (from && from->type == ADV_TYPE_NONE) { // matched a transient anon/ANON_REQ slot -- promote to a real contact
*from = ContactInfo{};
from = nullptr;
}
bool is_new = false;
if (from == nullptr) {
LOG_DBG("onAdvertRecv: new contact, checking auto-add for type %d", parser.getType());