From 38851da8d045dfd2b47db37ae2afde0f43635592 Mon Sep 17 00:00:00 2001 From: sebaszm Date: Sun, 8 Dec 2024 21:11:13 +0100 Subject: [PATCH 1/5] [Core] Accept pascal-cased method names on JSONR-RPC calls --- Source/core/JSONRPC.h | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/Source/core/JSONRPC.h b/Source/core/JSONRPC.h index 0139a3a9c..e24b2f367 100644 --- a/Source/core/JSONRPC.h +++ b/Source/core/JSONRPC.h @@ -260,14 +260,19 @@ namespace Core { size_t end = designator.find_last_of('@'); size_t begin = designator.find_last_of('.', end); size_t lookup = designator.find_first_of('#', begin+1); + string method; if (lookup != string::npos) { size_t ns = designator.find_first_of(':', lookup + 1); - return (designator.substr((begin == string::npos) ? 0 : begin + 1, lookup - begin - 1) + (ns != string::npos? designator.substr(ns, end - ns) : string{})); + method = designator.substr((begin == string::npos) ? 0 : begin + 1, lookup - begin - 1) + (ns != string::npos? designator.substr(ns, end - ns) : string{}); } else { - return (designator.substr((begin == string::npos) ? 0 : begin + 1, (end == string::npos ? string::npos : (begin == string::npos) ? end : end - begin - 1))); + method = designator.substr((begin == string::npos) ? 0 : begin + 1, (end == string::npos ? string::npos : (begin == string::npos) ? end : end - begin - 1)); } + + ToCamelCase(method); + + return (method); } static string FullMethod(const string& designator) { @@ -420,6 +425,30 @@ namespace Core { Core::JSON::String Result; Info Error; + private: + static void ToCamelCase(string& source) + { + // speed optimized, does not care for locale settings + + char* raw = &source[0]; + + auto const isup = [](const char ch) { + return (static_cast(ch - 'A') <= 25); + }; + + auto const islow = [](const char ch) { + return (static_cast(ch - 'a') <= 25); + }; + + if (isup(raw[0])) { + *raw++ |= 32; + + while (isup(raw[0]) && !islow(raw[1])) { + *raw++ |= 32; + } + } + } + private: string _implicitCallsign; }; From 9aa8664c3db2817cfe8ef876e335650531aee33e Mon Sep 17 00:00:00 2001 From: sebaszm Date: Mon, 9 Dec 2024 13:46:20 +0100 Subject: [PATCH 2/5] Already mark pascalcasing as deprecated --- Source/core/JSONRPC.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/core/JSONRPC.h b/Source/core/JSONRPC.h index e24b2f367..da382783f 100644 --- a/Source/core/JSONRPC.h +++ b/Source/core/JSONRPC.h @@ -270,7 +270,9 @@ namespace Core { method = designator.substr((begin == string::npos) ? 0 : begin + 1, (end == string::npos ? string::npos : (begin == string::npos) ? end : end - begin - 1)); } +PUSH_WARNING(DISABLE_WARNING_DEPRECATED_USE) // Support pascal casing during the transition period ToCamelCase(method); +POP_WARNING() return (method); } @@ -426,7 +428,7 @@ namespace Core { Info Error; private: - static void ToCamelCase(string& source) + DEPRECATED static void ToCamelCase(string& source) { // speed optimized, does not care for locale settings From c4add9c909960c6dcaefb36d6e3271e654274962 Mon Sep 17 00:00:00 2001 From: MFransen69 <39826971+MFransen69@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:18:38 +0100 Subject: [PATCH 3/5] [jsonrpc] Make json rpc error handle comrpc error case (#1809) --- Source/core/JSONRPC.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Source/core/JSONRPC.h b/Source/core/JSONRPC.h index da382783f..9089e274d 100644 --- a/Source/core/JSONRPC.h +++ b/Source/core/JSONRPC.h @@ -39,8 +39,15 @@ namespace Core { // this magical value as a base for Thunder error codes (0..999). // These error codes are *not* related to the JSONRPC transport // layer but relate to the application layer. - // Seems the spec is expecting a value > -32767, so with a value - // range of 0-999 Thunder codes, -31000 should be oke :-) + // Seems the spec is expecting a value > -32000, so with a value + // range of 0-499 Thunder non COMRPC error codes and 500-999 COMRPC errors, + // so -31000 as base should be oke :-) + // Please note: do NOT change the base number as there might be external + // code depending on this number to get to a certain error + // value for JSON RPC, so changing this number will break + // backwards compatibility not only for code below but + // also external code. + static constexpr int32_t ApplicationErrorCodeBase = -31000; class Info : public Core::JSON::Container { @@ -166,7 +173,11 @@ namespace Core { Text = _T("Requested service is not available."); break; default: - Code = ApplicationErrorCodeBase - static_cast(frameworkError); + if ((frameworkError & 0x80000000) == 0) { + Code = ApplicationErrorCodeBase - static_cast(frameworkError); + } else { + Code = ApplicationErrorCodeBase - static_cast(frameworkError & 0x7FFFFFFF) - 500; + } Text = Core::ErrorToString(frameworkError); break; } From d6719a09c7e4e9c452a3ab20dc60aa29e9fd5143 Mon Sep 17 00:00:00 2001 From: MFransen69 <39826971+MFransen69@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:57:53 +0100 Subject: [PATCH 4/5] [comrpc] add CC interface offset (#1811) --- Source/com/Ids.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/com/Ids.h b/Source/com/Ids.h index b0cbad129..4bf39d09f 100644 --- a/Source/com/Ids.h +++ b/Source/com/Ids.h @@ -93,7 +93,8 @@ namespace RPC { ID_SYSTEM_METADATA = (ID_OFFSET_INTERNAL + 0x0071), ID_EXTERNAL_INTERFACE_OFFSET = (ID_OFFSET_INTERNAL + 0x0080), - ID_EXTERNAL_QA_INTERFACE_OFFSET = (ID_OFFSET_INTERNAL + 0xA000) + ID_EXTERNAL_QA_INTERFACE_OFFSET = (0xA000), + ID_EXTERNAL_CC_INTERFACE_OFFSET = (0xCC00) // ends on 0xDFFF }; } } From e032a1063ff007e638a10214f47a0f9b81561f1b Mon Sep 17 00:00:00 2001 From: MFransen69 <39826971+MFransen69@users.noreply.github.com> Date: Thu, 12 Dec 2024 18:55:16 +0100 Subject: [PATCH 5/5] [secsoc] fix warning (#1812) * [secsoc] fix warning * Update SecureSocketPort.cpp --- Source/cryptalgo/SecureSocketPort.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cryptalgo/SecureSocketPort.cpp b/Source/cryptalgo/SecureSocketPort.cpp index 0b5379583..c1a57eb56 100644 --- a/Source/cryptalgo/SecureSocketPort.cpp +++ b/Source/cryptalgo/SecureSocketPort.cpp @@ -1,4 +1,4 @@ -/* +/* * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: * @@ -206,7 +206,6 @@ static int passwd_callback(char* buffer, int size, int /* flags */, void* passwo Key::Key(const string& fileName, const string& password) : _key(nullptr) { BIO* bio_key = BIO_new_file(fileName.c_str(), "rb"); - FILE* file = ::fopen(fileName.c_str(), "rt"); if (bio_key != nullptr) { _key = PEM_read_bio_PrivateKey(bio_key, NULL, passwd_callback, const_cast(static_cast(password.c_str())));