Browse Source

moved num sent/received bytes to TransportSession

pull/164/head
orignal 10 years ago
parent
commit
a72d7652af
  1. 3
      NTCPSession.cpp
  2. 4
      NTCPSession.h
  3. 4
      SSUSession.cpp
  4. 1
      SSUSession.h
  5. 7
      TransportSession.h

3
NTCPSession.cpp

@ -21,8 +21,7 @@ namespace transport
NTCPSession::NTCPSession (NTCPServer& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter): NTCPSession::NTCPSession (NTCPServer& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter):
TransportSession (in_RemoteRouter), m_Server (server), m_Socket (m_Server.GetService ()), TransportSession (in_RemoteRouter), m_Server (server), m_Socket (m_Server.GetService ()),
m_TerminationTimer (m_Server.GetService ()), m_IsEstablished (false), m_IsTerminated (false), m_TerminationTimer (m_Server.GetService ()), m_IsEstablished (false), m_IsTerminated (false),
m_ReceiveBufferOffset (0), m_NextMessage (nullptr), m_IsSending (false), m_ReceiveBufferOffset (0), m_NextMessage (nullptr), m_IsSending (false)
m_NumSentBytes (0), m_NumReceivedBytes (0)
{ {
m_DHKeysPair = transports.GetNextDHKeysPair (); m_DHKeysPair = transports.GetNextDHKeysPair ();
m_Establisher = new Establisher; m_Establisher = new Establisher;

4
NTCPSession.h

@ -64,9 +64,6 @@ namespace transport
void ServerLogin (); void ServerLogin ();
void SendI2NPMessage (I2NPMessage * msg); void SendI2NPMessage (I2NPMessage * msg);
void SendI2NPMessages (const std::vector<I2NPMessage *>& msgs); void SendI2NPMessages (const std::vector<I2NPMessage *>& msgs);
size_t GetNumSentBytes () const { return m_NumSentBytes; };
size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; };
private: private:
@ -138,7 +135,6 @@ namespace transport
bool m_IsSending; bool m_IsSending;
std::vector<I2NPMessage *> m_SendQueue; std::vector<I2NPMessage *> m_SendQueue;
size_t m_NumSentBytes, m_NumReceivedBytes;
boost::asio::ip::address m_ConnectedFrom; // for ban boost::asio::ip::address m_ConnectedFrom; // for ban
}; };

4
SSUSession.cpp

@ -16,8 +16,8 @@ namespace transport
SSUSession::SSUSession (SSUServer& server, boost::asio::ip::udp::endpoint& remoteEndpoint, SSUSession::SSUSession (SSUServer& server, boost::asio::ip::udp::endpoint& remoteEndpoint,
std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest ): TransportSession (router), std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest ): TransportSession (router),
m_Server (server), m_RemoteEndpoint (remoteEndpoint), m_Timer (GetService ()), m_Server (server), m_RemoteEndpoint (remoteEndpoint), m_Timer (GetService ()),
m_PeerTest (peerTest),m_State (eSessionStateUnknown), m_IsSessionKey (false), m_RelayTag (0), m_PeerTest (peerTest),m_State (eSessionStateUnknown), m_IsSessionKey (false),
m_NumSentBytes (0), m_NumReceivedBytes (0), m_Data (*this), m_IsDataReceived (false) m_RelayTag (0),m_Data (*this), m_IsDataReceived (false)
{ {
m_CreationTime = i2p::util::GetSecondsSinceEpoch (); m_CreationTime = i2p::util::GetSecondsSinceEpoch ();
} }

1
SSUSession.h

@ -146,7 +146,6 @@ namespace transport
i2p::crypto::CBCDecryption m_SessionKeyDecryption; i2p::crypto::CBCDecryption m_SessionKeyDecryption;
i2p::crypto::AESKey m_SessionKey; i2p::crypto::AESKey m_SessionKey;
i2p::crypto::MACKey m_MacKey; i2p::crypto::MACKey m_MacKey;
size_t m_NumSentBytes, m_NumReceivedBytes;
uint32_t m_CreationTime; // seconds since epoch uint32_t m_CreationTime; // seconds since epoch
SSUData m_Data; SSUData m_Data;
bool m_IsDataReceived; bool m_IsDataReceived;

7
TransportSession.h

@ -55,7 +55,8 @@ namespace transport
public: public:
TransportSession (std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter): TransportSession (std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter):
m_RemoteRouter (in_RemoteRouter), m_DHKeysPair (nullptr) m_RemoteRouter (in_RemoteRouter), m_DHKeysPair (nullptr),
m_NumSentBytes (0), m_NumReceivedBytes (0)
{ {
if (m_RemoteRouter) if (m_RemoteRouter)
m_RemoteIdentity = m_RemoteRouter->GetRouterIdentity (); m_RemoteIdentity = m_RemoteRouter->GetRouterIdentity ();
@ -67,6 +68,9 @@ namespace transport
std::shared_ptr<const i2p::data::RouterInfo> GetRemoteRouter () { return m_RemoteRouter; }; std::shared_ptr<const i2p::data::RouterInfo> GetRemoteRouter () { return m_RemoteRouter; };
const i2p::data::IdentityEx& GetRemoteIdentity () { return m_RemoteIdentity; }; const i2p::data::IdentityEx& GetRemoteIdentity () { return m_RemoteIdentity; };
size_t GetNumSentBytes () const { return m_NumSentBytes; };
size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; };
virtual void SendI2NPMessage (I2NPMessage * msg) = 0; virtual void SendI2NPMessage (I2NPMessage * msg) = 0;
virtual void SendI2NPMessages (const std::vector<I2NPMessage *>& msgs) = 0; virtual void SendI2NPMessages (const std::vector<I2NPMessage *>& msgs) = 0;
@ -75,6 +79,7 @@ namespace transport
std::shared_ptr<const i2p::data::RouterInfo> m_RemoteRouter; std::shared_ptr<const i2p::data::RouterInfo> m_RemoteRouter;
i2p::data::IdentityEx m_RemoteIdentity; i2p::data::IdentityEx m_RemoteIdentity;
DHKeysPair * m_DHKeysPair; // X - for client and Y - for server DHKeysPair * m_DHKeysPair; // X - for client and Y - for server
size_t m_NumSentBytes, m_NumReceivedBytes;
}; };
} }
} }

Loading…
Cancel
Save