mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
send relay request through connected session
This commit is contained in:
parent
31f906240e
commit
73066eb6c6
2 changed files with 18 additions and 9 deletions
19
SSU.cpp
19
SSU.cpp
|
@ -72,12 +72,12 @@ namespace ssu
|
||||||
// session confirmed
|
// session confirmed
|
||||||
ProcessSessionConfirmed (buf, len);
|
ProcessSessionConfirmed (buf, len);
|
||||||
break;
|
break;
|
||||||
case eSessionRelayRequestSent:
|
case eSessionStateRelayRequestSent:
|
||||||
// relay response
|
// relay response
|
||||||
ProcessRelayResponse (buf,len);
|
ProcessRelayResponse (buf, len);
|
||||||
m_Server.DeleteSession (this);
|
m_Server.DeleteSession (this);
|
||||||
break;
|
break;
|
||||||
case eSessionIntroduced:
|
case eSessionStateIntroduced:
|
||||||
// HolePunch received
|
// HolePunch received
|
||||||
LogPrint ("SSU HolePuch of ", len, " bytes received");
|
LogPrint ("SSU HolePuch of ", len, " bytes received");
|
||||||
m_State = eSessionStateUnknown;
|
m_State = eSessionStateUnknown;
|
||||||
|
@ -110,6 +110,10 @@ namespace ssu
|
||||||
m_Server.DeleteSession (this); // delete this
|
m_Server.DeleteSession (this); // delete this
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case PAYLOAD_TYPE_RELAY_RESPONSE:
|
||||||
|
LogPrint ("SSU relay response received though established session");
|
||||||
|
// Ignore it for now
|
||||||
|
break;
|
||||||
case PAYLOAD_TYPE_RELAY_INTRO:
|
case PAYLOAD_TYPE_RELAY_INTRO:
|
||||||
LogPrint ("SSU relay intro received");
|
LogPrint ("SSU relay intro received");
|
||||||
ProcessRelayIntro (buf + sizeof (SSUHeader), len - sizeof (SSUHeader));
|
ProcessRelayIntro (buf + sizeof (SSUHeader), len - sizeof (SSUHeader));
|
||||||
|
@ -295,8 +299,13 @@ namespace ssu
|
||||||
|
|
||||||
uint8_t iv[16];
|
uint8_t iv[16];
|
||||||
rnd.GenerateBlock (iv, 16); // random iv
|
rnd.GenerateBlock (iv, 16); // random iv
|
||||||
|
if (m_State == eSessionStateEstablished)
|
||||||
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_REQUEST, buf, 96, m_SessionKey, iv, m_MacKey);
|
||||||
|
else
|
||||||
|
{
|
||||||
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_REQUEST, buf, 96, iKey, iv, iKey);
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_REQUEST, buf, 96, iKey, iv, iKey);
|
||||||
m_State = eSessionRelayRequestSent;
|
m_State = eSessionStateRelayRequestSent;
|
||||||
|
}
|
||||||
m_Server.Send (buf, 96, m_RemoteEndpoint);
|
m_Server.Send (buf, 96, m_RemoteEndpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +538,7 @@ namespace ssu
|
||||||
|
|
||||||
void SSUSession::WaitForIntroduction ()
|
void SSUSession::WaitForIntroduction ()
|
||||||
{
|
{
|
||||||
m_State = eSessionIntroduced;
|
m_State = eSessionStateIntroduced;
|
||||||
// set connect timer
|
// set connect timer
|
||||||
m_Timer.expires_from_now (boost::posix_time::seconds(SSU_CONNECT_TIMEOUT));
|
m_Timer.expires_from_now (boost::posix_time::seconds(SSU_CONNECT_TIMEOUT));
|
||||||
m_Timer.async_wait (boost::bind (&SSUSession::HandleConnectTimer,
|
m_Timer.async_wait (boost::bind (&SSUSession::HandleConnectTimer,
|
||||||
|
|
6
SSU.h
6
SSU.h
|
@ -60,9 +60,9 @@ namespace ssu
|
||||||
eSessionStateCreatedReceived,
|
eSessionStateCreatedReceived,
|
||||||
eSessionStateConfirmedSent,
|
eSessionStateConfirmedSent,
|
||||||
eSessionStateConfirmedReceived,
|
eSessionStateConfirmedReceived,
|
||||||
eSessionRelayRequestSent,
|
eSessionStateRelayRequestSent,
|
||||||
eSessionRelayRequestReceived,
|
eSessionStateRelayRequestReceived,
|
||||||
eSessionIntroduced,
|
eSessionStateIntroduced,
|
||||||
eSessionStateEstablished,
|
eSessionStateEstablished,
|
||||||
eSessionStateFailed
|
eSessionStateFailed
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue