MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / ProcessSessionRequest

Method ProcessSessionRequest

libi2pd/NTCP2.cpp:724–763  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

722 }
723
724 void NTCP2Session::ProcessSessionRequest (size_t len, bool first)
725 {
726 LogPrint (eLogDebug, "NTCP2: SessionRequest ", first ? "received " : "updated ", len);
727 uint16_t paddingLen = 0;
728 bool clockSkew = false, pq = false;
729 if (m_Establisher->ProcessSessionRequestMessage (paddingLen, clockSkew, pq, first))
730 {
731 if (clockSkew)
732 {
733 // we don't care about padding, send SessionCreated and close session
734 SendSessionCreated ();
735 boost::asio::post (m_Server.GetService (), std::bind (&NTCP2Session::Terminate, shared_from_this ()));
736 }
737#if OPENSSL_PQ
738 else if (pq)
739 {
740 auto keyLen = i2p::crypto::GetMLKEMPublicKeyLen (m_Establisher->m_CryptoType);
741 boost::asio::async_read (m_Socket, boost::asio::buffer(m_Establisher->m_Buffer + 64, keyLen + 16), boost::asio::transfer_all (),
742 std::bind(&NTCP2Session::HandleSessionRequestMLKEMReceived, shared_from_this (), std::placeholders::_1, std::placeholders::_2));
743 }
744#endif
745 else if (paddingLen > 0)
746 {
747 if (len + paddingLen <= m_Establisher->m_MaxMsgSize)
748 {
749 boost::asio::async_read (m_Socket, boost::asio::buffer(m_Establisher->m_Buffer + len, paddingLen), boost::asio::transfer_all (),
750 std::bind(&NTCP2Session::HandleSessionRequestPaddingReceived, shared_from_this (), std::placeholders::_1, std::placeholders::_2));
751 }
752 else
753 {
754 LogPrint (eLogWarning, "NTCP2: SessionRequest padding length ", (int)paddingLen, " is too long");
755 boost::asio::post (m_Server.GetService (), std::bind (&NTCP2Session::Terminate, shared_from_this ()));
756 }
757 }
758 else
759 SendSessionCreated ();
760 }
761 else
762 ReadSomethingAndTerminate (); // probing resistance
763 }
764
765 void NTCP2Session::HandleSessionRequestPaddingReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred)
766 {

Calls 2

LogPrintFunction · 0.85

Tested by

no test coverage detected