diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b1cccf8dc..14cf66ac19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,13 +122,13 @@ if (LINTEL_FOUND AND DATASERIES_FOUND AND LIBXML2_FOUND) list(APPEND OPTLIBS ${LibXML2_LIBRARIES}) endif() -set(USE_LIBCURL false) +set(USE_CURL false) find_package(CURL) if (CURL_FOUND) - set(USE_LIBCURL true) + set(USE_CURL true) include_directories(BEFORE ${CURL_INCLUDE_DIR}) list(APPEND OPTLIBS ${CURL_LIBRARIES}) - set(INSTALL_ELASTICSEARCH true) + set(USE_ELASTICSEARCH true) endif() if (ENABLE_PERFTOOLS_DEBUG) @@ -218,13 +218,14 @@ message( "\nBroccoli: ${INSTALL_BROCCOLI}" "\nBroctl: ${INSTALL_BROCTL}" "\nAux. Tools: ${INSTALL_AUX_TOOLS}" - "\nElasticSearch: ${INSTALL_ELASTICSEARCH}" "\n" "\nGeoIP: ${USE_GEOIP}" "\nGoogle perftools: ${USE_PERFTOOLS}" "\n debugging: ${USE_PERFTOOLS_DEBUG}" + "\ncURL: ${USE_CURL}" + "\n" "\nDataSeries: ${USE_DATASERIES}" - "\nlibCURL: ${USE_LIBCURL}" + "\nElasticSearch: ${USE_ELASTICSEARCH}" "\n" "\n================================================================\n" ) diff --git a/config.h.in b/config.h.in index 66121cefbf..aa286736fd 100644 --- a/config.h.in +++ b/config.h.in @@ -114,11 +114,14 @@ /* Analyze Mobile IPv6 traffic */ #cmakedefine ENABLE_MOBILE_IPV6 +/* Use libCurl. */ +#cmakedefine USE_CURL + /* Use the DataSeries writer. */ #cmakedefine USE_DATASERIES -/* Build the ElasticSearch writer. */ -#cmakedefine INSTALL_ELASTICSEARCH +/* Use the ElasticSearch writer. */ +#cmakedefine USE_ELASTICSEARCH /* Version number of package */ #define VERSION "@VERSION@" diff --git a/configure b/configure index 801fb1e801..3258d4abfc 100755 --- a/configure +++ b/configure @@ -98,7 +98,6 @@ append_cache_entry BRO_SCRIPT_INSTALL_PATH STRING $prefix/share/bro append_cache_entry BRO_ETC_INSTALL_DIR PATH $prefix/etc append_cache_entry ENABLE_DEBUG BOOL false append_cache_entry ENABLE_PERFTOOLS_DEBUG BOOL false -append_cache_entry INSTALL_ELASTICSEARCH BOOL false append_cache_entry BinPAC_SKIP_INSTALL BOOL true append_cache_entry BUILD_SHARED_LIBS BOOL true append_cache_entry INSTALL_AUX_TOOLS BOOL true diff --git a/doc/logging-elasticsearch.rst b/doc/logging-elasticsearch.rst index 4fce470d4a..26b49f3a0b 100644 --- a/doc/logging-elasticsearch.rst +++ b/doc/logging-elasticsearch.rst @@ -26,16 +26,15 @@ ElasticSearch with:: Compiling Bro with ElasticSearch Support ---------------------------------------- -First, ensure that you have libcurl installed. Secondly, set the -``--enable-elasticsearch`` option:: +First, ensure that you have libcurl installed the run configure.:: - # ./configure --enable-elasticsearch + # ./configure [...] ====================| Bro Build Summary |===================== [...] - ElasticSearch: true + cURL: true [...] - libCURL: true + ElasticSearch: true [...] ================================================================ diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 5c1203fd91..5562b3b867 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -17,7 +17,7 @@ #include "writers/Ascii.h" #include "writers/None.h" -#ifdef INSTALL_ELASTICSEARCH +#ifdef USE_ELASTICSEARCH #include "writers/ElasticSearch.h" #endif @@ -40,7 +40,7 @@ WriterDefinition log_writers[] = { { BifEnum::Log::WRITER_NONE, "None", 0, writer::None::Instantiate }, { BifEnum::Log::WRITER_ASCII, "Ascii", 0, writer::Ascii::Instantiate }, -#ifdef INSTALL_ELASTICSEARCH +#ifdef USE_ELASTICSEARCH { BifEnum::Log::WRITER_ELASTICSEARCH, "ElasticSearch", 0, writer::ElasticSearch::Instantiate }, #endif diff --git a/src/logging/writers/ElasticSearch.cc b/src/logging/writers/ElasticSearch.cc index 402a2f21ad..494c48f286 100644 --- a/src/logging/writers/ElasticSearch.cc +++ b/src/logging/writers/ElasticSearch.cc @@ -2,7 +2,7 @@ #include "config.h" -#ifdef INSTALL_ELASTICSEARCH +#ifdef USE_ELASTICSEARCH #include #include @@ -261,7 +261,7 @@ CURL* ElasticSearch::HTTPSetup() // HTTP 1.1 likes to use chunked encoded transfers, which aren't good for speed. The best (only?) way to disable that is to // just use HTTP 1.0 - curl_easy_setopt(handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + //curl_easy_setopt(handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); return handle; } @@ -275,8 +275,8 @@ bool ElasticSearch::HTTPSend() { CURLcode return_code; + curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE_LARGE, buffer.Len()); curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, buffer.Bytes()); - curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE, buffer.Len()); return_code = curl_easy_perform(curl_handle); switch ( return_code ) diff --git a/src/main.cc b/src/main.cc index b1d0a4d723..04aa83b832 100644 --- a/src/main.cc +++ b/src/main.cc @@ -12,6 +12,10 @@ #include #endif +#ifdef USE_CURL +#include +#endif + #ifdef USE_IDMEF extern "C" { #include @@ -716,6 +720,10 @@ int main(int argc, char** argv) SSL_library_init(); SSL_load_error_strings(); +#ifdef USE_CURL + curl_global_init(CURL_GLOBAL_ALL); +#endif + // FIXME: On systems that don't provide /dev/urandom, OpenSSL doesn't // seed the PRNG. We should do this here (but at least Linux, FreeBSD // and Solaris provide /dev/urandom). @@ -1066,6 +1074,10 @@ int main(int argc, char** argv) done_with_network(); net_delete(); +#ifdef USE_CURL + curl_global_cleanup(); +#endif + terminate_bro(); // Close files after net_delete(), because net_delete()