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

#include <DBHandler.h>

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

Public Member Functions

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

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

Constructor & Destructor Documentation

TrackingProcessor::TrackingProcessor ( mapd::shared_ptr< OmniSciIf >  handler,
const bool  check_origin 
)
inline

Definition at line 110 of file DBHandler.h.

111  : OmniSciProcessor(handler), check_origin_(check_origin) {}
const bool check_origin_
Definition: DBHandler.h:152

Member Function Documentation

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

Definition at line 113 of file DBHandler.h.

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

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

thread_local std::string TrackingProcessor::client_address
static

Definition at line 148 of file DBHandler.h.

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

thread_local ClientProtocol TrackingProcessor::client_protocol
static

Definition at line 149 of file DBHandler.h.

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


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