7.5 KiB
GsDChat
A lightweight, secure, and private community chat platform built in pure C# (.NET 10) without external non-.NET libraries.
GsDChat provides a single-server architecture with SQLite persistence, dynamic DLL modding via AssemblyLoadContext, HTTPS/WSS and tunnel-ready HTTP/WS support, authenticated file transfers, and a server-driven screen-swapping Terminal User Interface (TUI).
Key Features
- Pure .NET Architecture: Strict adherence to the standard .NET runtime and first-party
Microsoft.Data.Sqlite. Zero native/unmanaged C/C++ third-party dependencies. - Flexible Network & Tunnel Support: Configurable direct HTTPS/WSS (with custom PFX/PEM certificates or self-signed certs) or plain HTTP/WS for running inside Docker containers behind Cloudflare Tunnels (
cloudflared), Tailscale, or reverse proxies. - Screen-Swapping TUI Client: Built with ANSI escape codes and
System.Console(zero third-party UI dependencies). Fast screen-swapping using function keys:- F1: Active Channel Chat (scrollable history, timestamps, role badges, file card indicators, bottom input box).
- F2: Channel Browser (channel list, topics, active indicator, join and create channels).
- F3: User Directory (member list, role tags, real-time online
●/ offline○presence). - F4: Shared Files Browser (table of uploaded files, download to
./downloads/, upload from local path). - F5+: Mod-defined custom screens rendered dynamically from server layout schemas.
- Dynamic Modding System: Place mod
.dllfiles in./mods/to dynamically extend the server usingAssemblyLoadContext:- Intercept and transform chat messages (e.g. shorthand emoji formatting
:shrug:, word filters). - Register custom slash commands (e.g.
/roll 2d6,/announce). - Subscribe to server lifecycle and entity events (
UserConnected,ChannelCreated,FileUploaded). - Inject custom TUI screens or customize server MOTD.
- Intercept and transform chat messages (e.g. shorthand emoji formatting
- Security & Authentication:
- PBKDF2 with SHA-512 (100,000 iterations) and 256-bit cryptographically secure salt.
- Constant-time verification preventing timing attacks.
- 256-bit secure session tokens.
- Optional server-wide password gate.
- Role-based permissions (
Owner,Admin,Member). First registered user automatically becomes the Server Owner.
- Direct File Transfers: Authenticated multipart HTTPS uploads (
POST /api/files/upload) and streaming downloads (GET /api/files/{id}) with SHA-256 integrity verification.
Project Structure
GsDChat/
├── GsDChat.slnx
├── src/
│ ├── GsDChat.Core/ # Shared models, crypto, and network/UI protocols
│ ├── GsDChat.Modding/ # Mod SDK: IMod, pipelines, command registry, event bus
│ ├── GsDChat.Server/ # ASP.NET Core Kestrel, SQLite DB, WebSockets, File REST
│ ├── GsDChat.Client/ # Pure C# screen-swapping TUI client
│ └── GsDChat.Mods.SampleBot/ # Reference mod: /roll, /announce, emoji transformer, F5 screen
└── tests/
└── GsDChat.Tests/ # Comprehensive xUnit test suite (Unit, Integration, E2E)
Quick Start
1. Build Solution
dotnet build GsDChat.slnx
2. Run All Tests
dotnet test GsDChat.slnx
3. Run the Server
dotnet run --project src/GsDChat.Server
By default, the server runs on http://0.0.0.0:5000 with SQLite database in ./data/chat.db and loads any mod DLLs in ./mods/.
Server Configuration (serversettings.json / CLI flags)
You can edit src/GsDChat.Server/serversettings.json or pass command-line arguments:
{
"Host": "0.0.0.0",
"Port": 5000,
"UseTls": false,
"CertificatePath": "",
"CertificatePassword": "",
"ServerWidePassword": "",
"RegistrationMode": "Open",
"DataDirectory": "data",
"MaxFileSizeMb": 50,
"ServerName": "GsDChat Community Server",
"Motd": "Welcome to GsDChat! Enjoy private and modular messaging."
}
CLI Overrides:
dotnet run --project src/GsDChat.Server -- --port 8080 --server-password "MySecretCommunityPassword"
Docker & Cloudflare Tunnel Deployment
Option A: Standard Docker Compose
- Copy
.env.exampleto.env(already done by default) and customize variables:cp .env.example .env - Start the container:
Data (database + files) is persisted indocker compose up -d --build./data/and mods in./mods/.
Option B: Built-in Cloudflare Tunnel (cloudflared)
This deploys GsDChat in an isolated container with zero open host ports, securely accessible globally via Cloudflare Tunnel.
- Create a tunnel in Cloudflare Zero Trust (
Networks -> Tunnels -> Add a Tunnel). - Copy the tunnel token into
.env:CLOUDFLARE_TUNNEL_TOKEN=eyJh... - In Cloudflare Zero Trust, configure the Public Hostname:
- Service:
HTTP - URL:
gsdchat:5000
- Service:
- Start both GsDChat and the cloudflared tunnel:
docker compose -f docker-compose.tunnel.yml up -d --build
4. Run the Client TUI
dotnet run --project src/GsDChat.Client
Or connect directly with credentials:
dotnet run --project src/GsDChat.Client -- --server http://localhost:5000 --username Alice --password MyPassword123!
Client TUI Navigation
| Key | Action |
|---|---|
| F1 | Switch to Chat view |
| F2 | Switch to Channels view |
| F3 | Switch to Users directory view |
| F4 | Switch to Files transfer view |
| F5 | Switch to Server Status (SampleBot mod view) |
| Enter (on F1) | Send message or run slash command |
| PageUp / PageDown | Scroll message viewport up and down |
| Ctrl + C | Exit client |
Built-in & Mod Slash Commands
Type these directly in the chat input on F1:
/help— List available commands./join <channel>— Switch to a channel (e.g./join general)./create <name> [topic]— Create a new channel (Admin/Owner)./upload <local_path>— Upload a file to the active channel./download <file_id>— Download a shared file to./downloads/./roll [NdM](SampleBot) — Roll dice (e.g./roll 2d6,/roll 1d20)./announce <text>(SampleBot) — Post an official broadcast announcement (Admin/Owner).- Text emoji shortcuts:
:shrug:converts to¯\_(ツ)_/¯,:tableflip:converts to(╯°□°)╯︵ ┻━┻,:heart:to❤️.
Modding Guide
To create a custom mod:
- Create a class library targeting
net10.0. - Reference
GsDChat.Modding.csproj. - Implement
IMod:
using GsDChat.Modding;
public class MyCustomMod : IMod
{
public string Id => "com.example.mycustommod";
public string Name => "My Custom Mod";
public string Version => "1.0.0";
public string Description => "Example custom mod for GsDChat";
public Task InitializeAsync(IModContext context)
{
// Register a custom slash command
context.Commands.RegisterCommand("ping", "Responds with pong", async cmdCtx =>
{
return CommandResult.Ok("🏓 Pong from custom mod!");
});
// Intercept messages
context.Pipeline.Use(async (msgCtx, next) =>
{
// Inspect or modify msgCtx.Message.Content
await next();
});
return Task.CompletedTask;
}
public Task ShutdownAsync() => Task.CompletedTask;
}
- Drop the built
.dllinto the server's./mods/directory and restart the server.
License
MIT License.