mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
show total send/received bytes
This commit is contained in:
parent
a72d7652af
commit
028e3a6c35
|
@ -660,6 +660,8 @@ namespace util
|
|||
}
|
||||
s << "<br>";
|
||||
s << "<b>Tunnel creation success rate:</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>";
|
||||
s << "<b>Received:</b> " << i2p::transport::transports.GetTotalReceivedBytes ()/1000 << "K<br>";
|
||||
s << "<b>Sent:</b> " << i2p::transport::transports.GetTotalSentBytes ()/1000 << "K<br>";
|
||||
s << "<b>Data path:</b> " << i2p::util::filesystem::GetDataDir().string() << "<br><br>";
|
||||
s << "<b>Our external address:</b>" << "<br>" ;
|
||||
for (auto& address : i2p::context.GetRouterInfo().GetAddresses())
|
||||
|
|
|
@ -496,6 +496,7 @@ namespace transport
|
|||
else
|
||||
{
|
||||
m_NumReceivedBytes += bytes_transferred;
|
||||
i2p::transport::transports.UpdateReceivedBytes (bytes_transferred);
|
||||
m_ReceiveBufferOffset += bytes_transferred;
|
||||
|
||||
if (m_ReceiveBufferOffset >= 16)
|
||||
|
@ -661,6 +662,7 @@ namespace transport
|
|||
else
|
||||
{
|
||||
m_NumSentBytes += bytes_transferred;
|
||||
i2p::transport::transports.UpdateSentBytes (bytes_transferred);
|
||||
if (!m_SendQueue.empty())
|
||||
{
|
||||
Send (m_SendQueue);
|
||||
|
|
|
@ -78,6 +78,7 @@ namespace transport
|
|||
void SSUSession::ProcessNextMessage (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint)
|
||||
{
|
||||
m_NumReceivedBytes += len;
|
||||
i2p::transport::transports.UpdateReceivedBytes (len);
|
||||
if (m_State == eSessionStateIntroduced)
|
||||
{
|
||||
// HolePunch received
|
||||
|
@ -1107,6 +1108,7 @@ namespace transport
|
|||
void SSUSession::Send (const uint8_t * buf, size_t size)
|
||||
{
|
||||
m_NumSentBytes += size;
|
||||
i2p::transport::transports.UpdateSentBytes (size);
|
||||
m_Server.Send (buf, size, m_RemoteEndpoint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,8 +96,8 @@ namespace transport
|
|||
|
||||
Transports::Transports ():
|
||||
m_IsRunning (false), m_Thread (nullptr), m_Work (m_Service), m_PeerCleanupTimer (m_Service),
|
||||
m_NTCPServer (nullptr), m_SSUServer (nullptr),
|
||||
m_DHKeysPairSupplier (5) // 5 pre-generated keys
|
||||
m_NTCPServer (nullptr), m_SSUServer (nullptr), m_DHKeysPairSupplier (5), // 5 pre-generated keys
|
||||
m_TotalSentBytes(0), m_TotalReceivedBytes(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <queue>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <atomic>
|
||||
#include <cryptopp/osrng.h>
|
||||
#include <boost/asio.hpp>
|
||||
#include "TransportSession.h"
|
||||
|
@ -87,6 +88,11 @@ namespace transport
|
|||
|
||||
void PeerConnected (std::shared_ptr<TransportSession> session);
|
||||
void PeerDisconnected (std::shared_ptr<TransportSession> session);
|
||||
|
||||
void UpdateSentBytes (uint64_t numBytes) { m_TotalSentBytes += numBytes; };
|
||||
void UpdateReceivedBytes (uint64_t numBytes) { m_TotalReceivedBytes += numBytes; };
|
||||
uint64_t GetTotalSentBytes () const { return m_TotalSentBytes; };
|
||||
uint64_t GetTotalReceivedBytes () const { return m_TotalReceivedBytes; };
|
||||
|
||||
private:
|
||||
|
||||
|
@ -118,7 +124,8 @@ namespace transport
|
|||
std::map<i2p::data::IdentHash, Peer> m_Peers;
|
||||
|
||||
DHKeysPairSupplier m_DHKeysPairSupplier;
|
||||
|
||||
std::atomic<uint64_t> m_TotalSentBytes, m_TotalReceivedBytes;
|
||||
|
||||
public:
|
||||
|
||||
// for HTTP only
|
||||
|
|
Loading…
Reference in a new issue