LoginRateLimiter
StockSharp.Server.Core
登录尝试的速率限制器。 每个IP地址的跟踪失败, 拒绝在滑动时间窗口内超过所配置的阈值的连接 。
构造函数
LoginRateLimiter
public LoginRateLimiter(int maxAttempts, TimeSpan? window)
loginRateLimiter = LoginRateLimiter(maxAttempts, window)
初始化一个新实例。
- maxAttempts
- 允许在窗口内进行最大失败的尝试 。
- window
- 滑动时间窗口用于跟踪尝试.
属性
TrackedCount
public int TrackedCount { get; }
value = loginRateLimiter.TrackedCount
目前持有的IP跟踪器数量。 已曝光用于诊断和测试, 以验证空跟踪器被赶走且不会被累积 。
方法
IsLimited
public bool IsLimited(EndPoint remoteEndPoint)
result = loginRateLimiter.IsLimited(remoteEndPoint)
检查给定的终点是否是限速的 。
- remoteEndPoint
- 客户端点.
返回值: 如果拒绝客户端,则真实性。
RecordFailure
public void RecordFailure(EndPoint remoteEndPoint)
loginRateLimiter.RecordFailure(remoteEndPoint)
记录给定的终点的登录尝试失败 。
- remoteEndPoint
- 客户端点.
RecordSuccess
public void RecordSuccess(EndPoint remoteEndPoint)
loginRateLimiter.RecordSuccess(remoteEndPoint)
记录一个成功的登录——清除了收尾点的失败计数器.
- remoteEndPoint
- 客户端点.