Browse Source

use random msg_id for I2NP messages

pull/197/head
orignal 9 years ago
parent
commit
6a043649f5
  1. 11
      I2NPProtocol.cpp

11
I2NPProtocol.cpp

@ -41,17 +41,13 @@ namespace i2p
return std::shared_ptr<I2NPMessage>(msg, DeleteI2NPMessage); return std::shared_ptr<I2NPMessage>(msg, DeleteI2NPMessage);
} }
static std::atomic<uint32_t> I2NPmsgID(0); // TODO: create class
void FillI2NPMessageHeader (I2NPMessage * msg, I2NPMessageType msgType, uint32_t replyMsgID) void FillI2NPMessageHeader (I2NPMessage * msg, I2NPMessageType msgType, uint32_t replyMsgID)
{ {
msg->SetTypeID (msgType); msg->SetTypeID (msgType);
if (replyMsgID) // for tunnel creation if (replyMsgID) // for tunnel creation
msg->SetMsgID (replyMsgID); msg->SetMsgID (replyMsgID);
else else
{ msg->SetMsgID (i2p::context.GetRandomNumberGenerator ().GenerateWord32 ());
msg->SetMsgID (I2NPmsgID);
I2NPmsgID++;
}
msg->SetExpiration (i2p::util::GetMillisecondsSinceEpoch () + 5000); // TODO: 5 secs is a magic number msg->SetExpiration (i2p::util::GetMillisecondsSinceEpoch () + 5000); // TODO: 5 secs is a magic number
msg->UpdateSize (); msg->UpdateSize ();
msg->UpdateChks (); msg->UpdateChks ();
@ -61,8 +57,7 @@ namespace i2p
{ {
if (msg) if (msg)
{ {
msg->SetMsgID (I2NPmsgID); msg->SetMsgID (i2p::context.GetRandomNumberGenerator ().GenerateWord32 ());
I2NPmsgID++;
msg->SetExpiration (i2p::util::GetMillisecondsSinceEpoch () + 5000); msg->SetExpiration (i2p::util::GetMillisecondsSinceEpoch () + 5000);
} }
} }

Loading…
Cancel
Save