From 6a043649f5bce21e65c43702d04e15fb4384185c Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 27 May 2015 13:35:54 -0400 Subject: [PATCH] use random msg_id for I2NP messages --- I2NPProtocol.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index 4ad95d9e..104fdef1 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -41,17 +41,13 @@ namespace i2p return std::shared_ptr(msg, DeleteI2NPMessage); } - static std::atomic I2NPmsgID(0); // TODO: create class void FillI2NPMessageHeader (I2NPMessage * msg, I2NPMessageType msgType, uint32_t replyMsgID) { msg->SetTypeID (msgType); if (replyMsgID) // for tunnel creation msg->SetMsgID (replyMsgID); - else - { - msg->SetMsgID (I2NPmsgID); - I2NPmsgID++; - } + else + msg->SetMsgID (i2p::context.GetRandomNumberGenerator ().GenerateWord32 ()); msg->SetExpiration (i2p::util::GetMillisecondsSinceEpoch () + 5000); // TODO: 5 secs is a magic number msg->UpdateSize (); msg->UpdateChks (); @@ -61,8 +57,7 @@ namespace i2p { if (msg) { - msg->SetMsgID (I2NPmsgID); - I2NPmsgID++; + msg->SetMsgID (i2p::context.GetRandomNumberGenerator ().GenerateWord32 ()); msg->SetExpiration (i2p::util::GetMillisecondsSinceEpoch () + 5000); } }