drogon
C++14/17-based HTTP application framework
Toggle main menu visibility
Loading...
Searching...
No Matches
RealIpResolver.h
1
6
7
#pragma once
8
9
#include <
drogon/plugins/Plugin.h
>
10
#include <trantor/net/InetAddress.h>
11
#include <
drogon/HttpRequest.h
>
12
#include <vector>
13
14
namespace
drogon
15
{
16
namespace
plugin
17
{
44
class
DROGON_EXPORT RealIpResolver :
public
drogon::Plugin
<RealIpResolver>
45
{
46
public
:
47
RealIpResolver()
48
{
49
}
50
51
void
initAndStart
(
const
Json::Value &config)
override
;
52
void
shutdown
()
override
;
53
54
static
const
trantor::InetAddress &GetRealAddr(
55
const
drogon::HttpRequestPtr &req);
56
57
private
:
58
const
trantor::InetAddress &getRealAddr(
59
const
drogon::HttpRequestPtr &req)
const
;
60
61
struct
CIDR
62
{
63
explicit
CIDR(
const
std::string &ipOrCidr);
64
in_addr_t addr_{0};
65
in_addr_t mask_{32};
66
};
67
68
using
CIDRs = std::vector<CIDR>;
69
static
bool
matchCidr(
const
trantor::InetAddress &addr,
70
const
CIDRs &trustCIDRs);
71
72
friend
class
Hodor;
73
CIDRs trustCIDRs_;
74
std::string fromHeader_;
75
std::string attributeKey_;
76
bool
useXForwardedFor_{
false
};
77
};
78
}
// namespace plugin
79
}
// namespace drogon
HttpRequest.h
Plugin.h
drogon::Plugin
The reflection base class for plugins.
Definition
Plugin.h:132
drogon::plugin::RealIpResolver::shutdown
void shutdown() override
drogon::plugin::RealIpResolver::initAndStart
void initAndStart(const Json::Value &config) override
drogon
Drogon Test is a minimal effort test framework developed because the major C++ test frameworks doesn'...
Definition
Attribute.h:23
lib
inc
drogon
plugins
RealIpResolver.h
Generated by
1.17.0