From 56ae875861ab260b80a030f50c4aff9f9dc8fff0 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:32:39 +0200 Subject: Adding upstream version 2.14.2. Signed-off-by: Daniel Baumann --- lib/remote/consolehandler.hpp | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 lib/remote/consolehandler.hpp (limited to 'lib/remote/consolehandler.hpp') diff --git a/lib/remote/consolehandler.hpp b/lib/remote/consolehandler.hpp new file mode 100644 index 0000000..df0d77d --- /dev/null +++ b/lib/remote/consolehandler.hpp @@ -0,0 +1,50 @@ +/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ + +#ifndef CONSOLEHANDLER_H +#define CONSOLEHANDLER_H + +#include "remote/httphandler.hpp" +#include "base/scriptframe.hpp" + +namespace icinga +{ + +struct ApiScriptFrame +{ + double Seen{0}; + int NextLine{1}; + std::map Lines; + Dictionary::Ptr Locals; +}; + +class ConsoleHandler final : public HttpHandler +{ +public: + DECLARE_PTR_TYPEDEFS(ConsoleHandler); + + bool HandleRequest( + AsioTlsStream& stream, + const ApiUser::Ptr& user, + boost::beast::http::request& request, + const Url::Ptr& url, + boost::beast::http::response& response, + const Dictionary::Ptr& params, + boost::asio::yield_context& yc, + HttpServerConnection& server + ) override; + + static std::vector GetAutocompletionSuggestions(const String& word, ScriptFrame& frame); + +private: + static bool ExecuteScriptHelper(boost::beast::http::request& request, + boost::beast::http::response& response, + const Dictionary::Ptr& params, const String& command, const String& session, bool sandboxed); + static bool AutocompleteScriptHelper(boost::beast::http::request& request, + boost::beast::http::response& response, + const Dictionary::Ptr& params, const String& command, const String& session, bool sandboxed); + +}; + +} + +#endif /* CONSOLEHANDLER_H */ -- cgit v1.2.3