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

Method ProcessSessionConfirmed

libi2pd/NTCP2.cpp:969–1006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

967 }
968
969 void NTCP2Session::ProcessSessionConfirmed ()
970 {
971 // run on establisher thread
972 LogPrint (eLogDebug, "NTCP2: SessionConfirmed received");
973 // part 1
974 if (m_Establisher->ProcessSessionConfirmedMessagePart1 ())
975 {
976 // part 2
977 auto buf = std::make_shared<std::vector<uint8_t> > (m_Establisher->m3p2Len - 16); // -MAC
978 if (m_Establisher->ProcessSessionConfirmedMessagePart2 (buf->data ())) // TODO:handle in establisher thread
979 {
980 // payload
981 // RI block must be first
982 if ((*buf)[0] != eNTCP2BlkRouterInfo)
983 {
984 LogPrint (eLogWarning, "NTCP2: Unexpected block ", (int)(*buf)[0], " in SessionConfirmed");
985 boost::asio::post (m_Server.GetService (), std::bind (&NTCP2Session::Terminate, shared_from_this ()));
986 return;
987 }
988 auto size = bufbe16toh (buf->data () + 1);
989 if (size > buf->size () - 3 || size > i2p::data::MAX_RI_BUFFER_SIZE + 1)
990 {
991 LogPrint (eLogError, "NTCP2: Unexpected RouterInfo size ", size, " in SessionConfirmed");
992 boost::asio::post (m_Server.GetService (), std::bind (&NTCP2Session::Terminate, shared_from_this ()));
993 return;
994 }
995 boost::asio::post (m_Server.GetService (),
996 [s = shared_from_this (), buf, size] ()
997 {
998 s->EstablishSessionAfterSessionConfirmed (buf, size);
999 });
1000 }
1001 else
1002 boost::asio::post (m_Server.GetService (), std::bind (&NTCP2Session::Terminate, shared_from_this ()));
1003 }
1004 else
1005 boost::asio::post (m_Server.GetService (), std::bind (&NTCP2Session::Terminate, shared_from_this ()));
1006 }
1007
1008 void NTCP2Session::EstablishSessionAfterSessionConfirmed (std::shared_ptr<std::vector<uint8_t> > buf, size_t size)
1009 {

Callers 2

ProcessNextPacketMethod · 0.45

Tested by

no test coverage detected