* ID hash 0x00 and 0xFF now reserved for future.
This commit is contained in:
@@ -228,6 +228,10 @@ class MyMesh : public BaseChatMesh {
|
|||||||
void loadMainIdentity() {
|
void loadMainIdentity() {
|
||||||
if (!_identity_store->load("_main", self_id)) {
|
if (!_identity_store->load("_main", self_id)) {
|
||||||
self_id = radio_new_identity(); // create new random identity
|
self_id = radio_new_identity(); // create new random identity
|
||||||
|
int count = 0;
|
||||||
|
while (count < 10 && (self_id.pub_key[0] == 0x00 || self_id.pub_key[0] == 0xFF)) { // reserved id hashes
|
||||||
|
self_id = radio_new_identity(); count++;
|
||||||
|
}
|
||||||
saveMainIdentity(self_id);
|
saveMainIdentity(self_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -643,6 +643,10 @@ void setup() {
|
|||||||
if (!store.load("_main", the_mesh.self_id)) {
|
if (!store.load("_main", the_mesh.self_id)) {
|
||||||
MESH_DEBUG_PRINTLN("Generating new keypair");
|
MESH_DEBUG_PRINTLN("Generating new keypair");
|
||||||
the_mesh.self_id = radio_new_identity(); // create new random identity
|
the_mesh.self_id = radio_new_identity(); // create new random identity
|
||||||
|
int count = 0;
|
||||||
|
while (count < 10 && (the_mesh.self_id.pub_key[0] == 0x00 || the_mesh.self_id.pub_key[0] == 0xFF)) { // reserved id hashes
|
||||||
|
the_mesh.self_id = radio_new_identity(); count++;
|
||||||
|
}
|
||||||
store.save("_main", the_mesh.self_id);
|
store.save("_main", the_mesh.self_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -872,6 +872,10 @@ void setup() {
|
|||||||
#endif
|
#endif
|
||||||
if (!store.load("_main", the_mesh.self_id)) {
|
if (!store.load("_main", the_mesh.self_id)) {
|
||||||
the_mesh.self_id = radio_new_identity(); // create new random identity
|
the_mesh.self_id = radio_new_identity(); // create new random identity
|
||||||
|
int count = 0;
|
||||||
|
while (count < 10 && (the_mesh.self_id.pub_key[0] == 0x00 || the_mesh.self_id.pub_key[0] == 0xFF)) { // reserved id hashes
|
||||||
|
the_mesh.self_id = radio_new_identity(); count++;
|
||||||
|
}
|
||||||
store.save("_main", the_mesh.self_id);
|
store.save("_main", the_mesh.self_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -300,6 +300,10 @@ public:
|
|||||||
((StdRNG *)getRNG())->begin(millis());
|
((StdRNG *)getRNG())->begin(millis());
|
||||||
|
|
||||||
self_id = mesh::LocalIdentity(getRNG()); // create new random identity
|
self_id = mesh::LocalIdentity(getRNG()); // create new random identity
|
||||||
|
int count = 0;
|
||||||
|
while (count < 10 && (self_id.pub_key[0] == 0x00 || self_id.pub_key[0] == 0xFF)) { // reserved id hashes
|
||||||
|
self_id = mesh::LocalIdentity(getRNG()); count++;
|
||||||
|
}
|
||||||
store.save("_main", self_id);
|
store.save("_main", self_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user