Browse Source

show number sent/received bytes through the status page

pull/93/head
orignal 11 years ago
parent
commit
756a920c1a
  1. 2
      HTTPServer.cpp
  2. 10
      NTCPSession.cpp
  3. 5
      NTCPSession.h
  4. 7
      SSU.cpp
  5. 6
      SSU.h

2
HTTPServer.cpp

@ -303,6 +303,7 @@ namespace util @@ -303,6 +303,7 @@ namespace util
s << it.second->GetRemoteRouterInfo ().GetIdentHashAbbreviation () << ": "
<< it.second->GetSocket ().remote_endpoint().address ().to_string ();
if (!outgoing) s << "-->";
s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]";
s << "<BR>";
}
}
@ -318,6 +319,7 @@ namespace util @@ -318,6 +319,7 @@ namespace util
if (outgoing) s << "-->";
s << endpoint.address ().to_string () << ":" << endpoint.port ();
if (!outgoing) s << "-->";
s << " [" << it.second->GetNumSentBytes () << ":" << it.second->GetNumReceivedBytes () << "]";
s << "<BR>";
}
}

10
NTCPSession.cpp

@ -21,15 +21,15 @@ namespace ntcp @@ -21,15 +21,15 @@ namespace ntcp
{
NTCPSession::NTCPSession (boost::asio::io_service& service, i2p::data::RouterInfo& in_RemoteRouterInfo):
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 ();
}
NTCPSession::~NTCPSession ()
{
delete m_DHKeysPair;
delete m_NextMessage;
}
void NTCPSession::CreateAESKey (uint8_t * pubKey, uint8_t * aesKey)
@ -403,7 +403,7 @@ namespace ntcp @@ -403,7 +403,7 @@ namespace ntcp
}
else
{
LogPrint ("Received: ", bytes_transferred);
m_NumReceivedBytes += bytes_transferred;
m_ReceiveBufferOffset += bytes_transferred;
if (m_ReceiveBufferOffset >= 16)
@ -514,7 +514,7 @@ namespace ntcp @@ -514,7 +514,7 @@ namespace ntcp
}
else
{
LogPrint ("Msg sent: ", bytes_transferred);
m_NumSentBytes += bytes_transferred;
ScheduleTermination (); // reset termination timer
}
}

5
NTCPSession.h

@ -78,6 +78,9 @@ namespace ntcp @@ -78,6 +78,9 @@ namespace ntcp
void ClientLogin ();
void ServerLogin ();
void SendI2NPMessage (I2NPMessage * msg);
size_t GetNumSentBytes () const { return m_NumSentBytes; };
size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; };
protected:
@ -142,6 +145,8 @@ namespace ntcp @@ -142,6 +145,8 @@ namespace ntcp
i2p::I2NPMessage * m_NextMessage;
std::list<i2p::I2NPMessage *> m_DelayedMessages;
size_t m_NextMessageOffset;
size_t m_NumSentBytes, m_NumReceivedBytes;
};
class NTCPClient: public NTCPSession

7
SSU.cpp

@ -19,7 +19,8 @@ namespace ssu @@ -19,7 +19,8 @@ namespace ssu
const i2p::data::RouterInfo * router, bool peerTest ):
m_Server (server), m_RemoteEndpoint (remoteEndpoint), m_RemoteRouter (router),
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 ();
}
@ -74,6 +75,7 @@ namespace ssu @@ -74,6 +75,7 @@ namespace ssu
void SSUSession::ProcessNextMessage (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint)
{
m_NumReceivedBytes += len;
if (m_State == eSessionStateIntroduced)
{
// HolePunch received
@ -842,6 +844,7 @@ namespace ssu @@ -842,6 +844,7 @@ namespace ssu
void SSUSession::Send (const uint8_t * buf, size_t size)
{
m_NumSentBytes += size;
m_Server.Send (buf, size, m_RemoteEndpoint);
}
@ -910,7 +913,6 @@ namespace ssu @@ -910,7 +913,6 @@ namespace ssu
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);
LogPrint ("SSU sent ", len, " bytes");
}
void SSUServer::Receive ()
@ -923,7 +925,6 @@ namespace ssu @@ -923,7 +925,6 @@ namespace ssu
{
if (!ecode)
{
LogPrint ("SSU received ", bytes_transferred, " bytes");
SSUSession * session = nullptr;
auto it = m_Sessions.find (m_SenderEndpoint);
if (it != m_Sessions.end ())

6
SSU.h

@ -73,7 +73,10 @@ namespace ssu @@ -73,7 +73,10 @@ namespace ssu
void SendPeerTest (); // Alice
SessionState GetState () const { return m_State; };
size_t GetNumSentBytes () const { return m_NumSentBytes; };
size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; };
private:
void CreateAESandMacKey (const uint8_t * pubKey);
@ -131,6 +134,7 @@ namespace ssu @@ -131,6 +134,7 @@ namespace ssu
std::list<i2p::I2NPMessage *> m_DelayedMessages;
std::set<IV> m_ReceivedIVs;
SSUData m_Data;
size_t m_NumSentBytes, m_NumReceivedBytes;
};
class SSUServer

Loading…
Cancel
Save