RESTinio

ip_blocker.hpp
Go to the documentation of this file.
1/*
2 * RESTinio
3 */
4
12#pragma once
13
14#include <restinio/common_types.hpp>
15
16 namespace restinio
17{
18
19 namespace ip_blocker
20{
21
22//
23// inspection_result_t
24//
30 enum class inspection_result_t
31{
33 deny,
35 allow
36};
37
43 inline constexpr inspection_result_t
44 deny() noexcept { return inspection_result_t::deny; }
45
51 inline constexpr inspection_result_t
52 allow() noexcept { return inspection_result_t::allow; }
53
54//
55// incoming_info_t
56//
63 class incoming_info_t
64{
65 endpoint_t m_remote_endpoint;
66
67public :
69 incoming_info_t(
70 endpoint_t remote_endpoint )
71 : m_remote_endpoint{ remote_endpoint }
72 {}
73
75 endpoint_t
76 remote_endpoint() const noexcept { return m_remote_endpoint; }
77};
78
79//
80// noop_ip_blocker_t
81//
93 struct noop_ip_blocker_t
94{
95 // empty type by design.
96};
97
98} /* namespace ip_blocker */
99
100} /* namespace restinio */
101
restinio::ip_blocker::incoming_info_t
An information about new incoming connection to be passed to IP-blocker object.
Definition: ip_blocker.hpp:64
restinio::ip_blocker::incoming_info_t::remote_endpoint
endpoint_t remote_endpoint() const noexcept
Remote endpoint of the new connection.
Definition: ip_blocker.hpp:76
restinio::ip_blocker::incoming_info_t::incoming_info_t
incoming_info_t(endpoint_t remote_endpoint)
Initializing constructor.
Definition: ip_blocker.hpp:69
restinio::ip_blocker::incoming_info_t::m_remote_endpoint
endpoint_t m_remote_endpoint
Definition: ip_blocker.hpp:65
common_types.hpp
restinio::ip_blocker::deny
constexpr inspection_result_t deny() noexcept
Shorthand for inspection_result_t::deny.
Definition: ip_blocker.hpp:44
restinio::ip_blocker::inspection_result_t
inspection_result_t
Enumeration of result of inspecting new incoming connection.
Definition: ip_blocker.hpp:31
restinio::ip_blocker::inspection_result_t::deny
@ deny
New connection is disabled and should be closed.
restinio::ip_blocker::inspection_result_t::allow
@ allow
New connection is allowed to be processed further.
restinio::ip_blocker::allow
constexpr inspection_result_t allow() noexcept
Shorthand for inspection_result_t::allow.
Definition: ip_blocker.hpp:52
restinio
Definition: asio_include.hpp:21
restinio::endpoint_t
asio_ns::ip::tcp::endpoint endpoint_t
An alias for endpoint type from Asio.
Definition: common_types.hpp:177
restinio::ip_blocker::noop_ip_blocker_t
The default no-op IP-blocker.
Definition: ip_blocker.hpp:94
const
#define const
Definition: zconf.h:230