STTNet 0.7.0
载入中...
搜索中...
未找到
stt::security::RateState结构体 参考

单一限流器的运行状态(可复用于多种限流策略)。 更多...

#include <sttnet.h>

Public 属性

int counter = 0
 
int violations = 0
 
std::chrono::steady_clock::time_point lastTime {}
 
std::deque< std::chrono::steady_clock::time_point > history
 
double tokens = 0.0
 
std::chrono::steady_clock::time_point lastRefill {}
 

详细描述

单一限流器的运行状态(可复用于多种限流策略)。

该结构用于记录某个限流维度(IP / fd / path 等)的实时状态, 会被不同限流算法复用:

  • Cooldown / FixedWindow:
    • 使用 counter + lastTime
  • SlidingWindow:
    • 使用 history(时间戳队列)
  • TokenBucket:
    • 使用 tokens + lastRefill
注解
  • violations 用于记录“被拒绝”的次数,是防御升级(DROP / CLOSE / 封禁)的依据
  • RateState 本身不做任何决策,只负责记录状态

类成员变量说明

◆ counter

int stt::security::RateState::counter = 0

◆ history

std::deque<std::chrono::steady_clock::time_point> stt::security::RateState::history

◆ lastRefill

std::chrono::steady_clock::time_point stt::security::RateState::lastRefill {}

◆ lastTime

std::chrono::steady_clock::time_point stt::security::RateState::lastTime {}

◆ tokens

double stt::security::RateState::tokens = 0.0

◆ violations

int stt::security::RateState::violations = 0

该结构体的文档由以下文件生成: