Browse Source

moved remote RI and identity to TransportSession

pull/105/head
orignal 10 years ago
parent
commit
6281fa625a
  1. 6
      NTCPSession.cpp
  2. 7
      NTCPSession.h
  3. 10
      SSU.cpp
  4. 3
      SSU.h
  5. 15
      TransportSession.h

6
NTCPSession.cpp

@ -20,12 +20,10 @@ namespace i2p @@ -20,12 +20,10 @@ namespace i2p
namespace transport
{
NTCPSession::NTCPSession (boost::asio::io_service& service, const i2p::data::RouterInfo * in_RemoteRouter):
m_Socket (service), m_TerminationTimer (service), m_IsEstablished (false),
m_RemoteRouter (in_RemoteRouter), m_ReceiveBufferOffset (0),
TransportSession (in_RemoteRouter), m_Socket (service),
m_TerminationTimer (service), m_IsEstablished (false), m_ReceiveBufferOffset (0),
m_NextMessage (nullptr), m_NumSentBytes (0), m_NumReceivedBytes (0)
{
if (m_RemoteRouter)
m_RemoteIdentity = m_RemoteRouter->GetRouterIdentity ();
m_DHKeysPair = transports.GetNextDHKeysPair ();
m_Establisher = new Establisher;
}

7
NTCPSession.h

@ -72,12 +72,10 @@ namespace transport @@ -72,12 +72,10 @@ namespace transport
public:
NTCPSession (boost::asio::io_service& service, const i2p::data::RouterInfo * in_RemoteRouter = nullptr);
virtual ~NTCPSession ();
~NTCPSession ();
boost::asio::ip::tcp::socket& GetSocket () { return m_Socket; };
bool IsEstablished () const { return m_IsEstablished; };
const i2p::data::RouterInfo * GetRemoteRouter () { return m_RemoteRouter; };
const i2p::data::IdentityEx& GetRemoteIdentity () { return m_RemoteIdentity; };
void ClientLogin ();
void ServerLogin ();
@ -134,9 +132,6 @@ namespace transport @@ -134,9 +132,6 @@ namespace transport
i2p::crypto::CBCDecryption m_Decryption;
i2p::crypto::CBCEncryption m_Encryption;
CryptoPP::Adler32 m_Adler;
const i2p::data::RouterInfo * m_RemoteRouter;
i2p::data::IdentityEx m_RemoteIdentity;
struct Establisher
{

10
SSU.cpp

@ -16,8 +16,8 @@ namespace transport @@ -16,8 +16,8 @@ namespace transport
{
SSUSession::SSUSession (SSUServer& server, boost::asio::ip::udp::endpoint& remoteEndpoint,
const i2p::data::RouterInfo * router, bool peerTest ):
m_Server (server), m_RemoteEndpoint (remoteEndpoint), m_RemoteRouter (router),
const i2p::data::RouterInfo * router, bool peerTest ): TransportSession (router),
m_Server (server), m_RemoteEndpoint (remoteEndpoint),
m_Timer (m_Server.GetService ()), m_PeerTest (peerTest),
m_State (eSessionStateUnknown), m_IsSessionKey (false), m_RelayTag (0),
m_Data (*this), m_NumSentBytes (0), m_NumReceivedBytes (0)
@ -232,10 +232,8 @@ namespace transport @@ -232,10 +232,8 @@ namespace transport
payload += 2; // size of identity fragment
if (identitySize == i2p::data::DEFAULT_IDENTITY_SIZE)
{
i2p::data::Identity ident;
ident.FromBuffer (payload, identitySize);
m_RemoteIdent = ident.Hash ();
m_Data.UpdatePacketSize (m_RemoteIdent);
m_RemoteIdentity.FromBuffer (payload, identitySize);
m_Data.UpdatePacketSize (m_RemoteIdentity.GetIdentHash ());
}
else
LogPrint ("SSU unexpected identity size ", identitySize);

3
SSU.h

@ -72,7 +72,6 @@ namespace transport @@ -72,7 +72,6 @@ namespace transport
void WaitForIntroduction ();
void Close ();
boost::asio::ip::udp::endpoint& GetRemoteEndpoint () { return m_RemoteEndpoint; };
const i2p::data::RouterInfo * GetRemoteRouter () const { return m_RemoteRouter; };
void SendI2NPMessage (I2NPMessage * msg);
void SendPeerTest (); // Alice
@ -129,8 +128,6 @@ namespace transport @@ -129,8 +128,6 @@ namespace transport
friend class SSUData; // TODO: change in later
SSUServer& m_Server;
boost::asio::ip::udp::endpoint m_RemoteEndpoint;
const i2p::data::RouterInfo * m_RemoteRouter;
i2p::data::IdentHash m_RemoteIdent; // if m_RemoteRouter is null
boost::asio::deadline_timer m_Timer;
bool m_PeerTest;
SessionState m_State;

15
TransportSession.h

@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
#define TRANSPORT_SESSION_H__
#include <inttypes.h>
#include "Identity.h"
#include "RouterInfo.h"
namespace i2p
{
@ -17,11 +19,22 @@ namespace transport @@ -17,11 +19,22 @@ namespace transport
{
public:
TransportSession (): m_DHKeysPair (nullptr) {};
TransportSession (const i2p::data::RouterInfo * in_RemoteRouter):
m_RemoteRouter (in_RemoteRouter), m_DHKeysPair (nullptr)
{
if (m_RemoteRouter)
m_RemoteIdentity = m_RemoteRouter->GetRouterIdentity ();
}
virtual ~TransportSession () { delete m_DHKeysPair; };
const i2p::data::RouterInfo * GetRemoteRouter () { return m_RemoteRouter; };
const i2p::data::IdentityEx& GetRemoteIdentity () { return m_RemoteIdentity; };
protected:
const i2p::data::RouterInfo * m_RemoteRouter;
i2p::data::IdentityEx m_RemoteIdentity;
DHKeysPair * m_DHKeysPair; // X - for client and Y - for server
};
}

Loading…
Cancel
Save