mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-10 05:11:10 +00:00
store relay session directly
This commit is contained in:
parent
2e8fa88fcb
commit
178dedf78c
9
SSU.cpp
9
SSU.cpp
@ -154,7 +154,7 @@ namespace transport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUServer::AddRelay (uint32_t tag, const boost::asio::ip::udp::endpoint& relay)
|
void SSUServer::AddRelay (uint32_t tag, std::shared_ptr<SSUSession> relay)
|
||||||
{
|
{
|
||||||
m_Relays[tag] = relay;
|
m_Relays[tag] = relay;
|
||||||
}
|
}
|
||||||
@ -168,7 +168,12 @@ namespace transport
|
|||||||
{
|
{
|
||||||
auto it = m_Relays.find (tag);
|
auto it = m_Relays.find (tag);
|
||||||
if (it != m_Relays.end ())
|
if (it != m_Relays.end ())
|
||||||
return FindSession (it->second);
|
{
|
||||||
|
if (it->second->GetState () == eSessionStateEstablished)
|
||||||
|
return it->second;
|
||||||
|
else
|
||||||
|
m_Relays.erase (it);
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
SSU.h
4
SSU.h
@ -57,7 +57,7 @@ namespace transport
|
|||||||
boost::asio::io_service& GetServiceV6 () { return m_ServiceV6; };
|
boost::asio::io_service& GetServiceV6 () { return m_ServiceV6; };
|
||||||
const boost::asio::ip::udp::endpoint& GetEndpoint () const { return m_Endpoint; };
|
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 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 AddRelay (uint32_t tag, std::shared_ptr<SSUSession> relay);
|
||||||
void RemoveRelay (uint32_t tag);
|
void RemoveRelay (uint32_t tag);
|
||||||
std::shared_ptr<SSUSession> FindRelaySession (uint32_t tag);
|
std::shared_ptr<SSUSession> FindRelaySession (uint32_t tag);
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ namespace transport
|
|||||||
m_TerminationTimer, m_TerminationTimerV6;
|
m_TerminationTimer, m_TerminationTimerV6;
|
||||||
std::list<boost::asio::ip::udp::endpoint> m_Introducers; // introducers we are connected to
|
std::list<boost::asio::ip::udp::endpoint> m_Introducers; // introducers we are connected to
|
||||||
std::map<boost::asio::ip::udp::endpoint, std::shared_ptr<SSUSession> > m_Sessions, m_SessionsV6;
|
std::map<boost::asio::ip::udp::endpoint, std::shared_ptr<SSUSession> > m_Sessions, m_SessionsV6;
|
||||||
std::map<uint32_t, boost::asio::ip::udp::endpoint> m_Relays; // we are introducer
|
std::map<uint32_t, std::shared_ptr<SSUSession> > m_Relays; // we are introducer
|
||||||
std::map<uint32_t, PeerTest> m_PeerTests; // nonce -> creation time in milliseconds
|
std::map<uint32_t, PeerTest> m_PeerTests; // nonce -> creation time in milliseconds
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -462,7 +462,7 @@ namespace transport
|
|||||||
{
|
{
|
||||||
RAND_bytes((uint8_t *)&m_SentRelayTag, 4);
|
RAND_bytes((uint8_t *)&m_SentRelayTag, 4);
|
||||||
if (!m_SentRelayTag) m_SentRelayTag = 1;
|
if (!m_SentRelayTag) m_SentRelayTag = 1;
|
||||||
m_Server.AddRelay (m_SentRelayTag, m_RemoteEndpoint);
|
m_Server.AddRelay (m_SentRelayTag, shared_from_this ());
|
||||||
}
|
}
|
||||||
htobe32buf (payload, m_SentRelayTag);
|
htobe32buf (payload, m_SentRelayTag);
|
||||||
payload += 4; // relay tag
|
payload += 4; // relay tag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user