Storage

Key-value data kept on the server between restarts, and player accounts with salted, slow password hashes.

Data kept on the server between restarts. Since v0.2 everything lives in one SQLite database, data/godfather/godfather.db, using the SQLite that's built into Windows 10 and later (nothing extra to install). Values are cached in memory and written every few seconds and on shutdown, in one transaction. A v0.1 server's JSON bucket files are imported the first time; the files stay as a backup.

Buckets#

static Bucket For(Player player) · static Bucket Server · static Bucket Named(string name)#

Data for one player (keyed by their current name), for the whole server, or a bucket of your own (e.g. Bucket.Named("ngrp/accounts/" + account) for data that belongs to an account rather than a name).

T Get<T>(string key, T fallback = default) · void Set<T>(string key, T value)#

Values are stored as JSON, so numbers, strings, arrays and plain classes work.

bool Remove(string key)#

Deletes a key; returns false if it was not there.

C#
1var bucket = Bucket.For(player);2var visits = bucket.Get("visits", 0) + 1;3bucket.Set("visits", visits);

Accounts#

For gamemodes with sign-in such as NG-RP.

AccountResult Accounts.Create(string name, string password)#

Creates an account. Names have 3 to 20 letters, digits or _ and are unique regardless of capitalisation; passwords need 8 to 128 characters.

AccountResult Accounts.Verify(string name, string password)#

Checks a name and password. A wrong name and a wrong password get the same message, so names can't be probed. After 5 wrong passwords the account is locked for 5 minutes.

bool Accounts.Exists(string name) · string Accounts.CheckName(string name)#

Whether an account exists, and why a name breaks the rules (null if it's fine).

AccountResult#

Ok, Error (NameInvalid, NameTaken, PasswordInvalid, WrongNameOrPassword, Locked), Message (safe to show the player, e.g. "That name and password don't match. 4 tries left."), Name (the stored capitalisation), AttemptsLeft, LockedSeconds.

C#
1var result = Accounts.Verify(name.Value, password.Value);2if (!result.Ok) { panel.Error(result.Message); return; }3player.SetName(result.Name);

How passwords are kept#

  • Hashed with PBKDF2-HMAC-SHA256, 100,000 iterations and a random 16-byte salt per account; compared in constant time.
  • Never stored, logged or sent back to a player's screen in plain text (password fields on panels are never echoed).
  • Lock counters are kept in memory, so a server restart clears them.