drogon
C++14/17-based HTTP application framework
Loading...
Searching...
No Matches
drogon::plugin::RealIpResolver Class Reference

This plugin is used to resolve client real ip from HTTP request. More...

#include <drogon/plugins/RealIpResolver.h>

Inheritance diagram for drogon::plugin::RealIpResolver:
Collaboration diagram for drogon::plugin::RealIpResolver:

Public Member Functions

void initAndStart (const Json::Value &config) override
void shutdown () override
Public Member Functions inherited from drogon::PluginBase
void initialize ()
 This method must be called by drogon.
Public Member Functions inherited from drogon::DrObject< RealIpResolver >
const std::string & className () const override
 Get the class name.
bool isClass (const std::string &class_name) const override
 Return true if the class name is 'class_name'.

Static Public Member Functions

static const trantor::InetAddress & GetRealAddr (const drogon::HttpRequestPtr &req)
Static Public Member Functions inherited from drogon::DrObject< RealIpResolver >
static const std::string & classTypeName ()

Friends

class Hodor

Detailed Description

This plugin is used to resolve client real ip from HTTP request.

Note
This plugin currently supports only ipv4 address or cidr.

The json configuration is as follows:

{
"name": "drogon::plugin::RealIpResolver",
"dependencies": [],
"config": {
// Trusted proxy ip or cidr
"trust_ips": ["127.0.0.1", "172.16.0.0/12"],
// Which header to parse ip form. Default is x-forwarded-for
"from_header": "x-forwarded-for",
// The result will be inserted to HttpRequest attribute map with this
// key. Default is "real-ip"
"attribute_key": "real-ip"
}
}

Enable the plugin by adding the configuration to the list of plugins in the configuration file.

Member Function Documentation

◆ initAndStart()

void drogon::plugin::RealIpResolver::initAndStart ( const Json::Value & config)
overridevirtual

This method must be called by drogon to initialize and start the plugin. It must be implemented by the user.

Implements drogon::PluginBase.

◆ shutdown()

void drogon::plugin::RealIpResolver::shutdown ( )
overridevirtual

This method must be called by drogon to shutdown the plugin. It must be implemented by the user.

Implements drogon::PluginBase.


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