Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
web::dosguard::Weights Class Reference

Implementation of WeightsInterface that manages command weights for DosGuard. More...

#include <Weights.hpp>

Inheritance diagram for web::dosguard::Weights:
Collaboration diagram for web::dosguard::Weights:

Classes

struct  Entry
 Structure representing weight configuration for a command. More...
 

Public Member Functions

 Weights (size_t defaultWeight, std::unordered_map< std::string, Entry > weights)
 Construct a new Weights object.
 
size_t requestWeight (boost::json::object const &request) const override
 Get the weight assigned to a specific command.
 
- Public Member Functions inherited from web::dosguard::WeightsInterface

Static Public Member Functions

static Weights make (util::config::ClioConfigDefinition const &config)
 Create a Weights object from configuration.
 

Detailed Description

Implementation of WeightsInterface that manages command weights for DosGuard.

This class provides a mechanism to assign different weights to API commands for the purpose of DOS protection calculations. Commands can have specific weights, or fall back to a default weight.

Constructor & Destructor Documentation

◆ Weights()

web::dosguard::Weights::Weights ( size_t defaultWeight,
std::unordered_map< std::string, Entry > weights )

Construct a new Weights object.

Parameters
defaultWeightThe default weight to use when a command-specific weight is not defined
weightsMap of command names to their specific weights

Member Function Documentation

◆ make()

Weights web::dosguard::Weights::make ( util::config::ClioConfigDefinition const & config)
static

Create a Weights object from configuration.

Parameters
configThe application configuration
Returns
Weights instance initialized with values from configuration

◆ requestWeight()

size_t web::dosguard::Weights::requestWeight ( boost::json::object const & request) const
overridevirtual

Get the weight assigned to a specific command.

Parameters
requestJson request
Returns
size_t The weight value (specific weight if defined, otherwise default weight)

Implements web::dosguard::WeightsInterface.


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