Class PendingAuthRules
The time limits on a pending authentication: the truth table behind the authenticator's stale sweep, as pure functions of monotonic seconds.
public static class PendingAuthRules
- Inheritance
-
PendingAuthRules
- Inherited Members
Remarks
A connection's life before authentication is covered by exactly one limit at a time. From
connect until the handshake completes, the host's handshake timeout applies (the game's
BaseServerAuthenticator.authHandshakeTimeoutSeconds). The handshake completing is
what starts pending-authentication tracking, and from then on these rules apply until the
connection authenticates, is refused, or disconnects.
Authenticating is bounded by progress: overdue ProgressTtlSeconds after the last progress report, and progress stops extending it once the phase has run for AuthenticatingCapSeconds, so a stall mid-SRP is dropped within cap + TTL at most, however it is paced.
AwaitingTwoFactor is bounded by the window alone: overdue a fixed window after the prompt. Each prompt gets the full window — the first, and each re-prompt after a counted wrong code — and the per-connection attempt cap bounds how many prompts one sign-in can have, so the phase can never be extended without spending an attempt. A code arriving moves the connection back to Authenticating for its verification.
Fields
AuthenticatingCapSeconds
Seconds into one authenticating phase after which progress no longer extends it.
public const double AuthenticatingCapSeconds = 60
Field Value
DefaultTwoFactorWindowSeconds
Default seconds a player has to answer one two-factor prompt.
public const double DefaultTwoFactorWindowSeconds = 120
Field Value
Remarks
Two minutes. Answering takes unlocking a phone, opening the authenticator app, finding the account and typing six digits — commonly 15 to 40 seconds, which is exactly why the fifteen seconds the prompt used to inherit failed people. A recovery code written on paper takes longer to find. Two minutes covers both with room to spare and spans four 30-second TOTP steps, so a code that rolls over while it is being typed still leaves a fresh one to read; beyond that the slot is being held for someone who has walked away.
MaxSrpChannelCapacity
Most requests one SRP channel, verify or proof, may be configured to hold.
public const int MaxSrpChannelCapacity = 10000
Field Value
MaxTwoFactorWindowSeconds
Longest configurable two-factor window.
public const double MaxTwoFactorWindowSeconds = 600
Field Value
MinTwoFactorWindowSeconds
Shortest configurable two-factor window: one TOTP step.
public const double MinTwoFactorWindowSeconds = 30
Field Value
PendingCeilingMultiplier
How many times the pending cap the whole set, two-factor prompts included, may reach.
public const int PendingCeilingMultiplier = 10
Field Value
ProgressTtlSeconds
Seconds an authenticating connection may go without progress before it is dropped.
public const double ProgressTtlSeconds = 15
Field Value
Methods
AdmitsNewPending(int, int, int)
Whether a connection that has just completed its handshake may start authenticating.
public static bool AdmitsNewPending(int authenticating, int total, int capacity)
Parameters
authenticatingintConnections pending in Authenticating.
totalintAll pending connections, prompts included.
capacityintThe pending cap.
Returns
- bool
True when both the cap and the ceiling have room.
Remarks
The cap counts machine work only: connections authenticating, which are what fill the SRP channels the cap is sized from. A player at the two-factor prompt has already proven their password and is waiting on themselves, not on the pipeline. Counted against the cap, a launch where many players type codes filled it and turned new sign-ins into the queue while the channels sat idle.
Prompts still cost memory, so the whole set has a ceiling of PendingCeilingMultiplier times the cap — at the Login Server's default 1,000, the 10,000 the cap used to be. Reaching it needs that many correct passwords at the prompt at once, each of which leaves after one window or its attempts.
ClampSrpChannelCapacity(int)
A configured SRP channel capacity brought into [1, MaxSrpChannelCapacity], as the Login Server builds the channel.
public static int ClampSrpChannelCapacity(int capacity)
Parameters
capacityintThe configured capacity.
Returns
- int
The capacity the channel is built with.
ClampTwoFactorWindow(double)
A configured two-factor window brought into [MinTwoFactorWindowSeconds, MaxTwoFactorWindowSeconds].
public static double ClampTwoFactorWindow(double seconds)
Parameters
secondsdoubleThe configured value.
Returns
- double
The value the authenticator uses.
Remarks
There is no "off": a window shorter than a person can use is the defect this exists to fix, and an unbounded one lets an abandoned prompt hold a pending slot forever. NaN, which no comparison clamps, reads as the default.
DefaultLoginPendingCap(int, int)
The Login Server's pending-authentication cap when none is configured: as many connections as its SRP verify and proof channels hold between them — 1,000 with the default 500 + 500.
public static int DefaultLoginPendingCap(int verifyChannelCapacity, int proofChannelCapacity)
Parameters
verifyChannelCapacityintThe configured SRP verify channel capacity.
proofChannelCapacityintThe configured SRP proof channel capacity.
Returns
- int
The default cap.
Remarks
The cap is where the login queue engages, so it should sit where a queue position starts to serve a player better than being let in. A connection counted here is waiting on the client (between the handshake and its verify request, or between the verify response and its proof), on a person (the two-factor prompt), or in one of the two SRP channels — and the channels are where a storm piles up. Each drops a request it has no room for and the player is answered ServerBusy: refused, told to try again, place lost. So letting in more connections than the channels can hold together buys nothing but the chance of that refusal, while held back in the queue the same connections keep their place and are told it. Past verify + proof capacity, the queue is the better answer.
The old default of 10,000 meant the queue never engaged. Pending connections number about their arrival rate times how long they stay, and the global handshake limit (500 a second) and a residence of a second or two keep that far below 10,000; it was reachable only by a stalled pipeline, which the channels had already been answering with ServerBusy.
Derived rather than a constant, so an operator who enlarges the channels moves the queue threshold with them. A player at the two-factor prompt occupies no channel and does not count against it; prompts have their own, looser ceiling (see AdmitsNewPending(int, int, int)).
IsOverdue(PendingAuthPhase, double, double, double, double, double)
Whether a pending authentication has run out of time.
public static bool IsOverdue(PendingAuthPhase phase, double phaseStartedSeconds, double lastProgressSeconds, double nowSeconds, double progressTtlSeconds, double twoFactorWindowSeconds)
Parameters
phasePendingAuthPhaseWhat it is waiting on.
phaseStartedSecondsdoubleWhen the current phase began: the prompt, for AwaitingTwoFactor.
lastProgressSecondsdoubleThe last progress report (or the phase start).
nowSecondsdoubleThe current time.
progressTtlSecondsdoubleSee ProgressTtlSeconds.
twoFactorWindowSecondsdoubleThe two-factor window.
Returns
- bool
truewhen the connection must be dropped.
MayExtend(PendingAuthPhase, double, double, double)
Whether a progress report may extend a pending authentication.
public static bool MayExtend(PendingAuthPhase phase, double phaseStartedSeconds, double nowSeconds, double authenticatingCapSeconds)
Parameters
phasePendingAuthPhaseWhat it is waiting on.
phaseStartedSecondsdoubleWhen the current phase began.
nowSecondsdoubleThe current time.
authenticatingCapSecondsdouble
Returns
- bool
truewhen the report counts.
Remarks
Only machine work reports progress. A report that lands while the player is being prompted — a verification of an earlier code finishing late — must not pull the connection off its window.