private string ApplicationRefusal(string username, string ip) | Returns why a whitelist application is refused, or null if it can be filed. |
private object CheckIfPermitted(UserConfig config, ServerSettings settings, string joinerIp, AuthPayloads.AuthenticateRequest payload) | Checks blacklist, password and whitelist in that order; returns the refusal to send, or null if the player may join. |
private async Task InterpretTcpStream(TcpClient client) | Handles one connection: applies limits, reads the request and routes it by its keys (ping, whitelist application, mods list, set_mods, join). |
private async Task ManageAuthRequest(Stream stream, JObject payload, string address) | Handles a join request: checks the fields are present, then replies with the result of ResolveJoin. |
private async Task ManageSetModsRequest(Stream stream, JObject payload, string ip) | Stores the mod list a player's game will load on their account, after checking their token. |
private async Task ManageWhitelistApplicationRequest(Stream stream, JObject payload, string joinerIp) | Handles a whitelist application and files it in the requests file unless it is refused. |
private static ulong NextUserId(UserConfig config) | Returns one more than the highest user id in the file, and never below FirstUserId. |
private async Task<string> ReadFullPayload(Stream stream, CancellationToken token) | Reads from the stream until it holds a complete JSON object, or throws if it never does. |
private static Dictionary<string, string> ReadModList(JToken token) | Parses a set_mods object into a dictionary, or returns null if any entry is too long or not a string. |
private ServerSettings ReadSettings() | Reads server_settings.json afresh; returns null if it can't be read. |
private bool Register(UserConfig config, ServerSettings settings, AuthPayloads.AuthenticateRequest payload, string ip, out object response) | Creates or checks the player's account and returns whether users.json changed; the response is the join result. |
private object ResolveJoin(AuthPayloads.AuthenticateRequest payload, string ip) | Checks permission and registers the player under the user file's lock; returns the response to send. |
private async Task StartAuthCycle() | Starts the TCP listener and accepts connections until the game quits. |
private void StopListening() | Stops the listener; runs when the game quits. |
private async Task WriteModsListResponse(Stream stream) | Sends the enabled server mods and untracked mods, prefixed with a 4 byte big-endian length. |
private async Task WritePongResponse(Stream stream) | Answers a ping with the server name, ports, password and whitelist flags, and the mod hash and count. |
private async Task WriteResponse(Stream stream, object response) | Serializes a response object to JSON and writes it to the stream. |