Auto reformatted the base, ref #470
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user