vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::NetJoinCookie Class Reference

The token a server gives an address that asks to join, and takes back as proof that the address hears what is sent to it. More...

#include <join_cookie.h>

Public Member Functions

void rekey ()
 Draw a new key from the operating system. Every token given before is void.
uint64_t issue (const NetAddress &to, double now) const
 The token for to, as of now.
bool accepts (const NetAddress &from, uint64_t token, double now) const
 Whether token is one issue() gave from, this window or the last.

Static Public Attributes

static constexpr double WINDOW_SECONDS = 10.0
 How long one window lasts, in seconds; a token is good for one to two of them.

Detailed Description

The token a server gives an address that asks to join, and takes back as proof that the address hears what is sent to it.

Stateless - a keyed hash of the address and the time window - so a forged Hello costs a hash and a reply no larger, and crowds out no real join. Accepted for its window and the next. The key comes from the operating system, so tokens cannot be predicted and a restart voids them.

Member Function Documentation

◆ issue()

uint64_t Vkm::Engine::NetJoinCookie::issue ( const NetAddress & to,
double now ) const

The token for to, as of now.

Parameters
toThe address that asked.
nowSeconds on a clock that only moves forward.
Returns
The token.

◆ accepts()

bool Vkm::Engine::NetJoinCookie::accepts ( const NetAddress & from,
uint64_t token,
double now ) const

Whether token is one issue() gave from, this window or the last.

Parameters
fromThe address the token came back from.
tokenWhat it carried.
nowSeconds, on the clock issue() was given.
Returns
True when the token proves the address heard the Challenge.

The documentation for this class was generated from the following file: