diff --git a/libi2pd/NTCP2.cpp b/libi2pd/NTCP2.cpp index f31044b8..77882b46 100644 --- a/libi2pd/NTCP2.cpp +++ b/libi2pd/NTCP2.cpp @@ -447,7 +447,7 @@ namespace transport SHA256 (h, 80, m_Establisher->m_H); std::vector buf(m_Establisher->m3p2Len - 16); // -MAC - buf[0] = 2; // block + buf[0] = eNTCP2BlkRouterInfo; // block htobe16buf (buf.data () + 1, i2p::context.GetRouterInfo ().GetBufferLen () + 1); // flag + RI buf[3] = 0; // flag memcpy (buf.data () + 4, i2p::context.GetRouterInfo ().GetBuffer (), i2p::context.GetRouterInfo ().GetBufferLen ()); @@ -695,7 +695,13 @@ namespace transport break; } case eNTCP2BlkTermination: - LogPrint (eLogDebug, "NTCP2: termination"); + if (size >= 9) + { + LogPrint (eLogDebug, "NTCP2: termination. reason=", (int)(frame[offset + 9])); + Terminate (); + } + else + LogPrint (eLogWarning, "NTCP2: Unexpected temination block size ", size); break; case eNTCP2BlkPadding: LogPrint (eLogDebug, "NTCP2: padding"); diff --git a/libi2pd/NTCP2.h b/libi2pd/NTCP2.h index 74043ca1..b1fe21e6 100644 --- a/libi2pd/NTCP2.h +++ b/libi2pd/NTCP2.h @@ -28,6 +28,29 @@ namespace transport eNTCP2BlkPadding = 254 }; + enum NTCP2TerminationReason + { + eNTCP2NormalClose = 0, + eNTCP2TerminationReceived, // 1 + eNTCP2IdleTimeout, // 2 + eNTCP2RouterShutdown, // 3 + eNTCP2DataPhaseAEADFailure, // 4 + eNTCP2IncompatibleOptions, // 5 + eNTCP2IncompatibleSignatureType, // 6 + eNTCP2ClockSkew, // 7 + eNTCP2PaddingViolation, // 8 + eNTCP2AEADFraminError, // 9 + eNTCP2PayloadFromatError, // 10 + eNTCP2Message1Error, // 11 + eNTCP2Message2Error, // 12 + eNTCP2Message3Error, // 13 + eNTCP2IntraFrameReadTimeout, // 14 + eNTCP2RouterInfoSignatureVerificationFail, // 15 + eNTCP2IncorrectSParameter, // 16 + eNTCP2Banned, // 17 + }; + + struct NTCP2Establisher { NTCP2Establisher ();