mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
print full tunnel path
This commit is contained in:
parent
a7b8b52dbd
commit
badcd64b62
19
Tunnel.cpp
19
Tunnel.cpp
|
@ -182,6 +182,15 @@ namespace tunnel
|
|||
return ret;
|
||||
}
|
||||
|
||||
void Tunnel::PrintHops (std::stringstream& s) const
|
||||
{
|
||||
for (auto& it: m_Hops)
|
||||
{
|
||||
s << "-->";
|
||||
s << i2p::data::GetIdentHashAbbreviation (it->ident->GetIdentHash ());
|
||||
}
|
||||
}
|
||||
|
||||
void InboundTunnel::HandleTunnelDataMsg (std::shared_ptr<const I2NPMessage> msg)
|
||||
{
|
||||
if (IsFailed ()) SetState (eTunnelStateEstablished); // incoming messages means a tunnel is alive
|
||||
|
@ -193,9 +202,8 @@ namespace tunnel
|
|||
|
||||
void InboundTunnel::Print (std::stringstream& s) const
|
||||
{
|
||||
s << "-->" << i2p::data::GetIdentHashAbbreviation (GetNextIdentHash ()) << ":" << GetNextTunnelID ();
|
||||
s << "-->" << (GetNumHops () - 1) << " hops ";
|
||||
s << GetTunnelID () << ":me";
|
||||
PrintHops (s);
|
||||
s << "-->" << GetTunnelID () << ":me";
|
||||
}
|
||||
|
||||
void OutboundTunnel::SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, std::shared_ptr<i2p::I2NPMessage> msg)
|
||||
|
@ -235,8 +243,9 @@ namespace tunnel
|
|||
|
||||
void OutboundTunnel::Print (std::stringstream& s) const
|
||||
{
|
||||
s << "me-->" << i2p::data::GetIdentHashAbbreviation (GetNextIdentHash ()) << ":" << GetNextTunnelID ();
|
||||
s << "-->" << (GetNumHops () - 1) << " hops-->";
|
||||
s << GetTunnelID () << ":me";
|
||||
PrintHops (s);
|
||||
s << "-->";
|
||||
}
|
||||
|
||||
Tunnels tunnels;
|
||||
|
|
5
Tunnel.h
5
Tunnel.h
|
@ -62,7 +62,6 @@ namespace tunnel
|
|||
std::vector<std::shared_ptr<const i2p::data::IdentityEx> > GetInvertedPeers () const;
|
||||
TunnelState GetState () const { return m_State; };
|
||||
void SetState (TunnelState state) { m_State = state; };
|
||||
int GetNumHops () const { return m_Hops.size (); }
|
||||
bool IsEstablished () const { return m_State == eTunnelStateEstablished; };
|
||||
bool IsFailed () const { return m_State == eTunnelStateFailed; };
|
||||
bool IsRecreated () const { return m_IsRecreated; };
|
||||
|
@ -77,6 +76,10 @@ namespace tunnel
|
|||
void SendTunnelDataMsg (std::shared_ptr<i2p::I2NPMessage> msg);
|
||||
void EncryptTunnelMsg (std::shared_ptr<const I2NPMessage> in, std::shared_ptr<I2NPMessage> out);
|
||||
|
||||
protected:
|
||||
|
||||
void PrintHops (std::stringstream& s) const;
|
||||
|
||||
private:
|
||||
|
||||
std::shared_ptr<const TunnelConfig> m_Config;
|
||||
|
|
|
@ -195,25 +195,6 @@ namespace tunnel
|
|||
return peers;
|
||||
}
|
||||
|
||||
void Print (std::stringstream& s) const
|
||||
{
|
||||
TunnelHopConfig * hop = m_FirstHop;
|
||||
if (!IsInbound ()) // outbound
|
||||
s << "me";
|
||||
s << "-->" << m_FirstHop->tunnelID;
|
||||
while (hop)
|
||||
{
|
||||
s << ":" << GetIdentHashAbbreviation (hop->ident->GetIdentHash ()) << "-->";
|
||||
if (!hop->isEndpoint)
|
||||
s << hop->nextTunnelID;
|
||||
else
|
||||
return;
|
||||
hop = hop->next;
|
||||
}
|
||||
// we didn't reach enpoint that mean we are last hop
|
||||
s << ":me";
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// this constructor can't be called from outside
|
||||
|
|
Loading…
Reference in a new issue