mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-11 19:10:55 +00:00
pass null tunnel config for zero hops tunnel
This commit is contained in:
parent
6ab7e79987
commit
0493f00a7a
12
Tunnel.cpp
12
Tunnel.cpp
@ -771,18 +771,18 @@ namespace tunnel
|
|||||||
|
|
||||||
std::shared_ptr<InboundTunnel> Tunnels::CreateInboundTunnel (std::shared_ptr<TunnelConfig> config, std::shared_ptr<OutboundTunnel> outboundTunnel)
|
std::shared_ptr<InboundTunnel> Tunnels::CreateInboundTunnel (std::shared_ptr<TunnelConfig> config, std::shared_ptr<OutboundTunnel> outboundTunnel)
|
||||||
{
|
{
|
||||||
if (config->IsEmpty ())
|
if (config)
|
||||||
return CreateZeroHopsInboundTunnel ();
|
|
||||||
else
|
|
||||||
return CreateTunnel<InboundTunnel>(config, outboundTunnel);
|
return CreateTunnel<InboundTunnel>(config, outboundTunnel);
|
||||||
|
else
|
||||||
|
return CreateZeroHopsInboundTunnel ();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<OutboundTunnel> Tunnels::CreateOutboundTunnel (std::shared_ptr<TunnelConfig> config)
|
std::shared_ptr<OutboundTunnel> Tunnels::CreateOutboundTunnel (std::shared_ptr<TunnelConfig> config)
|
||||||
{
|
{
|
||||||
if (config->IsEmpty ())
|
if (config)
|
||||||
return CreateZeroHopsOutboundTunnel ();
|
|
||||||
else
|
|
||||||
return CreateTunnel<OutboundTunnel>(config);
|
return CreateTunnel<OutboundTunnel>(config);
|
||||||
|
else
|
||||||
|
return CreateZeroHopsOutboundTunnel ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tunnels::AddPendingTunnel (uint32_t replyMsgID, std::shared_ptr<InboundTunnel> tunnel)
|
void Tunnels::AddPendingTunnel (uint32_t replyMsgID, std::shared_ptr<InboundTunnel> tunnel)
|
||||||
|
@ -396,8 +396,6 @@ namespace tunnel
|
|||||||
std::reverse (peers.begin (), peers.end ());
|
std::reverse (peers.begin (), peers.end ());
|
||||||
config = std::make_shared<TunnelConfig> (peers);
|
config = std::make_shared<TunnelConfig> (peers);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
config = std::make_shared<ZeroHopsTunnelConfig> ();
|
|
||||||
auto tunnel = tunnels.CreateInboundTunnel (config, outboundTunnel);
|
auto tunnel = tunnels.CreateInboundTunnel (config, outboundTunnel);
|
||||||
tunnel->SetTunnelPool (shared_from_this ());
|
tunnel->SetTunnelPool (shared_from_this ());
|
||||||
if (tunnel->IsEstablished ()) // zero hops
|
if (tunnel->IsEstablished ()) // zero hops
|
||||||
@ -413,8 +411,8 @@ namespace tunnel
|
|||||||
if (!outboundTunnel)
|
if (!outboundTunnel)
|
||||||
outboundTunnel = tunnels.GetNextOutboundTunnel ();
|
outboundTunnel = tunnels.GetNextOutboundTunnel ();
|
||||||
LogPrint (eLogDebug, "Tunnels: Re-creating destination inbound tunnel...");
|
LogPrint (eLogDebug, "Tunnels: Re-creating destination inbound tunnel...");
|
||||||
std::shared_ptr<TunnelConfig> config = m_NumInboundHops > 0 ?
|
std::shared_ptr<TunnelConfig> config;
|
||||||
std::make_shared<TunnelConfig>(tunnel->GetPeers ()) : std::make_shared<ZeroHopsTunnelConfig> ();
|
if (m_NumInboundHops > 0) config = std::make_shared<TunnelConfig>(tunnel->GetPeers ());
|
||||||
auto newTunnel = tunnels.CreateInboundTunnel (config, outboundTunnel);
|
auto newTunnel = tunnels.CreateInboundTunnel (config, outboundTunnel);
|
||||||
newTunnel->SetTunnelPool (shared_from_this());
|
newTunnel->SetTunnelPool (shared_from_this());
|
||||||
if (newTunnel->IsEstablished ()) // zero hops
|
if (newTunnel->IsEstablished ()) // zero hops
|
||||||
@ -432,10 +430,9 @@ namespace tunnel
|
|||||||
std::vector<std::shared_ptr<const i2p::data::IdentityEx> > peers;
|
std::vector<std::shared_ptr<const i2p::data::IdentityEx> > peers;
|
||||||
if (SelectPeers (peers, false))
|
if (SelectPeers (peers, false))
|
||||||
{
|
{
|
||||||
std::shared_ptr<TunnelConfig> config = m_NumOutboundHops > 0 ?
|
std::shared_ptr<TunnelConfig> config;
|
||||||
std::make_shared<TunnelConfig>(peers, inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ()) :
|
if (m_NumOutboundHops > 0)
|
||||||
std::make_shared<ZeroHopsTunnelConfig> ();
|
config = std::make_shared<TunnelConfig>(peers, inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ());
|
||||||
|
|
||||||
auto tunnel = tunnels.CreateOutboundTunnel (config);
|
auto tunnel = tunnels.CreateOutboundTunnel (config);
|
||||||
tunnel->SetTunnelPool (shared_from_this ());
|
tunnel->SetTunnelPool (shared_from_this ());
|
||||||
if (tunnel->IsEstablished ()) // zero hops
|
if (tunnel->IsEstablished ()) // zero hops
|
||||||
@ -456,9 +453,9 @@ namespace tunnel
|
|||||||
if (inboundTunnel)
|
if (inboundTunnel)
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "Tunnels: Re-creating destination outbound tunnel...");
|
LogPrint (eLogDebug, "Tunnels: Re-creating destination outbound tunnel...");
|
||||||
std::shared_ptr<TunnelConfig> config = m_NumOutboundHops > 0 ?
|
std::shared_ptr<TunnelConfig> config;
|
||||||
std::make_shared<TunnelConfig>(tunnel->GetPeers (), inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ()) :
|
if (m_NumOutboundHops > 0)
|
||||||
std::make_shared<ZeroHopsTunnelConfig> ();
|
config = std::make_shared<TunnelConfig>(tunnel->GetPeers (), inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ());
|
||||||
auto newTunnel = tunnels.CreateOutboundTunnel (config);
|
auto newTunnel = tunnels.CreateOutboundTunnel (config);
|
||||||
newTunnel->SetTunnelPool (shared_from_this ());
|
newTunnel->SetTunnelPool (shared_from_this ());
|
||||||
if (newTunnel->IsEstablished ()) // zero hops
|
if (newTunnel->IsEstablished ()) // zero hops
|
||||||
|
Loading…
Reference in New Issue
Block a user