mirror of
https://github.com/falcosecurity/falco.git
synced 2025-06-27 15:17:50 +00:00
new(userspace/falco): add webserver endpoint for retrieving internal versions
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
This commit is contained in:
parent
ea48ec70be
commit
55a6436ee8
@ -34,6 +34,7 @@ application::run_result application::start_webserver()
|
|||||||
+ ssl_option + "\n");
|
+ ssl_option + "\n");
|
||||||
|
|
||||||
m_state->webserver.start(
|
m_state->webserver.start(
|
||||||
|
m_state->offline_inspector,
|
||||||
m_state->config->m_webserver_threadiness,
|
m_state->config->m_webserver_threadiness,
|
||||||
m_state->config->m_webserver_listen_port,
|
m_state->config->m_webserver_listen_port,
|
||||||
m_state->config->m_webserver_k8s_healthz_endpoint,
|
m_state->config->m_webserver_k8s_healthz_endpoint,
|
||||||
|
@ -16,6 +16,7 @@ limitations under the License.
|
|||||||
|
|
||||||
#include "webserver.h"
|
#include "webserver.h"
|
||||||
#include "falco_utils.h"
|
#include "falco_utils.h"
|
||||||
|
#include "versions_info.h"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
falco_webserver::~falco_webserver()
|
falco_webserver::~falco_webserver()
|
||||||
@ -24,6 +25,7 @@ falco_webserver::~falco_webserver()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void falco_webserver::start(
|
void falco_webserver::start(
|
||||||
|
const std::shared_ptr<sinsp>& inspector,
|
||||||
uint32_t threadiness,
|
uint32_t threadiness,
|
||||||
uint32_t listen_port,
|
uint32_t listen_port,
|
||||||
std::string& healthz_endpoint,
|
std::string& healthz_endpoint,
|
||||||
@ -57,6 +59,13 @@ void falco_webserver::start(
|
|||||||
res.set_content("{\"status\": \"ok\"}", "application/json");
|
res.set_content("{\"status\": \"ok\"}", "application/json");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// setup versions endpoint
|
||||||
|
const auto versions_json_str = falco::versions_info(inspector).as_json().dump();
|
||||||
|
m_server->Get("/versions",
|
||||||
|
[versions_json_str](const httplib::Request &, httplib::Response &res) {
|
||||||
|
res.set_content(versions_json_str, "application/json");
|
||||||
|
});
|
||||||
|
|
||||||
// run server in a separate thread
|
// run server in a separate thread
|
||||||
if (!m_server->is_valid())
|
if (!m_server->is_valid())
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,8 @@ limitations under the License.
|
|||||||
#define CPPHTTPLIB_ZLIB_SUPPORT
|
#define CPPHTTPLIB_ZLIB_SUPPORT
|
||||||
#include <httplib.h>
|
#include <httplib.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <memory>
|
||||||
|
#include <sinsp.h>
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
class falco_webserver
|
class falco_webserver
|
||||||
@ -26,6 +28,7 @@ class falco_webserver
|
|||||||
public:
|
public:
|
||||||
virtual ~falco_webserver();
|
virtual ~falco_webserver();
|
||||||
virtual void start(
|
virtual void start(
|
||||||
|
const std::shared_ptr<sinsp>& inspector,
|
||||||
uint32_t threadiness,
|
uint32_t threadiness,
|
||||||
uint32_t listen_port,
|
uint32_t listen_port,
|
||||||
std::string& healthz_endpoint,
|
std::string& healthz_endpoint,
|
||||||
|
Loading…
Reference in New Issue
Block a user