|
|
@ -1,15 +1,21 @@ |
|
|
|
|
|
|
|
#include <cryptopp/dh.h> |
|
|
|
|
|
|
|
#include "CryptoConst.h" |
|
|
|
#include "Tunnel.h" |
|
|
|
#include "Tunnel.h" |
|
|
|
#include "NetDb.h" |
|
|
|
#include "NetDb.h" |
|
|
|
#include "Timestamp.h" |
|
|
|
#include "Timestamp.h" |
|
|
|
|
|
|
|
#include "RouterContext.h" |
|
|
|
#include "TunnelPool.h" |
|
|
|
#include "TunnelPool.h" |
|
|
|
|
|
|
|
|
|
|
|
namespace i2p |
|
|
|
namespace i2p |
|
|
|
{ |
|
|
|
{ |
|
|
|
namespace tunnel |
|
|
|
namespace tunnel |
|
|
|
{ |
|
|
|
{ |
|
|
|
TunnelPool::TunnelPool (i2p::data::LocalDestination * owner, int numTunnels): |
|
|
|
TunnelPool::TunnelPool (i2p::data::LocalDestination * localDestination, int numTunnels): |
|
|
|
m_Owner (owner), m_NumTunnels (numTunnels) |
|
|
|
m_LocalDestination (localDestination), m_NumTunnels (numTunnels) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CryptoPP::AutoSeededRandomPool rnd; |
|
|
|
|
|
|
|
CryptoPP::DH dh (i2p::crypto::elgp, i2p::crypto::elgg); |
|
|
|
|
|
|
|
dh.GenerateKeyPair(i2p::context.GetRandomNumberGenerator (), m_EncryptionPrivateKey, m_EncryptionPublicKey); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TunnelPool::~TunnelPool () |
|
|
|
TunnelPool::~TunnelPool () |
|
|
@ -21,15 +27,15 @@ namespace tunnel |
|
|
|
void TunnelPool::TunnelCreated (InboundTunnel * createdTunnel) |
|
|
|
void TunnelPool::TunnelCreated (InboundTunnel * createdTunnel) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_InboundTunnels.insert (createdTunnel); |
|
|
|
m_InboundTunnels.insert (createdTunnel); |
|
|
|
if (m_Owner) |
|
|
|
if (m_LocalDestination) |
|
|
|
m_Owner->UpdateLeaseSet (); |
|
|
|
m_LocalDestination->UpdateLeaseSet (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TunnelPool::TunnelExpired (InboundTunnel * expiredTunnel) |
|
|
|
void TunnelPool::TunnelExpired (InboundTunnel * expiredTunnel) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_InboundTunnels.erase (expiredTunnel); |
|
|
|
m_InboundTunnels.erase (expiredTunnel); |
|
|
|
if (m_Owner) |
|
|
|
if (m_LocalDestination) |
|
|
|
m_Owner->UpdateLeaseSet (); |
|
|
|
m_LocalDestination->UpdateLeaseSet (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::vector<InboundTunnel *> TunnelPool::GetInboundTunnels (int num) const |
|
|
|
std::vector<InboundTunnel *> TunnelPool::GetInboundTunnels (int num) const |
|
|
@ -63,7 +69,7 @@ namespace tunnel |
|
|
|
{ |
|
|
|
{ |
|
|
|
firstHop, |
|
|
|
firstHop, |
|
|
|
secondHop |
|
|
|
secondHop |
|
|
|
// TODO: swithc to 3-hops later
|
|
|
|
// TODO: switch to 3-hops later
|
|
|
|
/*i2p::data::netdb.GetRandomRouter (secondHop) */ |
|
|
|
/*i2p::data::netdb.GetRandomRouter (secondHop) */ |
|
|
|
}), |
|
|
|
}), |
|
|
|
outboundTunnel); |
|
|
|
outboundTunnel); |
|
|
|