mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
Merge remote-tracking branch 'purple/openssl'
This commit is contained in:
commit
b0c64afc6e
5
SSU.cpp
5
SSU.cpp
@ -159,6 +159,11 @@ namespace transport
|
||||
m_Relays[tag] = relay;
|
||||
}
|
||||
|
||||
void SSUServer::RemoveRelay (uint32_t tag)
|
||||
{
|
||||
m_Relays.erase (tag);
|
||||
}
|
||||
|
||||
std::shared_ptr<SSUSession> SSUServer::FindRelaySession (uint32_t tag)
|
||||
{
|
||||
auto it = m_Relays.find (tag);
|
||||
|
1
SSU.h
1
SSU.h
@ -58,6 +58,7 @@ namespace transport
|
||||
const boost::asio::ip::udp::endpoint& GetEndpoint () const { return m_Endpoint; };
|
||||
void Send (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& to);
|
||||
void AddRelay (uint32_t tag, const boost::asio::ip::udp::endpoint& relay);
|
||||
void RemoveRelay (uint32_t tag);
|
||||
std::shared_ptr<SSUSession> FindRelaySession (uint32_t tag);
|
||||
|
||||
void NewPeerTest (uint32_t nonce, PeerTestParticipant role, std::shared_ptr<SSUSession> session = nullptr);
|
||||
|
@ -16,7 +16,7 @@ namespace transport
|
||||
TransportSession (router, SSU_TERMINATION_TIMEOUT),
|
||||
m_Server (server), m_RemoteEndpoint (remoteEndpoint), m_ConnectTimer (GetService ()),
|
||||
m_IsPeerTest (peerTest),m_State (eSessionStateUnknown), m_IsSessionKey (false),
|
||||
m_RelayTag (0),m_Data (*this), m_IsDataReceived (false)
|
||||
m_RelayTag (0), m_SentRelayTag (0), m_Data (*this), m_IsDataReceived (false)
|
||||
{
|
||||
if (router)
|
||||
{
|
||||
@ -460,14 +460,13 @@ namespace transport
|
||||
else
|
||||
s.Insert (address->host.to_v6 ().to_bytes ().data (), 16); // our IP V6
|
||||
s.Insert<uint16_t> (htobe16 (address->port)); // our port
|
||||
uint32_t relayTag = 0;
|
||||
if (sendRelayTag && i2p::context.GetRouterInfo ().IsIntroducer () && !IsV6 ())
|
||||
{
|
||||
RAND_bytes((uint8_t *)&relayTag, 4);
|
||||
if (!relayTag) relayTag = 1;
|
||||
m_Server.AddRelay (relayTag, m_RemoteEndpoint);
|
||||
RAND_bytes((uint8_t *)&m_SentRelayTag, 4);
|
||||
if (!m_SentRelayTag) m_SentRelayTag = 1;
|
||||
m_Server.AddRelay (m_SentRelayTag, m_RemoteEndpoint);
|
||||
}
|
||||
htobe32buf (payload, relayTag);
|
||||
htobe32buf (payload, m_SentRelayTag);
|
||||
payload += 4; // relay tag
|
||||
htobe32buf (payload, i2p::util::GetSecondsSinceEpoch ()); // signed on time
|
||||
payload += 4;
|
||||
@ -876,6 +875,8 @@ namespace transport
|
||||
transports.PeerDisconnected (shared_from_this ());
|
||||
m_Data.Stop ();
|
||||
m_ConnectTimer.cancel ();
|
||||
if (m_SentRelayTag)
|
||||
m_Server.RemoveRelay (m_SentRelayTag); // relay tag is not valid anymore
|
||||
}
|
||||
|
||||
void SSUSession::Done ()
|
||||
|
@ -141,7 +141,8 @@ namespace transport
|
||||
bool m_IsPeerTest;
|
||||
SessionState m_State;
|
||||
bool m_IsSessionKey;
|
||||
uint32_t m_RelayTag;
|
||||
uint32_t m_RelayTag; // received from peer
|
||||
uint32_t m_SentRelayTag; // sent by us
|
||||
i2p::crypto::CBCEncryption m_SessionKeyEncryption;
|
||||
i2p::crypto::CBCDecryption m_SessionKeyDecryption;
|
||||
i2p::crypto::AESKey m_SessionKey;
|
||||
|
Loading…
Reference in New Issue
Block a user