aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Database.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Database.cpp b/src/Database.cpp
index ac5a941..5eedc7a 100644
--- a/src/Database.cpp
+++ b/src/Database.cpp
@@ -33,6 +33,7 @@ namespace odhtdb
const u16 DATABASE_CREATE_PACKET_STRUCTURE_VERSION = 1;
const u16 DATABASE_ADD_PACKET_STRUCTURE_VERSION = 1;
+ const u16 DATABASE_REQUEST_OLD_DATA_STRUCTURE_VERSION = 1;
class RequestQuarantineException : public runtime_error
{
@@ -251,6 +252,12 @@ namespace odhtdb
{
static_assert(HASH_LEN == OPENDHT_INFOHASH_LEN, "Wrong hashlen size, did it change with opendht upgrade?");
sibs::SafeDeserializer deserializer(value->data.data(), value->data.size());
+ u16 requestStructureVersion = deserializer.extract<u16>();
+ if(requestStructureVersion != DATABASE_REQUEST_OLD_DATA_STRUCTURE_VERSION)
+ {
+ Log::warn("Request: structure is version %d but we are at version %d, ignoring request", requestStructureVersion, DATABASE_REQUEST_OLD_DATA_STRUCTURE_VERSION);
+ return true;
+ }
InfoHash requestResponseInfoHash;
deserializer.extract(requestResponseInfoHash.data(), OPENDHT_INFOHASH_LEN);
if(*responseKeyShared == requestResponseInfoHash)
@@ -324,6 +331,7 @@ namespace odhtdb
seedInfoMap[*nodeToSeed.getRequestHash()] = newSeedInfo;
sibs::SafeSerializer serializer;
+ serializer.add(DATABASE_REQUEST_OLD_DATA_STRUCTURE_VERSION);
serializer.add(responseKey, OPENDHT_INFOHASH_LEN);
bool iHaveCreateNode = databaseStorage.doesNodeExist(*nodeToSeed.getRequestHash());
serializer.add(iHaveCreateNode ? (u8)0 : (u8)1);