Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

TNL::ClientPuzzleManager Class Reference

The ClientPuzzleManager class issues, solves and validates client puzzles for connection authentication. More...

#include <tnlClientPuzzle.h>

List of all members.

Public Types

enum  ErrorCode
 Error codes that can be returned by checkSolution.

enum  {
  PuzzleRefreshTime = 30000, InitialPuzzleDifficulty = 17, MaxPuzzleDifficulty = 26, MaxSolutionComputeFragment = 30,
  SolutionFragmentIterations = 50000
}
 Difficulty levels of puzzles. More...


Public Methods

void tick (U32 currentTime)
 Checks to see if a new nonce needs to be created, and if so generates one and tosses out the current list of accepted nonces.

ErrorCode checkSolution (U32 solution, Nonce &clientNonce, Nonce &serverNonce, U32 puzzleDifficulty, U32 clientIdentity)
 Checks a puzzle solution submitted by a client to see if it is a valid solution for the current or previous puzzle nonces.

Nonce getCurrentNonce ()
 Returns the current server nonce.

U32 getCurrentDifficulty ()
 Returns the current client puzzle difficulty.


Static Public Methods

bool solvePuzzle (U32 *solution, Nonce &clientNonce, Nonce &serverNonce, U32 puzzleDifficulty, U32 clientIdentity)
 Computes a puzzle solution value for the given puzzle difficulty and server nonce.


Detailed Description

The ClientPuzzleManager class issues, solves and validates client puzzles for connection authentication.

Definition at line 42 of file tnlClientPuzzle.h.


Member Enumeration Documentation

anonymous enum
 

Difficulty levels of puzzles.

Enumeration values:
PuzzleRefreshTime  Refresh the server puzzle every 30 seconds.
InitialPuzzleDifficulty  Initial puzzle difficulty is set so clients do approx 2-3x the shared secret generation of the server.
MaxPuzzleDifficulty  Maximum puzzle difficulty is approx 1 minute to solve on ~2004 hardware.
MaxSolutionComputeFragment  Number of milliseconds spent computing solution per call to solvePuzzle.
SolutionFragmentIterations  Number of attempts to spend on the client puzzle per call to solvePuzzle.

Definition at line 108 of file tnlClientPuzzle.h.


Member Function Documentation

bool TNL::ClientPuzzleManager::solvePuzzle U32   solution,
Nonce &    clientNonce,
Nonce &    serverNonce,
U32    puzzleDifficulty,
U32    clientIdentity
[static]
 

Computes a puzzle solution value for the given puzzle difficulty and server nonce.

If the execution time of this function exceeds MaxSolutionComputeFragment milliseconds, it will return the current trail solution in the solution variable and a return value of false.

Note:
Although the behavior of this function can be tweaked using MaxSolutionComputeFragment and SolutionFragmentIterations, it's important to bias these settings in favor of rapid puzzle completion. A client puzzle is only valid for two times PuzzleRefreshTime, so for about a minute, maximum. Most of the time the puzzle can be solved in only a few hundred milliseconds. It's better to solve the puzzle fast than to let it drag out, (ie, it's better to let your application hitch for a moment whilst calculating than to make the user endure many seconds of lag) so reducing the timeout or iterations should be done only if you know what you're doing.

Definition at line 152 of file clientPuzzle.cpp.

References MaxSolutionComputeFragment, SolutionFragmentIterations, and TNL::U32.


The documentation for this class was generated from the following files:
Generated on Thu Aug 18 16:03:37 2005 for Robin Hood: Thieves & Knights by doxygen1.2.18