Skip to main content

AuthLimits

A internal class in TavernLib, TavernLib.Backend.Auth. Reach it through att-stubs' publicized assemblies or Harmony's AccessTools.

Internal: per-address limits on the auth port and console logins. 8 failures, or 5 wrong passwords, each within 60 seconds of the last, hold an address off until 60 quiet seconds pass.

Constructors​

MemberWhat it is
AuthLimits()Created by TavernLib; mods don't make one.

Fields​

MemberWhat it is
const int FailLimit8 failures.
const int MaxOpen64 open connections in all.
const int MaxOpenPerAddress8 open connections from one address.
const int PasswordFailLimit5 wrong passwords.
9 private and internal fields
MemberWhat it is
private readonly HashSet<string> _capLoggedAddresses whose connection cap has been logged.
private readonly Dictionary<string, AuthLimits.Strikes> _failsFailure counts by address.
private readonly Dictionary<string, int> _openOpen connection count by address.
private int _openTotalOpen connections across all addresses.
private readonly Dictionary<string, AuthLimits.Strikes> _passwordFailsWrong password counts by address.
private readonly object _syncLock around the counters.
private bool _totalCapLoggedWhether the total connection cap has been logged.
private const int PruneAboveNumber of tracked addresses above which stale entries are dropped.
private static readonly TimeSpan WindowThe 60 second window failures are counted in.

Methods​

MemberWhat it is
void Close(string address)Records that one of the address's connections closed.
void Fail(string address)Counts a failure against the address, logging when it reaches the limit.
bool HeldOff(string address)True while the address has 8 recent failures.
void PasswordFail(string address)Counts a wrong password, which is also a failure.
bool PasswordHeldOff(string address)True while the address has 5 recent wrong passwords.
bool TryOpen(string address)Takes a connection slot for the address. False when it or the server is at its cap.
2 private and internal methods
MemberWhat it is
private int Add(Dictionary<string, AuthLimits.Strikes> strikes, string address)Adds a strike for an address, pruning stale entries first, and returns the new count.
private int Count(Dictionary<string, AuthLimits.Strikes> strikes, string address)Returns an address's recent strike count, or 0 if its last strike is outside the window.

Used in​

Members of other types that take, return or hold a AuthLimits: