mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-13 04:46:38 +01:00
always lookup SSU session if peer's endpoint doesn't match
This commit is contained in:
parent
1bfb9b02f5
commit
5e42947fbd
3 changed files with 12 additions and 15 deletions
|
@ -328,7 +328,11 @@ namespace transport
|
||||||
{
|
{
|
||||||
if (!session || session->GetRemoteEndpoint () != packet->from) // we received packet for other session than previous
|
if (!session || session->GetRemoteEndpoint () != packet->from) // we received packet for other session than previous
|
||||||
{
|
{
|
||||||
if (session) session->FlushData ();
|
if (session)
|
||||||
|
{
|
||||||
|
session->FlushData ();
|
||||||
|
session = nullptr;
|
||||||
|
}
|
||||||
auto it = sessions->find (packet->from);
|
auto it = sessions->find (packet->from);
|
||||||
if (it != sessions->end ())
|
if (it != sessions->end ())
|
||||||
session = it->second;
|
session = it->second;
|
||||||
|
@ -751,10 +755,7 @@ namespace transport
|
||||||
{
|
{
|
||||||
auto session = it.second;
|
auto session = it.second;
|
||||||
if (it.first != session->GetRemoteEndpoint ())
|
if (it.first != session->GetRemoteEndpoint ())
|
||||||
{
|
|
||||||
LogPrint (eLogWarning, "SSU: remote endpoint ", session->GetRemoteEndpoint (), " doesn't match key ", it.first, " adjusted");
|
LogPrint (eLogWarning, "SSU: remote endpoint ", session->GetRemoteEndpoint (), " doesn't match key ", it.first, " adjusted");
|
||||||
session->SetRemoteEndpoint (it.first); // TODO: investigate why it happens
|
|
||||||
}
|
|
||||||
m_Service.post ([session]
|
m_Service.post ([session]
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "SSU: no activity with ", session->GetRemoteEndpoint (), " for ", session->GetTerminationTimeout (), " seconds");
|
LogPrint (eLogWarning, "SSU: no activity with ", session->GetRemoteEndpoint (), " for ", session->GetTerminationTimeout (), " seconds");
|
||||||
|
@ -782,10 +783,7 @@ namespace transport
|
||||||
{
|
{
|
||||||
auto session = it.second;
|
auto session = it.second;
|
||||||
if (it.first != session->GetRemoteEndpoint ())
|
if (it.first != session->GetRemoteEndpoint ())
|
||||||
{
|
LogPrint (eLogWarning, "SSU: remote endpoint ", session->GetRemoteEndpoint (), " doesn't match key ", it.first);
|
||||||
LogPrint (eLogWarning, "SSU: remote endpoint ", session->GetRemoteEndpoint (), " doesn't match key ", it.first, " adjusted");
|
|
||||||
session->SetRemoteEndpoint (it.first); // TODO: investigate why it happens
|
|
||||||
}
|
|
||||||
m_ServiceV6.post ([session]
|
m_ServiceV6.post ([session]
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "SSU: no activity with ", session->GetRemoteEndpoint (), " for ", session->GetTerminationTimeout (), " seconds");
|
LogPrint (eLogWarning, "SSU: no activity with ", session->GetRemoteEndpoint (), " for ", session->GetTerminationTimeout (), " seconds");
|
||||||
|
|
|
@ -158,7 +158,7 @@ namespace transport
|
||||||
ProcessData (buf + headerSize, len - headerSize);
|
ProcessData (buf + headerSize, len - headerSize);
|
||||||
break;
|
break;
|
||||||
case PAYLOAD_TYPE_SESSION_REQUEST:
|
case PAYLOAD_TYPE_SESSION_REQUEST:
|
||||||
ProcessSessionRequest (buf, len, senderEndpoint); // buf with header
|
ProcessSessionRequest (buf, len); // buf with header
|
||||||
break;
|
break;
|
||||||
case PAYLOAD_TYPE_SESSION_CREATED:
|
case PAYLOAD_TYPE_SESSION_CREATED:
|
||||||
ProcessSessionCreated (buf, len); // buf with header
|
ProcessSessionCreated (buf, len); // buf with header
|
||||||
|
@ -194,7 +194,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUSession::ProcessSessionRequest (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint)
|
void SSUSession::ProcessSessionRequest (const uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "SSU message: session request");
|
LogPrint (eLogDebug, "SSU message: session request");
|
||||||
bool sendRelayTag = true;
|
bool sendRelayTag = true;
|
||||||
|
@ -215,7 +215,6 @@ namespace transport
|
||||||
LogPrint (eLogError, "Session request header size ", headerSize, " exceeds packet length ", len);
|
LogPrint (eLogError, "Session request header size ", headerSize, " exceeds packet length ", len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_RemoteEndpoint = senderEndpoint;
|
|
||||||
if (!m_DHKeysPair)
|
if (!m_DHKeysPair)
|
||||||
m_DHKeysPair = transports.GetNextDHKeysPair ();
|
m_DHKeysPair = transports.GetNextDHKeysPair ();
|
||||||
CreateAESandMacKey (buf + headerSize);
|
CreateAESandMacKey (buf + headerSize);
|
||||||
|
|
|
@ -80,8 +80,8 @@ namespace transport
|
||||||
void Close ();
|
void Close ();
|
||||||
void Done ();
|
void Done ();
|
||||||
void Failed ();
|
void Failed ();
|
||||||
boost::asio::ip::udp::endpoint& GetRemoteEndpoint () { return m_RemoteEndpoint; };
|
const boost::asio::ip::udp::endpoint& GetRemoteEndpoint () { return m_RemoteEndpoint; };
|
||||||
void SetRemoteEndpoint (const boost::asio::ip::udp::endpoint& ep) { m_RemoteEndpoint = ep; }; // TODO: not to use
|
|
||||||
bool IsV6 () const { return m_RemoteEndpoint.address ().is_v6 (); };
|
bool IsV6 () const { return m_RemoteEndpoint.address ().is_v6 (); };
|
||||||
void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs);
|
void SendI2NPMessages (const std::vector<std::shared_ptr<I2NPMessage> >& msgs);
|
||||||
void SendPeerTest (); // Alice
|
void SendPeerTest (); // Alice
|
||||||
|
@ -104,7 +104,7 @@ namespace transport
|
||||||
size_t GetSSUHeaderSize (const uint8_t * buf) const;
|
size_t GetSSUHeaderSize (const uint8_t * buf) const;
|
||||||
void PostI2NPMessages (std::vector<std::shared_ptr<I2NPMessage> > msgs);
|
void PostI2NPMessages (std::vector<std::shared_ptr<I2NPMessage> > msgs);
|
||||||
void ProcessMessage (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint); // call for established session
|
void ProcessMessage (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint); // call for established session
|
||||||
void ProcessSessionRequest (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint);
|
void ProcessSessionRequest (const uint8_t * buf, size_t len);
|
||||||
void SendSessionRequest ();
|
void SendSessionRequest ();
|
||||||
void SendRelayRequest (const i2p::data::RouterInfo::Introducer& introducer, uint32_t nonce);
|
void SendRelayRequest (const i2p::data::RouterInfo::Introducer& introducer, uint32_t nonce);
|
||||||
void ProcessSessionCreated (uint8_t * buf, size_t len);
|
void ProcessSessionCreated (uint8_t * buf, size_t len);
|
||||||
|
@ -140,7 +140,7 @@ 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;
|
const boost::asio::ip::udp::endpoint m_RemoteEndpoint;
|
||||||
boost::asio::deadline_timer m_ConnectTimer;
|
boost::asio::deadline_timer m_ConnectTimer;
|
||||||
bool m_IsPeerTest;
|
bool m_IsPeerTest;
|
||||||
SessionState m_State;
|
SessionState m_State;
|
||||||
|
|
Loading…
Add table
Reference in a new issue