* misc fixes

This commit is contained in:
Scott Powell committed 2026-11-01 17:52:27 +11:00
1 parent 8bcf760558
commit 9a6c0ae71c
4 files changed
+17 -6

No files matched your search

+5 -1
View File
@@ -636,7 +636,11 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m
// a DIRECT login can reply via the stored out_path, as onPeerDataRecv() does for REQ
ClientInfo* client = acl.getClient(sender.pub_key, PUB_KEY_SIZE);
if (client == NULL) {
MESH_DEBUG_PRINTLN("onAnonDataRecv: client ACL cannot find slot!"); // This shouldn't happen!
// prob one of ANON_REQ_TYPE_REGIONS/_OWNER/_BASIC, and not in ACL
if (reply_path_len != 0xFF) {
mesh::Packet* reply = createDatagram(PAYLOAD_TYPE_RESPONSE, sender, secret, reply_data, reply_len);
if (reply) { sendDirect(reply, reply_path, reply_path_len, SERVER_RESPONSE_DELAY); }
}
return;
}
+9 -2
View File
@@ -657,7 +657,9 @@ void SensorMesh::onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender_i
ClientInfo* from = acl.getClientByIdx(i);
if (crypto_type == CRYPTO_NEW_DIRECT) {
from->direct_mode = (DM_MODE_SEQ_NORMAL << 4) | CRYPTO_NEW_DIRECT; // have received from Client in new scheme, so they must support it
if (from->direct_mode == CRYPTO_LEGACY) {
from->direct_mode = (DM_MODE_SEQ_NORMAL << 4) | CRYPTO_NEW_DIRECT; // have received from Client in new scheme, so they must support it
}
}
if (type == PAYLOAD_TYPE_REQ) { // request (from a known contact)
@@ -794,7 +796,7 @@ void SensorMesh::onControlDataRecv(mesh::Packet* packet) {
}
}
bool SensorMesh::onPeerPathRecv(mesh::Packet* packet, int sender_idx, const uint8_t* secret, uint8_t* path, uint8_t path_len, uint8_t extra_type, uint8_t* extra, uint8_t extra_len) {
bool SensorMesh::onPeerPathRecv(mesh::Packet* packet, int sender_idx, const uint8_t* secret, uint8_t* path, uint8_t path_len, uint8_t extra_type, uint8_t* extra, uint8_t extra_len, uint8_t crypto_type) {
int i = matching_peer_indexes[sender_idx];
if (i < 0 || i >= acl.getNumClients()) {
MESH_DEBUG_PRINTLN("onPeerPathRecv: Invalid sender idx: %d", i);
@@ -802,6 +804,11 @@ bool SensorMesh::onPeerPathRecv(mesh::Packet* packet, int sender_idx, const uint
}
ClientInfo* from = acl.getClientByIdx(i);
if (crypto_type == CRYPTO_NEW_DIRECT) {
if (from->direct_mode == CRYPTO_LEGACY) {
from->direct_mode = (DM_MODE_SEQ_NORMAL << 4) | CRYPTO_NEW_DIRECT; // have received from Client in new scheme, so they must support it
}
}
MESH_DEBUG_PRINTLN("PATH to contact, path_len=%d", (uint32_t) path_len);
// NOTE: for this impl, we just replace the current 'out_path' regardless, whenever sender sends us a new out_path.
+1 -1
View File
@@ -136,7 +136,7 @@ protected:
int searchPeersByHash(const uint8_t* hash) override;
void getPeerSharedSecret(uint8_t* dest_secret, int peer_idx) override;
void onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender_idx, const uint8_t* secret, uint8_t* data, size_t len, uint8_t crypto_type) override;
bool onPeerPathRecv(mesh::Packet* packet, int sender_idx, const uint8_t* secret, uint8_t* path, uint8_t path_len, uint8_t extra_type, uint8_t* extra, uint8_t extra_len) override;
bool onPeerPathRecv(mesh::Packet* packet, int sender_idx, const uint8_t* secret, uint8_t* path, uint8_t path_len, uint8_t extra_type, uint8_t* extra, uint8_t extra_len, uint8_t crypto_type) override;
void onControlDataRecv(mesh::Packet* packet) override;
void onAckRecv(mesh::Packet* packet, uint32_t ack_crc) override;
+2 -2
View File
@@ -747,7 +747,7 @@ int BaseChatMesh::sendRequest(ContactInfo& recipient, const uint8_t* req_data,
memcpy(temp, &tag, 4); // mostly an extra blob to help make packet_hash unique
memcpy(&temp[4], req_data, data_len);
auto pkt = obtainPacketFor(recipient);
pkt = obtainPacketFor(recipient);
if (pkt == NULL) return MSG_SEND_FAILED;
encodeDatagram(pkt, PAYLOAD_TYPE_REQ, recipient.id, recipient.getSharedSecret(self_id), temp, 4 + data_len);
@@ -766,7 +766,7 @@ int BaseChatMesh::sendRequest(ContactInfo& recipient, uint8_t req_type, uint32_
memset(&temp[5], 0, 4); // reserved (possibly for 'since' param)
getRNG()->random(&temp[9], 4); // random blob to help make packet-hash unique
auto pkt = obtainPacketFor(recipient);
pkt = obtainPacketFor(recipient);
if (pkt == NULL) return MSG_SEND_FAILED;
encodeDatagram(pkt, PAYLOAD_TYPE_REQ, recipient.id, recipient.getSharedSecret(self_id), temp, sizeof(temp));