diff --git a/examples/simple_repeater/MyMesh.cpp b/examples/simple_repeater/MyMesh.cpp index 5cc3a9a11e..f68597a5b9 100644 --- a/examples/simple_repeater/MyMesh.cpp +++ b/examples/simple_repeater/MyMesh.cpp @@ -111,13 +111,13 @@ uint8_t MyMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t* secr } client = acl.putClient(sender, 0); // add to contacts (if not already known) - if (sender_timestamp <= client->last_timestamp) { + if (sender_timestamp <= client->last_login_timestamp) { MESH_DEBUG_PRINTLN("Possible login replay attack!"); return 0; // FATAL: client table is full -OR- replay attack } MESH_DEBUG_PRINTLN("Login success!"); - client->last_timestamp = sender_timestamp; + client->last_login_timestamp = sender_timestamp; client->last_activity = getRTCClock()->getCurrentTime(); client->permissions &= ~0x03; client->permissions |= perms; diff --git a/examples/simple_room_server/MyMesh.cpp b/examples/simple_room_server/MyMesh.cpp index 12d0b0c318..db1c6e38b5 100644 --- a/examples/simple_room_server/MyMesh.cpp +++ b/examples/simple_room_server/MyMesh.cpp @@ -342,13 +342,13 @@ void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const m } client = acl.putClient(sender, 0); // add to known clients (if not already known) - if (sender_timestamp <= client->last_timestamp) { + if (sender_timestamp <= client->last_login_timestamp) { MESH_DEBUG_PRINTLN("possible replay attack!"); return; } MESH_DEBUG_PRINTLN("Login success!"); - client->last_timestamp = sender_timestamp; + client->last_login_timestamp = sender_timestamp; client->extra.room.sync_since = sender_sync_since; client->extra.room.pending_ack = 0; client->extra.room.push_failures = 0; diff --git a/examples/simple_sensor/SensorMesh.cpp b/examples/simple_sensor/SensorMesh.cpp index 59c9aa0900..f899ecf263 100644 --- a/examples/simple_sensor/SensorMesh.cpp +++ b/examples/simple_sensor/SensorMesh.cpp @@ -349,13 +349,13 @@ uint8_t SensorMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t* } client = acl.putClient(sender, PERM_RECV_ALERTS_HI | PERM_RECV_ALERTS_LO); // add to contacts (if not already known) - if (sender_timestamp <= client->last_timestamp) { + if (sender_timestamp <= client->last_login_timestamp) { MESH_DEBUG_PRINTLN("Possible login replay attack!"); return 0; // FATAL: client table is full -OR- replay attack } MESH_DEBUG_PRINTLN("Login success!"); - client->last_timestamp = sender_timestamp; + client->last_login_timestamp = sender_timestamp; client->last_activity = getRTCClock()->getCurrentTime(); client->permissions |= PERM_ACL_ADMIN; memcpy(client->shared_secret, secret, PUB_KEY_SIZE); diff --git a/src/helpers/ClientACL.h b/src/helpers/ClientACL.h index b758f7068d..126f7d7307 100644 --- a/src/helpers/ClientACL.h +++ b/src/helpers/ClientACL.h @@ -19,6 +19,7 @@ struct ClientInfo { uint8_t out_path[MAX_PATH_SIZE]; uint8_t shared_secret[PUB_KEY_SIZE]; uint32_t last_timestamp; // by THEIR clock (transient) + uint32_t last_login_timestamp; // by THEIR clock, login packets only (transient) uint32_t last_activity; // by OUR clock (transient) union { struct {