From badcd64b621d62476a9e3612645fb6bce97abcf5 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 9 Dec 2015 19:07:12 -0500 Subject: [PATCH] print full tunnel path --- Tunnel.cpp | 19 ++++++++++++++----- Tunnel.h | 7 +++++-- TunnelConfig.h | 19 ------------------- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/Tunnel.cpp b/Tunnel.cpp index b899fdf7..0f1608f2 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -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 msg) { @@ -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 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; diff --git a/Tunnel.h b/Tunnel.h index 20e02c1b..daf0f054 100644 --- a/Tunnel.h +++ b/Tunnel.h @@ -62,7 +62,6 @@ namespace tunnel std::vector > 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 // implements TunnelBase void SendTunnelDataMsg (std::shared_ptr msg); void EncryptTunnelMsg (std::shared_ptr in, std::shared_ptr out); - + + protected: + + void PrintHops (std::stringstream& s) const; + private: std::shared_ptr m_Config; diff --git a/TunnelConfig.h b/TunnelConfig.h index d2164d86..1628b4b4 100644 --- a/TunnelConfig.h +++ b/TunnelConfig.h @@ -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: