mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-08 18:47:52 +00:00
moved remote RI and identity to TransportSession
This commit is contained in:
parent
c9abb62988
commit
6281fa625a
@ -20,12 +20,10 @@ namespace i2p
|
|||||||
namespace transport
|
namespace transport
|
||||||
{
|
{
|
||||||
NTCPSession::NTCPSession (boost::asio::io_service& service, const i2p::data::RouterInfo * in_RemoteRouter):
|
NTCPSession::NTCPSession (boost::asio::io_service& service, const i2p::data::RouterInfo * in_RemoteRouter):
|
||||||
m_Socket (service), m_TerminationTimer (service), m_IsEstablished (false),
|
TransportSession (in_RemoteRouter), m_Socket (service),
|
||||||
m_RemoteRouter (in_RemoteRouter), m_ReceiveBufferOffset (0),
|
m_TerminationTimer (service), m_IsEstablished (false), m_ReceiveBufferOffset (0),
|
||||||
m_NextMessage (nullptr), m_NumSentBytes (0), m_NumReceivedBytes (0)
|
m_NextMessage (nullptr), m_NumSentBytes (0), m_NumReceivedBytes (0)
|
||||||
{
|
{
|
||||||
if (m_RemoteRouter)
|
|
||||||
m_RemoteIdentity = m_RemoteRouter->GetRouterIdentity ();
|
|
||||||
m_DHKeysPair = transports.GetNextDHKeysPair ();
|
m_DHKeysPair = transports.GetNextDHKeysPair ();
|
||||||
m_Establisher = new Establisher;
|
m_Establisher = new Establisher;
|
||||||
}
|
}
|
||||||
|
@ -72,12 +72,10 @@ namespace transport
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
NTCPSession (boost::asio::io_service& service, const i2p::data::RouterInfo * in_RemoteRouter = nullptr);
|
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; };
|
boost::asio::ip::tcp::socket& GetSocket () { return m_Socket; };
|
||||||
bool IsEstablished () const { return m_IsEstablished; };
|
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 ClientLogin ();
|
||||||
void ServerLogin ();
|
void ServerLogin ();
|
||||||
@ -135,9 +133,6 @@ namespace transport
|
|||||||
i2p::crypto::CBCEncryption m_Encryption;
|
i2p::crypto::CBCEncryption m_Encryption;
|
||||||
CryptoPP::Adler32 m_Adler;
|
CryptoPP::Adler32 m_Adler;
|
||||||
|
|
||||||
const i2p::data::RouterInfo * m_RemoteRouter;
|
|
||||||
i2p::data::IdentityEx m_RemoteIdentity;
|
|
||||||
|
|
||||||
struct Establisher
|
struct Establisher
|
||||||
{
|
{
|
||||||
NTCPPhase1 phase1;
|
NTCPPhase1 phase1;
|
||||||
|
10
SSU.cpp
10
SSU.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,
|
||||||
const i2p::data::RouterInfo * router, bool peerTest ):
|
const i2p::data::RouterInfo * router, bool peerTest ): TransportSession (router),
|
||||||
m_Server (server), m_RemoteEndpoint (remoteEndpoint), m_RemoteRouter (router),
|
m_Server (server), m_RemoteEndpoint (remoteEndpoint),
|
||||||
m_Timer (m_Server.GetService ()), m_PeerTest (peerTest),
|
m_Timer (m_Server.GetService ()), m_PeerTest (peerTest),
|
||||||
m_State (eSessionStateUnknown), m_IsSessionKey (false), m_RelayTag (0),
|
m_State (eSessionStateUnknown), m_IsSessionKey (false), m_RelayTag (0),
|
||||||
m_Data (*this), m_NumSentBytes (0), m_NumReceivedBytes (0)
|
m_Data (*this), m_NumSentBytes (0), m_NumReceivedBytes (0)
|
||||||
@ -232,10 +232,8 @@ namespace transport
|
|||||||
payload += 2; // size of identity fragment
|
payload += 2; // size of identity fragment
|
||||||
if (identitySize == i2p::data::DEFAULT_IDENTITY_SIZE)
|
if (identitySize == i2p::data::DEFAULT_IDENTITY_SIZE)
|
||||||
{
|
{
|
||||||
i2p::data::Identity ident;
|
m_RemoteIdentity.FromBuffer (payload, identitySize);
|
||||||
ident.FromBuffer (payload, identitySize);
|
m_Data.UpdatePacketSize (m_RemoteIdentity.GetIdentHash ());
|
||||||
m_RemoteIdent = ident.Hash ();
|
|
||||||
m_Data.UpdatePacketSize (m_RemoteIdent);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint ("SSU unexpected identity size ", identitySize);
|
LogPrint ("SSU unexpected identity size ", identitySize);
|
||||||
|
3
SSU.h
3
SSU.h
@ -72,7 +72,6 @@ namespace transport
|
|||||||
void WaitForIntroduction ();
|
void WaitForIntroduction ();
|
||||||
void Close ();
|
void Close ();
|
||||||
boost::asio::ip::udp::endpoint& GetRemoteEndpoint () { return m_RemoteEndpoint; };
|
boost::asio::ip::udp::endpoint& GetRemoteEndpoint () { return m_RemoteEndpoint; };
|
||||||
const i2p::data::RouterInfo * GetRemoteRouter () const { return m_RemoteRouter; };
|
|
||||||
void SendI2NPMessage (I2NPMessage * msg);
|
void SendI2NPMessage (I2NPMessage * msg);
|
||||||
void SendPeerTest (); // Alice
|
void SendPeerTest (); // Alice
|
||||||
|
|
||||||
@ -129,8 +128,6 @@ namespace transport
|
|||||||
friend class SSUData; // TODO: change in later
|
friend class SSUData; // TODO: change in later
|
||||||
SSUServer& m_Server;
|
SSUServer& m_Server;
|
||||||
boost::asio::ip::udp::endpoint m_RemoteEndpoint;
|
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;
|
boost::asio::deadline_timer m_Timer;
|
||||||
bool m_PeerTest;
|
bool m_PeerTest;
|
||||||
SessionState m_State;
|
SessionState m_State;
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#define TRANSPORT_SESSION_H__
|
#define TRANSPORT_SESSION_H__
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include "Identity.h"
|
||||||
|
#include "RouterInfo.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
@ -17,11 +19,22 @@ namespace transport
|
|||||||
{
|
{
|
||||||
public:
|
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; };
|
virtual ~TransportSession () { delete m_DHKeysPair; };
|
||||||
|
|
||||||
|
const i2p::data::RouterInfo * GetRemoteRouter () { return m_RemoteRouter; };
|
||||||
|
const i2p::data::IdentityEx& GetRemoteIdentity () { return m_RemoteIdentity; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
const i2p::data::RouterInfo * m_RemoteRouter;
|
||||||
|
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
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user