JSON backing store, I/O fixes, Networking Security
Introduced Newtonsoft.Json-backed persistence. Improved backing-store reliability and serialization across the caching stack. Improved networking security posture. Key changes: - Add new GameCult.Caching.NewtonsoftJson project with SingleFile/MultiFile backing stores and polymorphic known-type envelopes. - Add MessagePack helper serialization (DatabaseEntrySerialization) and update MessagePack backing stores to use the shared options/resolver; add DatabaseLink formatter and generator/analyzer docs. - Update CultLib.sln to include the new projects and new caching tests project. - Improve CultCache persistence behavior: track pending store operations, wait for operations on PullAll, and centralize async push handling with error logging. - Harden file I/O in multi-file/single-file stores: atomic temp-file writes, safe Replace/Move semantics, rename-safe deletes, and improved file-watcher subscription and debounce disposal. - Add README files and documentation for several subprojects and packaging projects. These changes add JSON persistence support, improve serialization consistency, and make on-disk operations more robust and observable.
This commit is contained in:
parent
d88eecb4ba
commit
0bfc85a4f2
50 changed files with 3957 additions and 325 deletions
51
src/GameCult.Networking/ClientSecurityOptions.cs
Normal file
51
src/GameCult.Networking/ClientSecurityOptions.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace GameCult.Networking
|
||||
{
|
||||
/// <summary>
|
||||
/// Carries the client-side networking configuration required to talk to a server.
|
||||
/// </summary>
|
||||
public sealed class ClientSecurityOptions
|
||||
{
|
||||
private readonly byte[] _encryptionKey;
|
||||
|
||||
/// <summary>
|
||||
/// Shared LiteNetLib connection key and encryption seed.
|
||||
/// </summary>
|
||||
public string ConnectionKey { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new client security configuration.
|
||||
/// </summary>
|
||||
/// <param name="connectionKey">The shared connection key used by both client and server.</param>
|
||||
public ClientSecurityOptions(string connectionKey)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(connectionKey))
|
||||
throw new ArgumentException("Connection key must be provided.", nameof(connectionKey));
|
||||
|
||||
ConnectionKey = connectionKey;
|
||||
_encryptionKey = ComputeSha256(Encoding.UTF8.GetBytes(connectionKey));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a deterministic development-only configuration.
|
||||
/// </summary>
|
||||
public static ClientSecurityOptions Development()
|
||||
{
|
||||
return new ClientSecurityOptions("gamecult-dev-connection-key");
|
||||
}
|
||||
|
||||
internal byte[] GetEncryptionKey()
|
||||
{
|
||||
return _encryptionKey;
|
||||
}
|
||||
|
||||
private static byte[] ComputeSha256(byte[] data)
|
||||
{
|
||||
using var sha256 = SHA256.Create();
|
||||
return sha256.ComputeHash(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue