diff --git a/package/rousette/0001-Log-HTTP-headers-and-the-input-data-payload.patch b/package/rousette/0001-Log-HTTP-headers-and-the-input-data-payload.patch index ec9e1889..e4a1f7dd 100644 --- a/package/rousette/0001-Log-HTTP-headers-and-the-input-data-payload.patch +++ b/package/rousette/0001-Log-HTTP-headers-and-the-input-data-payload.patch @@ -1,7 +1,7 @@ -From a4136d889237dadb9253ea7eb668a525dd779e6d Mon Sep 17 00:00:00 2001 +From c0d13b8e426608a30b1eea382f908fb6447fd01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Thu, 12 Jun 2025 10:33:42 +0100 -Subject: [PATCH 01/17] Log HTTP headers and the input data payload +Subject: [PATCH 01/13] Log HTTP headers and the input data payload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -11,7 +11,7 @@ Organization: Wires Hažlinský just found. Change-Id: I2a930a02c7d30c051390fe73e6af9849edd580b4 -Signed-off-by: Mattias Walström +Signed-off-by: Joachim Wiberg --- src/restconf/Server.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package/rousette/0002-restconf-prevent-throwing-exception-in-withRestconfE.patch b/package/rousette/0002-restconf-prevent-throwing-exception-in-withRestconfE.patch index 3b3c8ac9..e11b6366 100644 --- a/package/rousette/0002-restconf-prevent-throwing-exception-in-withRestconfE.patch +++ b/package/rousette/0002-restconf-prevent-throwing-exception-in-withRestconfE.patch @@ -1,11 +1,8 @@ -From 6c5b482ea5c9fbc1149a0864b05d1bb1fa7100bf Mon Sep 17 00:00:00 2001 +From 027a47ac3ff6c369caab7c007a5a171a68270829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= Date: Fri, 13 Jun 2025 10:47:55 +0200 -Subject: [PATCH 02/17] restconf: prevent throwing exception in +Subject: [PATCH 02/13] restconf: prevent throwing exception in withRestconfExceptions wrapper -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit Organization: Wires In case the catch block of withRestconfExceptions is reached and an @@ -22,7 +19,7 @@ handle such situations. Bug: https://github.com/CESNET/rousette/issues/19 Change-Id: Ifbd74b9bdc0ca66c4e5449a7673ef2f12ae9215e -Signed-off-by: Mattias Walström +Signed-off-by: Joachim Wiberg --- src/restconf/Server.cpp | 2 +- tests/restconf-plain-patch.cpp | 24 ++++++++++++++++++++++++ diff --git a/package/rousette/0003-CI-switch-to-the-new-cloud-s-Swift-URL.patch b/package/rousette/0003-CI-switch-to-the-new-cloud-s-Swift-URL.patch deleted file mode 100644 index 202864fe..00000000 --- a/package/rousette/0003-CI-switch-to-the-new-cloud-s-Swift-URL.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 41c9d9cab47a88ee6c70ab8009b789226c0982fe Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= -Date: Tue, 17 Jun 2025 12:46:27 +0200 -Subject: [PATCH 03/17] CI: switch to the new cloud's Swift URL -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit -Organization: Wires - -Change-Id: I69f8351394262a2a9b691422592741bfb40a8e38 -Signed-off-by: Mattias Walström ---- - ci/build.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/ci/build.sh b/ci/build.sh -index d49bd56..59b31ab 100755 ---- a/ci/build.sh -+++ b/ci/build.sh -@@ -67,7 +67,7 @@ if [[ -z "${ARTIFACT_URL}" ]]; then - # nothing ahead in the pipeline -> fallback to the latest promoted artifact - DEPSRCDIR=$(jq < ~/zuul-env.json -e -r ".projects[] | select(.name == \"CzechLight/dependencies\").src_dir") - DEP_SUBMODULE_COMMIT=$(git --git-dir ${HOME}/${DEPSRCDIR}/.git rev-parse HEAD) -- ARTIFACT_URL="https://object-store.cloud.muni.cz/swift/v1/ci-artifacts-${ZUUL_TENANT}/${ZUUL_GERRIT_HOSTNAME}/CzechLight/dependencies/deps-${ZUUL_JOB_NAME_NO_PROJECT%%-cover?(-previous)}/${DEP_SUBMODULE_COMMIT}.tar.zst" -+ ARTIFACT_URL="https://object-store.brno.openstack.cloud.e-infra.cz/swift/v1/KEY_b637b9c937414b29b3e277b4a85cc658/ci-artifacts-${ZUUL_TENANT}/${ZUUL_GERRIT_HOSTNAME}/CzechLight/dependencies/deps-${ZUUL_JOB_NAME_NO_PROJECT%%-cover?(-previous)}/${DEP_SUBMODULE_COMMIT}.tar.zst" - fi - - curl ${ARTIFACT_URL} | unzstd --stdout | tar -C ${PREFIX} -xf - --- -2.43.0 - diff --git a/package/rousette/0004-restconf-crash-instead-of-a-deadlock-when-the-handle.patch b/package/rousette/0003-restconf-crash-instead-of-a-deadlock-when-the-handle.patch similarity index 97% rename from package/rousette/0004-restconf-crash-instead-of-a-deadlock-when-the-handle.patch rename to package/rousette/0003-restconf-crash-instead-of-a-deadlock-when-the-handle.patch index 452f9039..bb0bb2c0 100644 --- a/package/rousette/0004-restconf-crash-instead-of-a-deadlock-when-the-handle.patch +++ b/package/rousette/0003-restconf-crash-instead-of-a-deadlock-when-the-handle.patch @@ -1,7 +1,7 @@ -From ec8673126929b6459fcd99c84a79993a725b40e1 Mon Sep 17 00:00:00 2001 +From d1c56f14b54b113df8fba759924bb47cfa27366c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= Date: Fri, 13 Jun 2025 10:47:55 +0200 -Subject: [PATCH 04/17] restconf: crash instead of a deadlock when the handler +Subject: [PATCH 03/13] restconf: crash instead of a deadlock when the handler throws MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 @@ -37,7 +37,7 @@ called twice [3]. Signed-off-by: Jan Kundrát Bug: https://github.com/CESNET/rousette/issues/19 Change-Id: I2c090b9a76b062101ba422a7d50e8e699779e203 -Signed-off-by: Mattias Walström +Signed-off-by: Joachim Wiberg --- src/restconf/Server.cpp | 28 ++++++++++++++++++++++++++++ src/restconf/Server.h | 4 ++++ diff --git a/package/rousette/0006-close-long-lived-connections-on-SIGTERM.patch b/package/rousette/0004-close-long-lived-connections-on-SIGTERM.patch similarity index 98% rename from package/rousette/0006-close-long-lived-connections-on-SIGTERM.patch rename to package/rousette/0004-close-long-lived-connections-on-SIGTERM.patch index 57179a31..6bff80ac 100644 --- a/package/rousette/0006-close-long-lived-connections-on-SIGTERM.patch +++ b/package/rousette/0004-close-long-lived-connections-on-SIGTERM.patch @@ -1,10 +1,7 @@ -From 4eae6200aa812950ebbac1660a1899f4edf41e11 Mon Sep 17 00:00:00 2001 +From db64d7b3fc0a0373067e6c5ac9e41b93351778a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Wed, 7 Aug 2024 19:07:35 +0200 -Subject: [PATCH 06/17] close long-lived connections on SIGTERM -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +Subject: [PATCH 04/13] close long-lived connections on SIGTERM Organization: Wires Without this patch, all the ongoing SSE streams would be left alive for @@ -23,7 +20,7 @@ hope it is). Change-Id: If442134783ba1d699de47c51a9068378f53e8339 Co-authored-by: Tomas Pecka -Signed-off-by: Mattias Walström +Signed-off-by: Joachim Wiberg --- CMakeLists.txt | 1 + src/clock.cpp | 7 +-- diff --git a/package/rousette/0005-doc-let-s-stop-calling-this-an-almost-RESTCONF-serve.patch b/package/rousette/0005-doc-let-s-stop-calling-this-an-almost-RESTCONF-serve.patch deleted file mode 100644 index 9985c857..00000000 --- a/package/rousette/0005-doc-let-s-stop-calling-this-an-almost-RESTCONF-serve.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 37ca95c387d76c3f296a4e44b211772a1ca155ab Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= -Date: Wed, 18 Jun 2025 12:01:04 +0200 -Subject: [PATCH 05/17] doc: let's stop calling this "an almost-RESTCONF - server" -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit -Organization: Wires - -Change-Id: If55ace481c78d838a811ded76a564f8fb59f9233 -Signed-off-by: Mattias Walström ---- - README.md | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/README.md b/README.md -index 0796dce..a42c64d 100644 ---- a/README.md -+++ b/README.md -@@ -1,4 +1,4 @@ --# An almost-RESTCONF server -+# A RESTCONF server for sysrepo - - ![License](https://img.shields.io/github/license/cesnet/rousette) - [![Gerrit](https://img.shields.io/badge/patches-via%20Gerrit-blue)](https://gerrit.cesnet.cz/q/project:CzechLight/rousette) --- -2.43.0 - diff --git a/package/rousette/0007-restconf-refactor-server-stop.patch b/package/rousette/0005-restconf-refactor-server-stop.patch similarity index 87% rename from package/rousette/0007-restconf-refactor-server-stop.patch rename to package/rousette/0005-restconf-refactor-server-stop.patch index 328b1682..1830546f 100644 --- a/package/rousette/0007-restconf-refactor-server-stop.patch +++ b/package/rousette/0005-restconf-refactor-server-stop.patch @@ -1,10 +1,7 @@ -From ca2894d4888c673d227fc196a25f83ded20e8f04 Mon Sep 17 00:00:00 2001 +From 5c8a139d04d9b3dfb28b8c0e1a4aa7b945a1e8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= Date: Mon, 30 Jun 2025 15:38:02 +0200 -Subject: [PATCH 07/17] restconf: refactor server stop -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +Subject: [PATCH 05/13] restconf: refactor server stop Organization: Wires In 94b24795 ("server: simplify listening/stopping") we needed to call @@ -20,7 +17,7 @@ does not seem like it should be called from *every* io_service.) [2] https://www.boost.org/doc/libs/1_85_0/doc/html/boost_asio/reference/post.html Change-Id: I2f33c38a78dce4081a03326c9a9bb25817fc9d2f -Signed-off-by: Mattias Walström +Signed-off-by: Joachim Wiberg --- src/restconf/Server.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/package/rousette/0010-http-send-keep-alive-pings-from-EventStream.patch b/package/rousette/0006-http-send-keep-alive-pings-from-EventStream.patch similarity index 98% rename from package/rousette/0010-http-send-keep-alive-pings-from-EventStream.patch rename to package/rousette/0006-http-send-keep-alive-pings-from-EventStream.patch index 6dd69f96..d26a23a3 100644 --- a/package/rousette/0010-http-send-keep-alive-pings-from-EventStream.patch +++ b/package/rousette/0006-http-send-keep-alive-pings-from-EventStream.patch @@ -1,10 +1,7 @@ -From 5becffe8a1dd47c8836ce1800a1b72acdf86021f Mon Sep 17 00:00:00 2001 +From 086cfe1847e406df90852dc3cb52ece3d0cbe22b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= Date: Mon, 12 May 2025 14:56:54 +0200 -Subject: [PATCH 10/17] http: send keep-alive pings from EventStream -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +Subject: [PATCH 06/13] http: send keep-alive pings from EventStream Organization: Wires The nghttp2-asio server disconnects client after 60 seconds of no @@ -31,7 +28,7 @@ to the server when the server sends these "keep-alive comments". [3] https://html.spec.whatwg.org/multipage/server-sent-events.html#authoring-notes Change-Id: I57e510d0b61ac7ed032c582779780c64768b7d53 -Signed-off-by: Mattias Walström +Signed-off-by: Joachim Wiberg --- src/clock.cpp | 4 +- src/http/EventStream.cpp | 44 +++++++++++++-- diff --git a/package/rousette/0011-refactor-event-streams-use-named-constructors.patch b/package/rousette/0007-refactor-event-streams-use-named-constructors.patch similarity index 97% rename from package/rousette/0011-refactor-event-streams-use-named-constructors.patch rename to package/rousette/0007-refactor-event-streams-use-named-constructors.patch index fc507e62..abe346d5 100644 --- a/package/rousette/0011-refactor-event-streams-use-named-constructors.patch +++ b/package/rousette/0007-refactor-event-streams-use-named-constructors.patch @@ -1,10 +1,7 @@ -From ff4ff1c193083feca76d9f0f4485e4b175c373c2 Mon Sep 17 00:00:00 2001 +From 06e2751e4da052195db96aaa90549fba398208bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= Date: Wed, 23 Jul 2025 14:27:26 +0200 -Subject: [PATCH 11/17] refactor: event streams use named constructors -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +Subject: [PATCH 07/13] refactor: event streams use named constructors Organization: Wires This commit refactors the EventStream and NotificationStream to use @@ -17,7 +14,7 @@ named constructors which perform the double initialization themselves. This way, the code is more readable and the intention should be clearer. Change-Id: Iac96c49c20670dfe924d7c8db33328ed9c2fc9dd -Signed-off-by: Mattias Walström +Signed-off-by: Joachim Wiberg --- src/clock.cpp | 3 +-- src/http/EventStream.cpp | 20 ++++++++++++++++++++ diff --git a/package/rousette/0012-refactor-a-better-convention-for-weak_from_this-lock.patch b/package/rousette/0008-refactor-a-better-convention-for-weak_from_this-lock.patch similarity index 93% rename from package/rousette/0012-refactor-a-better-convention-for-weak_from_this-lock.patch rename to package/rousette/0008-refactor-a-better-convention-for-weak_from_this-lock.patch index 8bdd105c..d02e9056 100644 --- a/package/rousette/0012-refactor-a-better-convention-for-weak_from_this-lock.patch +++ b/package/rousette/0008-refactor-a-better-convention-for-weak_from_this-lock.patch @@ -1,16 +1,13 @@ -From f4602a03adc9134a9b7a9d338e900b40557da6c4 Mon Sep 17 00:00:00 2001 +From e98e079d0fdedf48facbfcf187950946c1ffed7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Thu, 7 Aug 2025 12:14:02 +0200 -Subject: [PATCH 12/17] refactor: a better convention for weak_from_this->lock -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +Subject: [PATCH 08/13] refactor: a better convention for weak_from_this->lock Organization: Wires It is not a "client", so let's stop calling it a "client". My bad. Change-Id: Id8dc4d92c3ade8d86697366d0102e84bd466f504 -Signed-off-by: Mattias Walström +Signed-off-by: Joachim Wiberg --- src/http/EventStream.cpp | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/package/rousette/0008-tests-use-std-string-starts_with.patch b/package/rousette/0008-tests-use-std-string-starts_with.patch deleted file mode 100644 index 8c07b924..00000000 --- a/package/rousette/0008-tests-use-std-string-starts_with.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 9961430bacdd8dbac64a01b2a2ffb6a4b7e806b6 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= -Date: Tue, 13 May 2025 13:48:35 +0200 -Subject: [PATCH 08/17] tests: use std::string::starts_with -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit -Organization: Wires - -We are C++20, so we can use line, which is more readable. - -Change-Id: I40d4038b421f6bc1fcf320f609b50d5ce7018a45 -Signed-off-by: Mattias Walström ---- - tests/restconf_utils.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/restconf_utils.cpp b/tests/restconf_utils.cpp -index cbfce2c..08b9623 100644 ---- a/tests/restconf_utils.cpp -+++ b/tests/restconf_utils.cpp -@@ -228,7 +228,7 @@ std::vector SSEClient::parseEvents(const std::string& msg) - std::string event; - - while (std::getline(iss, line)) { -- if (line.compare(0, prefix.size(), prefix) == 0) { -+ if (line.starts_with(prefix)) { - event += line.substr(prefix.size()); - } else if (line.empty()) { - res.emplace_back(std::move(event)); --- -2.43.0 - diff --git a/package/rousette/0013-fix-a-possible-bad_weak_ptr-exception.patch b/package/rousette/0009-fix-a-possible-bad_weak_ptr-exception.patch similarity index 79% rename from package/rousette/0013-fix-a-possible-bad_weak_ptr-exception.patch rename to package/rousette/0009-fix-a-possible-bad_weak_ptr-exception.patch index 3c396813..99cbeade 100644 --- a/package/rousette/0013-fix-a-possible-bad_weak_ptr-exception.patch +++ b/package/rousette/0009-fix-a-possible-bad_weak_ptr-exception.patch @@ -1,15 +1,12 @@ -From 4e9b535a59861f25c0602eaa1fc39126d7cd9899 Mon Sep 17 00:00:00 2001 +From de7c55a1e8d3dda20ee3dc408612f2ddb309e888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Thu, 7 Aug 2025 12:21:54 +0200 -Subject: [PATCH 13/17] fix a possible bad_weak_ptr exception -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +Subject: [PATCH 09/13] fix a possible bad_weak_ptr exception Organization: Wires Change-Id: I8c7f7a943a1d848f15527988cb76c2a0a10089e6 Fixes: 4eae6200 (close long-lived connections on SIGTERM) -Signed-off-by: Mattias Walström +Signed-off-by: Joachim Wiberg --- src/http/EventStream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/rousette/0009-tests-add-SSE-event-watcher-for-comments.patch b/package/rousette/0009-tests-add-SSE-event-watcher-for-comments.patch deleted file mode 100644 index e83c5868..00000000 --- a/package/rousette/0009-tests-add-SSE-event-watcher-for-comments.patch +++ /dev/null @@ -1,172 +0,0 @@ -From 746c0cdfef6808f393be7946630b8acbb0636706 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= -Date: Tue, 22 Jul 2025 17:47:50 +0200 -Subject: [PATCH 09/17] tests: add SSE event watcher for comments -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit -Organization: Wires - -I want to test whether client receives even the Server Sent Events -which should be ignored, i.e., lines starting with colon. - -Change-Id: If54f0af05b4884aab01325f12fd0a6859791b41b -Signed-off-by: Mattias Walström ---- - tests/event_watchers.cpp | 7 ++++++- - tests/event_watchers.h | 4 +++- - tests/restconf_utils.cpp | 36 ++++++++++++++++++++---------------- - tests/restconf_utils.h | 12 +++++++++--- - 4 files changed, 38 insertions(+), 21 deletions(-) - -diff --git a/tests/event_watchers.cpp b/tests/event_watchers.cpp -index 690338e..26ba951 100644 ---- a/tests/event_watchers.cpp -+++ b/tests/event_watchers.cpp -@@ -64,7 +64,7 @@ void RestconfNotificationWatcher::setDataFormat(const libyang::DataFormat dataFo - this->dataFormat = dataFormat; - } - --void RestconfNotificationWatcher::operator()(const std::string& msg) const -+void RestconfNotificationWatcher::dataEvent(const std::string& msg) const - { - spdlog::trace("Client received data: {}", msg); - auto notifDataNode = ctx.parseOp(msg, -@@ -79,3 +79,8 @@ void RestconfNotificationWatcher::operator()(const std::string& msg) const - - data(*dataRoot->printStr(libyang::DataFormat::JSON, libyang::PrintFlags::Shrink)); - } -+ -+void RestconfNotificationWatcher::commentEvent(const std::string& msg) const -+{ -+ comment(msg); -+} -diff --git a/tests/event_watchers.h b/tests/event_watchers.h -index 3b533ba..7022b64 100644 ---- a/tests/event_watchers.h -+++ b/tests/event_watchers.h -@@ -39,8 +39,10 @@ struct RestconfNotificationWatcher { - - RestconfNotificationWatcher(const libyang::Context& ctx); - void setDataFormat(const libyang::DataFormat dataFormat); -- void operator()(const std::string& msg) const; -+ void dataEvent(const std::string& msg) const; -+ void commentEvent(const std::string& msg) const; - -+ MAKE_CONST_MOCK1(comment, void(const std::string&)); - MAKE_CONST_MOCK1(data, void(const std::string&)); - }; - -diff --git a/tests/restconf_utils.cpp b/tests/restconf_utils.cpp -index 08b9623..5b1ebe3 100644 ---- a/tests/restconf_utils.cpp -+++ b/tests/restconf_utils.cpp -@@ -169,10 +169,11 @@ SSEClient::SSEClient( - const std::string& server_address, - const std::string& server_port, - std::binary_semaphore& requestSent, -- const RestconfNotificationWatcher& notification, -+ const RestconfNotificationWatcher& eventWatcher, - const std::string& uri, - const std::map& headers, -- const boost::posix_time::seconds silenceTimeout) -+ const boost::posix_time::seconds silenceTimeout, -+ const ReportIgnoredLines reportIgnoredLines) - : client(std::make_shared(io, server_address, server_port)) - , t(io, silenceTimeout) - { -@@ -191,17 +192,15 @@ SSEClient::SSEClient( - } - }); - -- client->on_connect([&, uri, reqHeaders, silenceTimeout, server_address, server_port](auto) { -+ client->on_connect([&, uri, reqHeaders, silenceTimeout, server_address, server_port, reportIgnoredLines](auto) { - boost::system::error_code ec; - - auto req = client->submit(ec, "GET", serverAddressAndPort(server_address, server_port) + uri, "", reqHeaders); -- req->on_response([&, silenceTimeout](const ng_client::response& res) { -+ req->on_response([&, silenceTimeout, reportIgnoredLines](const ng_client::response& res) { - requestSent.release(); -- res.on_data([&, silenceTimeout](const uint8_t* data, std::size_t len) { -+ res.on_data([&, silenceTimeout, reportIgnoredLines](const uint8_t* data, std::size_t len) { - // not a production-ready code. In real-life condition the data received in one callback might probably be incomplete -- for (const auto& event : parseEvents(std::string(reinterpret_cast(data), len))) { -- notification(event); -- } -+ parseEvents(std::string(reinterpret_cast(data), len), eventWatcher, reportIgnoredLines); - t.expires_from_now(silenceTimeout); - }); - }); -@@ -218,25 +217,30 @@ SSEClient::SSEClient( - }); - } - --std::vector SSEClient::parseEvents(const std::string& msg) -+void SSEClient::parseEvents(const std::string& msg, const RestconfNotificationWatcher& eventWatcher, const ReportIgnoredLines reportIgnoredLines) - { -- static const std::string prefix = "data:"; -+ static const std::string dataPrefix = "data:"; -+ static const std::string ignorePrefix = ":"; - -- std::vector res; - std::istringstream iss(msg); - std::string line; - std::string event; - - while (std::getline(iss, line)) { -- if (line.starts_with(prefix)) { -- event += line.substr(prefix.size()); -- } else if (line.empty()) { -- res.emplace_back(std::move(event)); -+ if (line.starts_with(ignorePrefix) && reportIgnoredLines == ReportIgnoredLines::Yes) { -+ eventWatcher.commentEvent(line); -+ } else if (line.starts_with(ignorePrefix)) { -+ continue; -+ } else if (line.starts_with(dataPrefix)) { -+ event += line.substr(dataPrefix.size()); -+ } else if (line.empty() && !event.empty()) { -+ eventWatcher.dataEvent(event); - event.clear(); -+ } else if (line.empty()) { -+ continue; - } else { - CAPTURE(msg); - FAIL("Unprefixed response"); - } - } -- return res; - } -diff --git a/tests/restconf_utils.h b/tests/restconf_utils.h -index 9efe398..9dde10b 100644 ---- a/tests/restconf_utils.h -+++ b/tests/restconf_utils.h -@@ -88,17 +88,23 @@ struct SSEClient { - std::shared_ptr client; - boost::asio::deadline_timer t; - -+ enum class ReportIgnoredLines { -+ No, -+ Yes, -+ }; -+ - SSEClient( - boost::asio::io_service& io, - const std::string& server_address, - const std::string& server_port, - std::binary_semaphore& requestSent, -- const RestconfNotificationWatcher& notification, -+ const RestconfNotificationWatcher& eventWatcher, - const std::string& uri, - const std::map& headers, -- const boost::posix_time::seconds silenceTimeout = boost::posix_time::seconds(1)); // test code; the server should respond "soon" -+ const boost::posix_time::seconds silenceTimeout = boost::posix_time::seconds(1), // test code; the server should respond "soon" -+ const ReportIgnoredLines reportIgnoredLines = ReportIgnoredLines::No); - -- static std::vector parseEvents(const std::string& msg); -+ static void parseEvents(const std::string& msg, const RestconfNotificationWatcher& eventWatcher, const ReportIgnoredLines reportIgnoredLines); - }; - - #define PREPARE_LOOP_WITH_EXCEPTIONS \ --- -2.43.0 - diff --git a/package/rousette/0014-http-add-optional-callbacks-to-EventStream.patch b/package/rousette/0010-http-add-optional-callbacks-to-EventStream.patch similarity index 95% rename from package/rousette/0014-http-add-optional-callbacks-to-EventStream.patch rename to package/rousette/0010-http-add-optional-callbacks-to-EventStream.patch index efab0a1d..5ffb3bee 100644 --- a/package/rousette/0014-http-add-optional-callbacks-to-EventStream.patch +++ b/package/rousette/0010-http-add-optional-callbacks-to-EventStream.patch @@ -1,10 +1,7 @@ -From 6bca750f866b5b14c4d9c3da68e5c8f1e4eee36c Mon Sep 17 00:00:00 2001 +From 0f034d6da3e6d0a91bbe09717cb33aaf3a3ed747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= Date: Mon, 19 May 2025 12:11:09 +0200 -Subject: [PATCH 14/17] http: add optional callbacks to EventStream -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +Subject: [PATCH 10/13] http: add optional callbacks to EventStream Organization: Wires In some cases, it might be useful to have a callback that is called when @@ -14,7 +11,7 @@ implementation where we would like to clean up stuff after client disconnects. Change-Id: Icfc2959e38b812b7c18f45976415209b29151c7b -Signed-off-by: Mattias Walström +Signed-off-by: Joachim Wiberg --- src/http/EventStream.cpp | 18 +++++++++++++++--- src/http/EventStream.h | 10 ++++++++-- diff --git a/package/rousette/0015-restconf-add-internal-RPC-handler-dispatcher.patch b/package/rousette/0011-restconf-add-internal-RPC-handler-dispatcher.patch similarity index 93% rename from package/rousette/0015-restconf-add-internal-RPC-handler-dispatcher.patch rename to package/rousette/0011-restconf-add-internal-RPC-handler-dispatcher.patch index 6d703c2d..4aa75f32 100644 --- a/package/rousette/0015-restconf-add-internal-RPC-handler-dispatcher.patch +++ b/package/rousette/0011-restconf-add-internal-RPC-handler-dispatcher.patch @@ -1,10 +1,7 @@ -From f6ee629de8abef42a24c42b185052b0c8e78bd6b Mon Sep 17 00:00:00 2001 +From d72adb3da31cb509e64c8f33174e375fa9468b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= Date: Mon, 19 May 2025 12:23:16 +0200 -Subject: [PATCH 15/17] restconf: add internal RPC handler dispatcher -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +Subject: [PATCH 11/13] restconf: add internal RPC handler dispatcher Organization: Wires This code adds a new internal RPC handler dispatcher that checks if user @@ -14,7 +11,7 @@ So far, there are no RPCs processed, but support for the ietf-subscribed-notifications:establish-subscription RPC is coming soon. Change-Id: I99121a511011229e4098f95e91601b39d333444a -Signed-off-by: Mattias Walström +Signed-off-by: Joachim Wiberg --- src/restconf/Server.cpp | 24 ++++++++++++++++++++---- tests/restconf-rpc.cpp | 18 ++++++++++++++++++ diff --git a/package/rousette/0017-EventStream-fix-possible-heap-use-after-free.patch b/package/rousette/0012-EventStream-fix-possible-heap-use-after-free.patch similarity index 98% rename from package/rousette/0017-EventStream-fix-possible-heap-use-after-free.patch rename to package/rousette/0012-EventStream-fix-possible-heap-use-after-free.patch index 205af21b..e0069ede 100644 --- a/package/rousette/0017-EventStream-fix-possible-heap-use-after-free.patch +++ b/package/rousette/0012-EventStream-fix-possible-heap-use-after-free.patch @@ -1,10 +1,7 @@ -From 1067e05674633b97d64b428686aff44822230c5f Mon Sep 17 00:00:00 2001 +From 86ea8a1fdc2cb8baa1edbd32bd4f8b45acdef816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= Date: Mon, 8 Sep 2025 20:24:15 +0200 -Subject: [PATCH 17/17] EventStream: fix possible heap-use-after-free -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +Subject: [PATCH 12/13] EventStream: fix possible heap-use-after-free Organization: Wires I have started getting heap-use-after-free errors from sanitizers (see @@ -64,7 +61,7 @@ before actually resuming the response. (...) Change-Id: Ifdb1f8610cacffca3bb49da17aa9b1d267cdd472 -Signed-off-by: Mattias Walström +Signed-off-by: Joachim Wiberg --- src/http/EventStream.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/package/rousette/0016-tests-processing-incomplete-events-in-SSE-client.patch b/package/rousette/0016-tests-processing-incomplete-events-in-SSE-client.patch deleted file mode 100644 index 916aede4..00000000 --- a/package/rousette/0016-tests-processing-incomplete-events-in-SSE-client.patch +++ /dev/null @@ -1,120 +0,0 @@ -From b7966613b43b01402c9f0af286a0b3237161779d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= -Date: Tue, 2 Sep 2025 15:33:43 +0200 -Subject: [PATCH 16/17] tests: processing incomplete events in SSE client -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit -Organization: Wires - -During my testing I noticed that I obtained incomplete message in -on_data callback. The message was split into two callbacks. -This commit fixes the FIXME by buffering the data and processing -a complete event, once available. - -Change-Id: Ied07e69e8b518f20fcc82134a4c041e7ec3a06d6 -Signed-off-by: Mattias Walström ---- - tests/restconf_utils.cpp | 53 +++++++++++++++++++++++----------------- - tests/restconf_utils.h | 3 ++- - 2 files changed, 33 insertions(+), 23 deletions(-) - -diff --git a/tests/restconf_utils.cpp b/tests/restconf_utils.cpp -index 5b1ebe3..740b1fa 100644 ---- a/tests/restconf_utils.cpp -+++ b/tests/restconf_utils.cpp -@@ -199,8 +199,8 @@ SSEClient::SSEClient( - req->on_response([&, silenceTimeout, reportIgnoredLines](const ng_client::response& res) { - requestSent.release(); - res.on_data([&, silenceTimeout, reportIgnoredLines](const uint8_t* data, std::size_t len) { -- // not a production-ready code. In real-life condition the data received in one callback might probably be incomplete -- parseEvents(std::string(reinterpret_cast(data), len), eventWatcher, reportIgnoredLines); -+ dataBuffer.append(std::string(reinterpret_cast(data), len)); -+ parseEvents(eventWatcher, reportIgnoredLines); - t.expires_from_now(silenceTimeout); - }); - }); -@@ -217,30 +217,39 @@ SSEClient::SSEClient( - }); - } - --void SSEClient::parseEvents(const std::string& msg, const RestconfNotificationWatcher& eventWatcher, const ReportIgnoredLines reportIgnoredLines) -+void SSEClient::parseEvents(const RestconfNotificationWatcher& eventWatcher, const ReportIgnoredLines reportIgnoredLines) - { - static const std::string dataPrefix = "data:"; - static const std::string ignorePrefix = ":"; - -- std::istringstream iss(msg); -- std::string line; -- std::string event; -- -- while (std::getline(iss, line)) { -- if (line.starts_with(ignorePrefix) && reportIgnoredLines == ReportIgnoredLines::Yes) { -- eventWatcher.commentEvent(line); -- } else if (line.starts_with(ignorePrefix)) { -- continue; -- } else if (line.starts_with(dataPrefix)) { -- event += line.substr(dataPrefix.size()); -- } else if (line.empty() && !event.empty()) { -- eventWatcher.dataEvent(event); -- event.clear(); -- } else if (line.empty()) { -- continue; -- } else { -- CAPTURE(msg); -- FAIL("Unprefixed response"); -+ std::size_t pos = 0; -+ constexpr auto EVENT_SEPARATOR = "\n\n"; // FIXME: Not a production-ready code; does not deal with all possible newline combinations of CR and LF -+ -+ while ((pos = dataBuffer.find(EVENT_SEPARATOR)) != std::string::npos) { -+ // extract event -+ auto rawEvent = dataBuffer.substr(0, pos + std::char_traits::length(EVENT_SEPARATOR)); -+ std::istringstream stream(rawEvent); -+ dataBuffer.erase(0, pos + std::char_traits::length(EVENT_SEPARATOR)); -+ -+ // split on newlines -+ std::string line; -+ std::string event; -+ while (std::getline(stream, line)) { -+ if (line.starts_with(ignorePrefix) && reportIgnoredLines == ReportIgnoredLines::Yes) { -+ eventWatcher.commentEvent(line); -+ } else if (line.starts_with(ignorePrefix)) { -+ continue; -+ } else if (line.starts_with(dataPrefix)) { -+ event += line.substr(dataPrefix.size()); -+ } else if (line.empty() && !event.empty()) { -+ eventWatcher.dataEvent(event); -+ event.clear(); -+ } else if (line.empty()) { -+ continue; -+ } else { -+ CAPTURE(rawEvent); -+ FAIL("Unprefixed response"); -+ } - } - } - } -diff --git a/tests/restconf_utils.h b/tests/restconf_utils.h -index 9dde10b..c35df54 100644 ---- a/tests/restconf_utils.h -+++ b/tests/restconf_utils.h -@@ -87,6 +87,7 @@ void setupRealNacm(sysrepo::Session session); - struct SSEClient { - std::shared_ptr client; - boost::asio::deadline_timer t; -+ std::string dataBuffer; - - enum class ReportIgnoredLines { - No, -@@ -104,7 +105,7 @@ struct SSEClient { - const boost::posix_time::seconds silenceTimeout = boost::posix_time::seconds(1), // test code; the server should respond "soon" - const ReportIgnoredLines reportIgnoredLines = ReportIgnoredLines::No); - -- static void parseEvents(const std::string& msg, const RestconfNotificationWatcher& eventWatcher, const ReportIgnoredLines reportIgnoredLines); -+ void parseEvents(const RestconfNotificationWatcher& eventWatcher, const ReportIgnoredLines reportIgnoredLines); - }; - - #define PREPARE_LOOP_WITH_EXCEPTIONS \ --- -2.43.0 - diff --git a/package/rousette/Config.in b/package/rousette/Config.in index ae104321..b5da8bc6 100644 --- a/package/rousette/Config.in +++ b/package/rousette/Config.in @@ -13,4 +13,6 @@ config BR2_PACKAGE_ROUSETTE select BR2_PACKAGE_SYSREPO_CPP select BR2_PACKAGE_DATE help - RESTconf server + A RESTCONF server for sysrepo + + https://github.com/CESNET/rousette