OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackingProcessor Class Reference

#include <DBHandler.h>

+ Inheritance diagram for TrackingProcessor:
+ Collaboration diagram for TrackingProcessor:

Public Member Functions

 TrackingProcessor (std::shared_ptr< HeavyIf > handler, const bool check_origin)
 
bool process (std::shared_ptr<::apache::thrift::protocol::TProtocol > in, std::shared_ptr<::apache::thrift::protocol::TProtocol > out, void *connectionContext) override
 

Static Public Attributes

static thread_local std::string client_address
 
static thread_local ClientProtocol client_protocol
 

Private Attributes

const bool check_origin_
 

Detailed Description

Definition at line 114 of file DBHandler.h.

Constructor & Destructor Documentation

TrackingProcessor::TrackingProcessor ( std::shared_ptr< HeavyIf >  handler,
const bool  check_origin 
)
inline

Definition at line 116 of file DBHandler.h.

117  : HeavyProcessor(handler), check_origin_(check_origin) {}
const bool check_origin_
Definition: DBHandler.h:158

Member Function Documentation

bool TrackingProcessor::process ( std::shared_ptr<::apache::thrift::protocol::TProtocol >  in,
std::shared_ptr<::apache::thrift::protocol::TProtocol >  out,
void *  connectionContext 
)
inlineoverride

Definition at line 119 of file DBHandler.h.

References client_address, client_protocol, HTTP, Other, split(), and TCP.

121  {
122  using namespace ::apache::thrift;
123 
124  auto transport = in->getTransport();
125  if (transport && check_origin_) {
126  static std::mutex processor_mutex;
127  std::lock_guard lock(processor_mutex);
128  const auto origin_str = transport->getOrigin();
129  std::vector<std::string> origins;
130  boost::split(origins, origin_str, boost::is_any_of(","));
131  if (origins.empty()) {
133  } else {
134  // Take the first origin, which should be the client IP before any intermediate
135  // servers (e.g. the web server)
136  auto trimmed_origin = origins.front();
137  boost::algorithm::trim(trimmed_origin);
138  TrackingProcessor::client_address = trimmed_origin;
139  }
140  if (dynamic_cast<transport::THttpTransport*>(transport.get())) {
142  } else if (dynamic_cast<transport::TBufferedTransport*>(transport.get())) {
144  } else {
146  }
147  } else {
149  }
150 
151  return HeavyProcessor::process(in, out, connectionContext);
152  }
std::lock_guard< T > lock_guard
static thread_local std::string client_address
Definition: DBHandler.h:154
static thread_local ClientProtocol client_protocol
Definition: DBHandler.h:155
const bool check_origin_
Definition: DBHandler.h:158
std::vector< std::string > split(std::string_view str, std::string_view delim, std::optional< size_t > maxsplit)
split apart a string into a vector of substrings

+ Here is the call graph for this function:

Member Data Documentation

const bool TrackingProcessor::check_origin_
private

Definition at line 158 of file DBHandler.h.

thread_local std::string TrackingProcessor::client_address
static

Definition at line 154 of file DBHandler.h.

Referenced by DBHandler::getConnectionInfo(), and process().

thread_local ClientProtocol TrackingProcessor::client_protocol
static

Definition at line 155 of file DBHandler.h.

Referenced by DBHandler::getConnectionInfo(), and process().


The documentation for this class was generated from the following files: