From 83f9e1098d66d9a01c61c67535ae70ca9b2a8151 Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 14 Aug 2025 15:58:42 -0400 Subject: [PATCH] decline master session if SAM version is less than 3.3 --- libi2pd_client/SAM.cpp | 20 +++++++++++++++++++- libi2pd_client/SAM.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/libi2pd_client/SAM.cpp b/libi2pd_client/SAM.cpp index 94bac10f..22279001 100644 --- a/libi2pd_client/SAM.cpp +++ b/libi2pd_client/SAM.cpp @@ -373,7 +373,15 @@ namespace client } } else if (style == SAM_VALUE_RAW) type = SAMSessionType::eSAMSessionTypeRaw; - else if (style == SAM_VALUE_MASTER) type = SAMSessionType::eSAMSessionTypeMaster; + else if (style == SAM_VALUE_MASTER) + { + if (m_Version < SAM_VERSION_33) // < SAM 3.3 + { + SendSessionI2PError("MASTER session is not supported"); + return; + } + type = SAMSessionType::eSAMSessionTypeMaster; + } if (type == SAMSessionType::eSAMSessionTypeUnknown) { // unknown style @@ -868,6 +876,11 @@ namespace client void SAMSocket::ProcessSessionAdd (std::string_view buf) { + if (m_Version < SAM_VERSION_33) // < SAM 3.3 + { + SendSessionI2PError("SESSION ADD is not supported"); + return; + } auto session = m_Owner.FindSession(m_ID); if (session && session->Type == SAMSessionType::eSAMSessionTypeMaster) { @@ -918,6 +931,11 @@ namespace client void SAMSocket::ProcessSessionRemove (std::string_view buf) { + if (m_Version < SAM_VERSION_33) // < SAM 3.3 + { + SendSessionI2PError("SESSION REMOVE is not supported"); + return; + } auto session = m_Owner.FindSession(m_ID); if (session && session->Type == SAMSessionType::eSAMSessionTypeMaster) { diff --git a/libi2pd_client/SAM.h b/libi2pd_client/SAM.h index 7ffafb61..00b7ed03 100644 --- a/libi2pd_client/SAM.h +++ b/libi2pd_client/SAM.h @@ -94,6 +94,7 @@ namespace client constexpr int MAKE_SAM_VERSION_NUMBER (int major, int minor) { return major*10 + minor; } constexpr int MIN_SAM_VERSION = MAKE_SAM_VERSION_NUMBER (3, 0); constexpr int MAX_SAM_VERSION = MAKE_SAM_VERSION_NUMBER (3, 3); + constexpr int SAM_VERSION_33 = MAKE_SAM_VERSION_NUMBER (3, 3); // SAM 3.3 enum class SAMSocketType {