diff --git a/Profiling.cpp b/Profiling.cpp index fb45e0af..65eb1260 100644 --- a/Profiling.cpp +++ b/Profiling.cpp @@ -10,7 +10,8 @@ namespace i2p namespace data { RouterProfile::RouterProfile (const IdentHash& identHash): - m_IdentHash (identHash), m_NumTunnelsAgreed (0), m_NumTunnelsDeclined (0) + m_IdentHash (identHash), m_NumTunnelsAgreed (0), m_NumTunnelsDeclined (0), + m_NumTunnelsNonReplied (0) { } @@ -20,6 +21,7 @@ namespace data boost::property_tree::ptree participation; participation.put (PEER_PROFILE_PARTICIPATION_AGREED, m_NumTunnelsAgreed); participation.put (PEER_PROFILE_PARTICIPATION_DECLINED, m_NumTunnelsDeclined); + participation.put (PEER_PROFILE_PARTICIPATION_NON_REPLIED, m_NumTunnelsNonReplied); // fill property tree boost::property_tree::ptree pt; pt.put_child (PEER_PROFILE_SECTION_PARTICIPATION, participation); @@ -82,6 +84,7 @@ namespace data auto participations = pt.get_child (PEER_PROFILE_SECTION_PARTICIPATION); m_NumTunnelsAgreed = participations.get (PEER_PROFILE_PARTICIPATION_AGREED, 0); m_NumTunnelsDeclined = participations.get (PEER_PROFILE_PARTICIPATION_DECLINED, 0); + m_NumTunnelsNonReplied = participations.get (PEER_PROFILE_PARTICIPATION_NON_REPLIED, 0); } catch (std::exception& ex) { @@ -97,6 +100,11 @@ namespace data else m_NumTunnelsAgreed++; } + + void RouterProfile::TunnelNonReplied () + { + m_NumTunnelsNonReplied++; + } std::shared_ptr GetRouterProfile (const IdentHash& identHash) { diff --git a/Profiling.h b/Profiling.h index 2f9d80c5..f130e1e1 100644 --- a/Profiling.h +++ b/Profiling.h @@ -15,6 +15,7 @@ namespace data // params const char PEER_PROFILE_PARTICIPATION_AGREED[] = "agreed"; const char PEER_PROFILE_PARTICIPATION_DECLINED[] = "declined"; + const char PEER_PROFILE_PARTICIPATION_NON_REPLIED[] = "nonreplied"; class RouterProfile { @@ -28,13 +29,15 @@ namespace data bool IsBad () const { return !m_NumTunnelsAgreed && m_NumTunnelsDeclined >= 5; }; void TunnelBuildResponse (uint8_t ret); + void TunnelNonReplied (); private: IdentHash m_IdentHash; // participation uint32_t m_NumTunnelsAgreed; - uint32_t m_NumTunnelsDeclined; + uint32_t m_NumTunnelsDeclined; + uint32_t m_NumTunnelsNonReplied; }; std::shared_ptr GetRouterProfile (const IdentHash& identHash); diff --git a/Tunnel.cpp b/Tunnel.cpp index 4852c7bd..110446b4 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -489,6 +489,19 @@ namespace tunnel if (ts > tunnel->GetCreationTime () + TUNNEL_CREATION_TIMEOUT) { LogPrint ("Pending tunnel build request ", it->first, " timeout. Deleted"); + // update stats + auto config = tunnel->GetTunnelConfig (); + if (config) + { + auto hop = config->GetFirstHop (); + while (hop) + { + if (hop->router) + hop->router->GetProfile ()->TunnelNonReplied (); + hop = hop->next; + } + } + // delete it = pendingTunnels.erase (it); m_NumFailedTunnelCreations++; }