diff --git a/Destination.h b/Destination.h index c9fd4ee6..62dc527c 100644 --- a/Destination.h +++ b/Destination.h @@ -86,6 +86,7 @@ namespace stream public: // for HTTP only + int GetNumRemoteLeaseSets () const { return m_RemoteLeaseSets.size (); }; const decltype(m_Streams)& GetStreams () const { return m_Streams; }; }; diff --git a/HTTPServer.cpp b/HTTPServer.cpp index dfca5ee8..7a94468f 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -795,6 +795,7 @@ namespace util auto dest = i2p::stream::FindLocalDestination (ident); if (dest) { + s << "LeaseSets: " << dest->GetNumRemoteLeaseSets () << "
"; auto pool = dest->GetTunnelPool (); if (pool) { @@ -812,7 +813,11 @@ namespace util } s << "
Streams:
"; for (auto it: dest->GetStreams ()) - s << it.first << "->" << it.second->GetRemoteIdentity ().GetIdentHash ().ToBase32 () << ".b32.i2p
" << std::endl; + { + s << it.first << "->" << it.second->GetRemoteIdentity ().GetIdentHash ().ToBase32 () << ".b32.i2p "; + s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]"; + s << "
"<< std::endl; + } } } diff --git a/Streaming.cpp b/Streaming.cpp index a7a21658..65796ba0 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -15,7 +15,8 @@ namespace stream m_SequenceNumber (0), m_LastReceivedSequenceNumber (-1), m_IsOpen (false), m_IsReset (false), m_IsAckSendScheduled (false), m_LocalDestination (local), m_RemoteLeaseSet (&remote), m_RoutingSession (nullptr), m_ReceiveTimer (m_Service), - m_ResendTimer (m_Service), m_AckSendTimer (m_Service) + m_ResendTimer (m_Service), m_AckSendTimer (m_Service), m_NumSentBytes (0), + m_NumReceivedBytes (0) { m_RecvStreamID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 (); UpdateCurrentRemoteLease (); @@ -25,7 +26,8 @@ namespace stream m_Service (service), m_SendStreamID (0), m_SequenceNumber (0), m_LastReceivedSequenceNumber (-1), m_IsOpen (false), m_IsReset (false), m_IsAckSendScheduled (false), m_LocalDestination (local), m_RemoteLeaseSet (nullptr), m_RoutingSession (nullptr), m_ReceiveTimer (m_Service), - m_ResendTimer (m_Service), m_AckSendTimer (m_Service) + m_ResendTimer (m_Service), m_AckSendTimer (m_Service), m_NumSentBytes (0), + m_NumReceivedBytes (0) { m_RecvStreamID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 (); } @@ -55,6 +57,7 @@ namespace stream void Stream::HandleNextPacket (Packet * packet) { + m_NumReceivedBytes += packet->GetLength (); if (!m_SendStreamID) m_SendStreamID = packet->GetReceiveStreamID (); @@ -442,6 +445,7 @@ namespace stream m_CurrentRemoteLease.tunnelGateway, m_CurrentRemoteLease.tunnelID, msg }); + m_NumSentBytes += it->GetLength (); } m_LocalDestination.SendTunnelDataMsgs (msgs); } diff --git a/Streaming.h b/Streaming.h index 80153ae5..40312464 100644 --- a/Streaming.h +++ b/Streaming.h @@ -97,7 +97,10 @@ namespace stream void AsyncReceive (const Buffer& buffer, ReceiveHandler handler, int timeout = 0); void Close (); - + + size_t GetNumSentBytes () const { return m_NumSentBytes; }; + size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; }; + private: void SendQuickAck (); @@ -133,6 +136,7 @@ namespace stream std::set m_SavedPackets; std::set m_SentPackets; boost::asio::deadline_timer m_ReceiveTimer, m_ResendTimer, m_AckSendTimer; + size_t m_NumSentBytes, m_NumReceivedBytes; }; //-------------------------------------------------