LoginRateLimiter
StockSharp.Server.Core
Rate limiter for login attempts. Tracks failed attempts per IP address and rejects connections that exceed the configured threshold within a sliding time window.
Constructors
LoginRateLimiter
public LoginRateLimiter(int maxAttempts, TimeSpan? window)
loginRateLimiter = LoginRateLimiter(maxAttempts, window)
Initializes a new instance.
- maxAttempts
- Maximum failed attempts allowed within the window.
- window
- Sliding time window for tracking attempts.
Properties
TrackedCount
public int TrackedCount { get; }
value = loginRateLimiter.TrackedCount
Number of IP trackers currently held. Exposed for diagnostics and tests to verify that empty trackers are evicted and do not accumulate.
Methods
IsLimited
public bool IsLimited(EndPoint remoteEndPoint)
result = loginRateLimiter.IsLimited(remoteEndPoint)
Check if the given endpoint is rate-limited.
- remoteEndPoint
- Client endpoint.
Returns: true if the client should be rejected.
RecordFailure
public void RecordFailure(EndPoint remoteEndPoint)
loginRateLimiter.RecordFailure(remoteEndPoint)
Record a failed login attempt for the given endpoint.
- remoteEndPoint
- Client endpoint.
RecordSuccess
public void RecordSuccess(EndPoint remoteEndPoint)
loginRateLimiter.RecordSuccess(remoteEndPoint)
Record a successful login — clears the failure counter for the endpoint.
- remoteEndPoint
- Client endpoint.