1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 04:04:16 +00:00

some cleanup

This commit is contained in:
orignal 2014-12-09 21:07:54 -05:00
parent a2d69a8b66
commit c8e34052a7
4 changed files with 12 additions and 10 deletions

View File

@ -161,7 +161,7 @@ namespace i2p
buf[32] = 1; // 1 tag buf[32] = 1; // 1 tag
rnd.GenerateBlock (buf + 33, 32); // tag rnd.GenerateBlock (buf + 33, 32); // tag
if (pool) if (pool)
pool->GetGarlicDestination ().SubmitSessionKey (buf, buf + 33); // introduce new key-tag to garlic engine pool->GetLocalDestination ().SubmitSessionKey (buf, buf + 33); // introduce new key-tag to garlic engine
else else
LogPrint ("Destination for encrypteed reply not specified"); LogPrint ("Destination for encrypteed reply not specified");
buf += 65; buf += 65;
@ -563,7 +563,7 @@ namespace i2p
case eI2NPGarlic: case eI2NPGarlic:
LogPrint ("Garlic"); LogPrint ("Garlic");
if (msg->from && msg->from->GetTunnelPool ()) if (msg->from && msg->from->GetTunnelPool ())
msg->from->GetTunnelPool ()->GetGarlicDestination ().ProcessGarlicMessage (msg); msg->from->GetTunnelPool ()->GetLocalDestination ().ProcessGarlicMessage (msg);
else else
i2p::context.ProcessGarlicMessage (msg); i2p::context.ProcessGarlicMessage (msg);
break; break;

View File

@ -221,7 +221,7 @@ namespace tunnel
m_PendingTunnels.clear ();*/ m_PendingTunnels.clear ();*/
for (auto& it: m_Pools) for (auto& it: m_Pools)
delete it.second; delete it;
m_Pools.clear (); m_Pools.clear ();
} }
@ -291,7 +291,7 @@ namespace tunnel
{ {
auto pool = new TunnelPool (localDestination, numInboundHops, numOutboundHops); auto pool = new TunnelPool (localDestination, numInboundHops, numOutboundHops);
std::unique_lock<std::mutex> l(m_PoolsMutex); std::unique_lock<std::mutex> l(m_PoolsMutex);
m_Pools[pool->GetIdentHash ()] = pool; m_Pools.push_back (pool);
return pool; return pool;
} }
@ -300,7 +300,10 @@ namespace tunnel
if (pool) if (pool)
{ {
StopTunnelPool (pool); StopTunnelPool (pool);
m_Pools.erase (pool->GetLocalDestination ().GetIdentHash ()); {
std::unique_lock<std::mutex> l(m_PoolsMutex);
m_Pools.remove (pool);
}
for (auto it: m_PendingTunnels) for (auto it: m_PendingTunnels)
if (it.second->GetTunnelPool () == pool) if (it.second->GetTunnelPool () == pool)
it.second->SetTunnelPool (nullptr); it.second->SetTunnelPool (nullptr);
@ -551,7 +554,7 @@ namespace tunnel
std::unique_lock<std::mutex> l(m_PoolsMutex); std::unique_lock<std::mutex> l(m_PoolsMutex);
for (auto it: m_Pools) for (auto it: m_Pools)
{ {
TunnelPool * pool = it.second; TunnelPool * pool = it;
if (pool->IsActive ()) if (pool->IsActive ())
{ {
pool->CreateTunnels (); pool->CreateTunnels ();

View File

@ -157,7 +157,7 @@ namespace tunnel
std::mutex m_TransitTunnelsMutex; std::mutex m_TransitTunnelsMutex;
std::map<uint32_t, TransitTunnel *> m_TransitTunnels; std::map<uint32_t, TransitTunnel *> m_TransitTunnels;
std::mutex m_PoolsMutex; std::mutex m_PoolsMutex;
std::map<i2p::data::IdentHash, TunnelPool *> m_Pools; std::list<TunnelPool *> m_Pools;
TunnelPool * m_ExploratoryPool; TunnelPool * m_ExploratoryPool;
i2p::util::Queue<I2NPMessage> m_Queue; i2p::util::Queue<I2NPMessage> m_Queue;

View File

@ -30,9 +30,8 @@ namespace tunnel
~TunnelPool (); ~TunnelPool ();
const uint8_t * GetEncryptionPrivateKey () const { return m_LocalDestination.GetEncryptionPrivateKey (); }; const uint8_t * GetEncryptionPrivateKey () const { return m_LocalDestination.GetEncryptionPrivateKey (); };
const uint8_t * GetEncryptionPublicKey () const { return m_LocalDestination.GetEncryptionPublicKey (); }; const uint8_t * GetEncryptionPublicKey () const { return m_LocalDestination.GetEncryptionPublicKey (); };
const i2p::data::LocalDestination& GetLocalDestination () const { return m_LocalDestination; }; i2p::garlic::GarlicDestination& GetLocalDestination () const { return m_LocalDestination; };
i2p::garlic::GarlicDestination& GetGarlicDestination () const { return m_LocalDestination; };
bool IsExploratory () const { return GetIdentHash () == i2p::context.GetIdentHash (); }; bool IsExploratory () const { return GetIdentHash () == i2p::context.GetIdentHash (); };
void CreateTunnels (); void CreateTunnels ();