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

Method ProcessFirstIncomingMessage

libi2pd/SSU2Session.cpp:670–710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

668 }
669
670 bool SSU2Session::ProcessFirstIncomingMessage (uint64_t connID, uint8_t * buf, size_t len)
671 {
672 // we are Bob
673 m_SourceConnID = connID;
674 Header header;
675 header.h.connID = connID;
676 memcpy (header.buf + 8, buf + 8, 8);
677 header.ll[1] ^= CreateHeaderMask (i2p::context.GetSSU2IntroKey (), buf + (len - 12));
678 switch (header.h.type)
679 {
680 case eSSU2SessionRequest:
681 return ProcessSessionRequest (header, buf, len);
682 break;
683 case eSSU2TokenRequest:
684 return ProcessTokenRequest (header, buf, len);
685 break;
686 case eSSU2PeerTest:
687 {
688 // TODO: remove later
689 if (len < 32)
690 {
691 LogPrint (eLogWarning, "SSU2: PeerTest message too short ", len);
692 break;
693 }
694 const uint8_t nonce[12] = {0};
695 uint64_t headerX[2];
696 m_Server.ChaCha20 (buf + 16, 16, i2p::context.GetSSU2IntroKey (), nonce, (uint8_t *)headerX);
697 LogPrint (eLogWarning, "SSU2: Unexpected PeerTest message SourceConnID=", connID, " DestConnID=", headerX[0]);
698 break;
699 }
700 case eSSU2HolePunch:
701 LogPrint (eLogDebug, "SSU2: Late HolePunch for ", connID);
702 break;
703 default:
704 {
705 LogPrint (eLogWarning, "SSU2: Unexpected message type ", (int)header.h.type, " from ", m_RemoteEndpoint, " of ", len, " bytes");
706 return false;
707 }
708 }
709 return true;
710 }
711
712 bool SSU2Session::SendSessionRequest (uint64_t token)
713 {

Callers 1

ProcessNextPacketMethod · 0.45

Calls 4

CreateHeaderMaskFunction · 0.85
LogPrintFunction · 0.85
GetSSU2IntroKeyMethod · 0.80
ChaCha20Method · 0.80

Tested by

no test coverage detected