From d9741c7c807e4dd5fccf9bda90d36450c77d2e26 Mon Sep 17 00:00:00 2001 From: natenichols Date: Tue, 11 Jan 2022 19:27:38 -0600 Subject: [PATCH] Set X-User header where clio is a websocket client --- src/etl/ETLSource.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/etl/ETLSource.cpp b/src/etl/ETLSource.cpp index a0d563de1..b37f28738 100644 --- a/src/etl/ETLSource.cpp +++ b/src/etl/ETLSource.cpp @@ -247,7 +247,9 @@ PlainETLSource::onConnect( req.set( boost::beast::http::field::user_agent, std::string(BOOST_BEAST_VERSION_STRING) + - " websocket-client-async"); + " coro-client"); + + req.set("X-User", "coro-client"); })); // Update the host_ string. This will provide the value of the @@ -291,7 +293,9 @@ SslETLSource::onConnect( req.set( boost::beast::http::field::user_agent, std::string(BOOST_BEAST_VERSION_STRING) + - " websocket-client-async"); + " clio-client"); + + req.set("X-User", "coro-client"); })); // Update the host_ string. This will provide the value of the @@ -342,6 +346,18 @@ ETLSourceImpl::onHandshake(boost::beast::error_code ec) {"ledger", "manifests", "validations", "transactions_proposed"}}}; std::string s = boost::json::serialize(jv); BOOST_LOG_TRIVIAL(trace) << "Sending subscribe stream message"; + + derived().ws().set_option( + boost::beast::websocket::stream_base::decorator( + [](boost::beast::websocket::request_type& req) { + req.set( + boost::beast::http::field::user_agent, + std::string(BOOST_BEAST_VERSION_STRING) + + "clio-client"); + + req.set("X-User", "coro-client"); + })); + // Send the message derived().ws().async_write( boost::asio::buffer(s),