Browse Source

print full tunnel path

pull/308/head
orignal 9 years ago
parent
commit
badcd64b62
  1. 19
      Tunnel.cpp
  2. 7
      Tunnel.h
  3. 19
      TunnelConfig.h

19
Tunnel.cpp

@ -181,6 +181,15 @@ namespace tunnel @@ -181,6 +181,15 @@ namespace tunnel
ret.push_back (it->ident);
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)
{
@ -193,9 +202,8 @@ namespace tunnel @@ -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 @@ -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;

7
Tunnel.h

@ -62,7 +62,6 @@ namespace tunnel @@ -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; };
@ -76,7 +75,11 @@ namespace tunnel @@ -76,7 +75,11 @@ namespace tunnel
// implements TunnelBase
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;

19
TunnelConfig.h

@ -194,25 +194,6 @@ namespace tunnel @@ -194,25 +194,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:

Loading…
Cancel
Save