Skip to content

Commit

Permalink
cleanup(libsinsp): make user agent string parametrized
Browse files Browse the repository at this point in the history
Signed-off-by: lucklypse <[email protected]>
  • Loading branch information
LucaGuerra authored and poiana committed Sep 22, 2021
1 parent 4d9c85e commit 5727c45
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cmake/modules/libsinsp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ option(USE_BUNDLED_DEPS "Enable bundled dependencies instead of using the system

option(WITH_CHISEL "Include chisel implementation" OFF)

if(DEFINED LIBSINSP_USER_AGENT)
add_definitions(-DLIBSINSP_USER_AGENT="${LIBSINSP_USER_AGENT}")
endif()

include(ExternalProject)
include(libscap)
if(NOT WIN32)
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/mesos_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ std::string mesos_http::make_request(uri url, curl_version_info_data* curl_versi
{
request << '?' << query;
}
request << " HTTP/1.1\r\nConnection: Keep-Alive\r\nUser-Agent: sysdig";
request << " HTTP/1.1\r\nConnection: Keep-Alive\r\nUser-Agent: " LIBSINSP_USER_AGENT;
if(curl_version && curl_version->version)
{
request << " (curl " << curl_version->version << ')';
Expand Down
8 changes: 8 additions & 0 deletions userspace/libsinsp/sinsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ class metadata_download_params
uint32_t m_data_watch_freq_sec = METADATA_DATA_WATCH_FREQ_SEC;
};

/*!
\brief The user agent string to use for any libsinsp connection, can be changed at compile time
*/

#if !defined(LIBSINSP_USER_AGENT)
#define LIBSINSP_USER_AGENT "falcosecurity-libs"
#endif // LIBSINSP_USER_AGENT

/*!
\brief The default way an event is converted to string by the library
*/
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/socket_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class socket_data_handler
{
request << '?' << query;
}
request << " HTTP/" << http_version << "\r\n" << m_keep_alive << "User-Agent: sysdig\r\n";
request << " HTTP/" << http_version << "\r\n" << m_keep_alive << "User-Agent: " LIBSINSP_USER_AGENT "\r\n";
if(!host_and_port.empty())
{
request << "Host: " << host_and_port << "\r\n";
Expand Down

0 comments on commit 5727c45

Please sign in to comment.