OmniSciDB  c1a53651b2
 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 115 of file DBHandler.h.

Constructor & Destructor Documentation

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

Definition at line 117 of file DBHandler.h.

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

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 120 of file DBHandler.h.

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

122  {
123  using namespace ::apache::thrift;
124 
125  auto transport = in->getTransport();
126  if (transport && check_origin_) {
127  static std::mutex processor_mutex;
128  std::lock_guard lock(processor_mutex);
129  const auto origin_str = transport->getOrigin();
130  std::vector<std::string> origins;
131  boost::split(origins, origin_str, boost::is_any_of(","));
132  if (origins.empty()) {
134  } else {
135  // Take the first origin, which should be the client IP before any intermediate
136  // servers (e.g. the web server)
137  auto trimmed_origin = origins.front();
138  boost::algorithm::trim(trimmed_origin);
139  TrackingProcessor::client_address = trimmed_origin;
140  }
141  if (dynamic_cast<transport::THttpTransport*>(transport.get())) {
143  } else if (dynamic_cast<transport::TBufferedTransport*>(transport.get())) {
145  } else {
147  }
148  } else {
150  }
151 
152  return HeavyProcessor::process(in, out, connectionContext);
153  }
std::lock_guard< T > lock_guard
static thread_local std::string client_address
Definition: DBHandler.h:155
static thread_local ClientProtocol client_protocol
Definition: DBHandler.h:156
const bool check_origin_
Definition: DBHandler.h:159
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 159 of file DBHandler.h.

thread_local std::string TrackingProcessor::client_address
static

Definition at line 155 of file DBHandler.h.

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

thread_local ClientProtocol TrackingProcessor::client_protocol
static

Definition at line 156 of file DBHandler.h.

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


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