Skip to content

Commit

Permalink
Admin session key debugging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-bennett committed Aug 19, 2024
1 parent 273beef commit ab9268c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/modules/AdminModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "NodeDB.h"
#include "PowerFSM.h"
#include "RTC.h"
#include "meshUtils.h"
#include <FSCommon.h>
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_BLUETOOTH
#include "BleOta.h"
Expand Down Expand Up @@ -968,13 +969,16 @@ void AdminModule::setPassKey(meshtastic_AdminMessage *res)
}
memcpy(res->session_passkey.bytes, session_passkey, 8);
res->session_passkey.size = 8;
printBytes("Setting admin key to ", res->session_passkey.bytes, 8);
// if halfway to session_expire, regenerate session_passkey, reset the timeout
// set the key in the packet
}

bool AdminModule::checkPassKey(meshtastic_AdminMessage *res)
{ // check that the key in the packet is still valid
return (session_time + 300 < millis() / 1000 && res->session_passkey.size == 8 &&
printBytes("Incoming session key: ", res->session_passkey.bytes, 8);
printBytes("Expected session key: ", session_passkey, 8);
return (session_time + 300 > millis() / 1000 && res->session_passkey.size == 8 &&
memcmp(res->session_passkey.bytes, session_passkey, 8) == 0);
}

Expand Down

0 comments on commit ab9268c

Please sign in to comment.