mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
show number sent/received bytes through the status page
This commit is contained in:
parent
d7bcaaa3f7
commit
756a920c1a
@ -303,6 +303,7 @@ namespace util
|
|||||||
s << it.second->GetRemoteRouterInfo ().GetIdentHashAbbreviation () << ": "
|
s << it.second->GetRemoteRouterInfo ().GetIdentHashAbbreviation () << ": "
|
||||||
<< it.second->GetSocket ().remote_endpoint().address ().to_string ();
|
<< it.second->GetSocket ().remote_endpoint().address ().to_string ();
|
||||||
if (!outgoing) s << "-->";
|
if (!outgoing) s << "-->";
|
||||||
|
s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]";
|
||||||
s << "<BR>";
|
s << "<BR>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,6 +319,7 @@ namespace util
|
|||||||
if (outgoing) s << "-->";
|
if (outgoing) s << "-->";
|
||||||
s << endpoint.address ().to_string () << ":" << endpoint.port ();
|
s << endpoint.address ().to_string () << ":" << endpoint.port ();
|
||||||
if (!outgoing) s << "-->";
|
if (!outgoing) s << "-->";
|
||||||
|
s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]";
|
||||||
s << "<BR>";
|
s << "<BR>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,8 @@ namespace ntcp
|
|||||||
{
|
{
|
||||||
NTCPSession::NTCPSession (boost::asio::io_service& service, i2p::data::RouterInfo& in_RemoteRouterInfo):
|
NTCPSession::NTCPSession (boost::asio::io_service& service, i2p::data::RouterInfo& in_RemoteRouterInfo):
|
||||||
m_Socket (service), m_TerminationTimer (service), m_IsEstablished (false),
|
m_Socket (service), m_TerminationTimer (service), m_IsEstablished (false),
|
||||||
m_RemoteRouterInfo (in_RemoteRouterInfo), m_ReceiveBufferOffset (0), m_NextMessage (nullptr)
|
m_RemoteRouterInfo (in_RemoteRouterInfo), m_ReceiveBufferOffset (0), m_NextMessage (nullptr),
|
||||||
|
m_NumSentBytes (0), m_NumReceivedBytes (0)
|
||||||
{
|
{
|
||||||
m_DHKeysPair = i2p::transports.GetNextDHKeysPair ();
|
m_DHKeysPair = i2p::transports.GetNextDHKeysPair ();
|
||||||
}
|
}
|
||||||
@ -29,7 +30,6 @@ namespace ntcp
|
|||||||
NTCPSession::~NTCPSession ()
|
NTCPSession::~NTCPSession ()
|
||||||
{
|
{
|
||||||
delete m_DHKeysPair;
|
delete m_DHKeysPair;
|
||||||
delete m_NextMessage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NTCPSession::CreateAESKey (uint8_t * pubKey, uint8_t * aesKey)
|
void NTCPSession::CreateAESKey (uint8_t * pubKey, uint8_t * aesKey)
|
||||||
@ -403,7 +403,7 @@ namespace ntcp
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint ("Received: ", bytes_transferred);
|
m_NumReceivedBytes += bytes_transferred;
|
||||||
m_ReceiveBufferOffset += bytes_transferred;
|
m_ReceiveBufferOffset += bytes_transferred;
|
||||||
|
|
||||||
if (m_ReceiveBufferOffset >= 16)
|
if (m_ReceiveBufferOffset >= 16)
|
||||||
@ -514,7 +514,7 @@ namespace ntcp
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint ("Msg sent: ", bytes_transferred);
|
m_NumSentBytes += bytes_transferred;
|
||||||
ScheduleTermination (); // reset termination timer
|
ScheduleTermination (); // reset termination timer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,9 @@ namespace ntcp
|
|||||||
void ServerLogin ();
|
void ServerLogin ();
|
||||||
void SendI2NPMessage (I2NPMessage * msg);
|
void SendI2NPMessage (I2NPMessage * msg);
|
||||||
|
|
||||||
|
size_t GetNumSentBytes () const { return m_NumSentBytes; };
|
||||||
|
size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void Terminate ();
|
void Terminate ();
|
||||||
@ -142,6 +145,8 @@ namespace ntcp
|
|||||||
i2p::I2NPMessage * m_NextMessage;
|
i2p::I2NPMessage * m_NextMessage;
|
||||||
std::list<i2p::I2NPMessage *> m_DelayedMessages;
|
std::list<i2p::I2NPMessage *> m_DelayedMessages;
|
||||||
size_t m_NextMessageOffset;
|
size_t m_NextMessageOffset;
|
||||||
|
|
||||||
|
size_t m_NumSentBytes, m_NumReceivedBytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NTCPClient: public NTCPSession
|
class NTCPClient: public NTCPSession
|
||||||
|
7
SSU.cpp
7
SSU.cpp
@ -19,7 +19,8 @@ namespace ssu
|
|||||||
const i2p::data::RouterInfo * router, bool peerTest ):
|
const i2p::data::RouterInfo * router, bool peerTest ):
|
||||||
m_Server (server), m_RemoteEndpoint (remoteEndpoint), m_RemoteRouter (router),
|
m_Server (server), m_RemoteEndpoint (remoteEndpoint), m_RemoteRouter (router),
|
||||||
m_Timer (m_Server.GetService ()), m_PeerTest (peerTest), m_State (eSessionStateUnknown),
|
m_Timer (m_Server.GetService ()), m_PeerTest (peerTest), m_State (eSessionStateUnknown),
|
||||||
m_IsSessionKey (false), m_RelayTag (0), m_Data (*this)
|
m_IsSessionKey (false), m_RelayTag (0), m_Data (*this),
|
||||||
|
m_NumSentBytes (0), m_NumReceivedBytes (0)
|
||||||
{
|
{
|
||||||
m_DHKeysPair = i2p::transports.GetNextDHKeysPair ();
|
m_DHKeysPair = i2p::transports.GetNextDHKeysPair ();
|
||||||
}
|
}
|
||||||
@ -74,6 +75,7 @@ namespace ssu
|
|||||||
|
|
||||||
void SSUSession::ProcessNextMessage (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint)
|
void SSUSession::ProcessNextMessage (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint)
|
||||||
{
|
{
|
||||||
|
m_NumReceivedBytes += len;
|
||||||
if (m_State == eSessionStateIntroduced)
|
if (m_State == eSessionStateIntroduced)
|
||||||
{
|
{
|
||||||
// HolePunch received
|
// HolePunch received
|
||||||
@ -842,6 +844,7 @@ namespace ssu
|
|||||||
|
|
||||||
void SSUSession::Send (const uint8_t * buf, size_t size)
|
void SSUSession::Send (const uint8_t * buf, size_t size)
|
||||||
{
|
{
|
||||||
|
m_NumSentBytes += size;
|
||||||
m_Server.Send (buf, size, m_RemoteEndpoint);
|
m_Server.Send (buf, size, m_RemoteEndpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -910,7 +913,6 @@ namespace ssu
|
|||||||
void SSUServer::Send (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& to)
|
void SSUServer::Send (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& to)
|
||||||
{
|
{
|
||||||
m_Socket.send_to (boost::asio::buffer (buf, len), to);
|
m_Socket.send_to (boost::asio::buffer (buf, len), to);
|
||||||
LogPrint ("SSU sent ", len, " bytes");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUServer::Receive ()
|
void SSUServer::Receive ()
|
||||||
@ -923,7 +925,6 @@ namespace ssu
|
|||||||
{
|
{
|
||||||
if (!ecode)
|
if (!ecode)
|
||||||
{
|
{
|
||||||
LogPrint ("SSU received ", bytes_transferred, " bytes");
|
|
||||||
SSUSession * session = nullptr;
|
SSUSession * session = nullptr;
|
||||||
auto it = m_Sessions.find (m_SenderEndpoint);
|
auto it = m_Sessions.find (m_SenderEndpoint);
|
||||||
if (it != m_Sessions.end ())
|
if (it != m_Sessions.end ())
|
||||||
|
4
SSU.h
4
SSU.h
@ -73,6 +73,9 @@ namespace ssu
|
|||||||
void SendPeerTest (); // Alice
|
void SendPeerTest (); // Alice
|
||||||
|
|
||||||
SessionState GetState () const { return m_State; };
|
SessionState GetState () const { return m_State; };
|
||||||
|
size_t GetNumSentBytes () const { return m_NumSentBytes; };
|
||||||
|
size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; };
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -131,6 +134,7 @@ namespace ssu
|
|||||||
std::list<i2p::I2NPMessage *> m_DelayedMessages;
|
std::list<i2p::I2NPMessage *> m_DelayedMessages;
|
||||||
std::set<IV> m_ReceivedIVs;
|
std::set<IV> m_ReceivedIVs;
|
||||||
SSUData m_Data;
|
SSUData m_Data;
|
||||||
|
size_t m_NumSentBytes, m_NumReceivedBytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SSUServer
|
class SSUServer
|
||||||
|
Loading…
Reference in New Issue
Block a user