Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
DOSGuardInterface.hpp
1#pragma once
2
3#include <boost/json/object.hpp>
4
5#include <cstdint>
6#include <string>
7#include <string_view>
8namespace web::dosguard {
9
14public:
15 virtual ~BaseDOSGuard() = default;
16
20 virtual void
21 clear() noexcept = 0;
22};
23
28public:
36 [[nodiscard]] virtual bool
37 isWhiteListed(std::string_view const ip) const noexcept = 0;
38
46 [[nodiscard]] virtual bool
47 isOk(std::string const& ip) const noexcept = 0;
48
54 virtual void
55 increment(std::string const& ip) noexcept = 0;
56
62 virtual void
63 decrement(std::string const& ip) noexcept = 0;
64
77 [[maybe_unused]] virtual bool
78 add(std::string const& ip, uint32_t numObjects) noexcept = 0;
79
90 [[maybe_unused]] virtual bool
91 request(std::string const& ip, boost::json::object const& request) = 0;
92};
93
94} // namespace web::dosguard
The interface of a denial of service guard.
Definition DOSGuardInterface.hpp:13
virtual void clear() noexcept=0
Clears implementation-defined counters.
The interface of a denial of service guard.
Definition DOSGuardInterface.hpp:27
virtual bool isWhiteListed(std::string_view const ip) const noexcept=0
Check whether an ip address is in the whitelist or not.
virtual bool request(std::string const &ip, boost::json::object const &request)=0
Adds one request for the given ip address.
virtual void decrement(std::string const &ip) noexcept=0
Decrement connection count for the given ip address.
virtual void increment(std::string const &ip) noexcept=0
Increment connection count for the given ip address.
virtual bool add(std::string const &ip, uint32_t numObjects) noexcept=0
Adds numObjects of usage for the given ip address.
virtual bool isOk(std::string const &ip) const noexcept=0
Check whether an ip address is currently rate limited or not.