Auto reformatted the base, ref #470

This commit is contained in:
emeric
2024-05-24 23:31:52 +02:00
parent 83b868673c
commit 39941d90a3
460 changed files with 8583 additions and 8514 deletions
+23 -23
View File
@@ -24,34 +24,34 @@
#include <Wt/WDateTime.h>
#include "core/NetAddress.hpp"
#include "core/Exception.hpp"
#include "core/NetAddress.hpp"
namespace lms::auth
{
class LoginThrottler
{
public:
LoginThrottler(std::size_t maxEntries) : _maxEntries {maxEntries} {}
class LoginThrottler
{
public:
LoginThrottler(std::size_t maxEntries)
: _maxEntries{ maxEntries } {}
// user must lock these calls to avoid races
bool isClientThrottled(const boost::asio::ip::address& address) const;
void onBadClientAttempt(const boost::asio::ip::address& address);
void onGoodClientAttempt(const boost::asio::ip::address& address);
// user must lock these calls to avoid races
bool isClientThrottled(const boost::asio::ip::address& address) const;
void onBadClientAttempt(const boost::asio::ip::address& address);
void onGoodClientAttempt(const boost::asio::ip::address& address);
private:
void removeOutdatedEntries();
private:
void removeOutdatedEntries();
const std::size_t _maxEntries;
static constexpr std::size_t _maxBadConsecutiveAttemptCount {5};
static constexpr std::chrono::seconds _throttlingDuration {3};
struct AttemptInfo
{
Wt::WDateTime nextAttempt;
std::size_t badConsecutiveAttemptCount{};
};
std::unordered_map<boost::asio::ip::address, AttemptInfo> _attemptsInfo;
};
} // Auth
const std::size_t _maxEntries;
static constexpr std::size_t _maxBadConsecutiveAttemptCount{ 5 };
static constexpr std::chrono::seconds _throttlingDuration{ 3 };
struct AttemptInfo
{
Wt::WDateTime nextAttempt;
std::size_t badConsecutiveAttemptCount{};
};
std::unordered_map<boost::asio::ip::address, AttemptInfo> _attemptsInfo;
};
} // namespace lms::auth