Browse Source

generate reandom tunnelMsgID

pull/102/head
orignal 10 years ago
parent
commit
05c297cb0b
  1. 9
      Tunnel.cpp
  2. 2
      Tunnel.h

9
Tunnel.cpp

@ -198,8 +198,7 @@ namespace tunnel
Tunnels tunnels; Tunnels tunnels;
Tunnels::Tunnels (): m_IsRunning (false), m_IsTunnelCreated (false), Tunnels::Tunnels (): m_IsRunning (false), m_Thread (nullptr), m_ExploratoryPool (nullptr)
m_NextReplyMsgID (555), m_Thread (nullptr), m_ExploratoryPool (nullptr)
{ {
} }
@ -535,9 +534,9 @@ namespace tunnel
TTunnel * Tunnels::CreateTunnel (TunnelConfig * config, OutboundTunnel * outboundTunnel) TTunnel * Tunnels::CreateTunnel (TunnelConfig * config, OutboundTunnel * outboundTunnel)
{ {
TTunnel * newTunnel = new TTunnel (config); TTunnel * newTunnel = new TTunnel (config);
m_PendingTunnels[m_NextReplyMsgID] = newTunnel; uint32_t replyMsgID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 ();
newTunnel->Build (m_NextReplyMsgID, outboundTunnel); m_PendingTunnels[replyMsgID] = newTunnel;
m_NextReplyMsgID++; // TODO: should be atomic newTunnel->Build (replyMsgID, outboundTunnel);
return newTunnel; return newTunnel;
} }

2
Tunnel.h

@ -146,8 +146,6 @@ namespace tunnel
private: private:
bool m_IsRunning; bool m_IsRunning;
bool m_IsTunnelCreated; // TODO: temporary
uint32_t m_NextReplyMsgID; // TODO: make it random later
std::thread * m_Thread; std::thread * m_Thread;
std::map<uint32_t, Tunnel *> m_PendingTunnels; // by replyMsgID std::map<uint32_t, Tunnel *> m_PendingTunnels; // by replyMsgID
std::mutex m_InboundTunnelsMutex; std::mutex m_InboundTunnelsMutex;

Loading…
Cancel
Save