feat: add E2EE DMs, group chats, local serversettings.json, and security/perf fixes
This commit is contained in:
parent
b60b5a0774
commit
3b52de20d1
33 changed files with 5107 additions and 366 deletions
51
README.md
51
README.md
|
|
@ -10,10 +10,18 @@ GsDChat provides a single-server architecture with SQLite persistence, dynamic D
|
|||
|
||||
- **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.
|
||||
- **Direct Messaging (DMs) with Configurable E2EE**:
|
||||
- Private 1-on-1 direct messages between users.
|
||||
- Controlled by the `AllowDmE2ee` setting in `serversettings.json`:
|
||||
- When `AllowDmE2ee: true` (default), DMs use full **End-to-End Encryption** (NIST P-256 ECDH key agreement + SHA-256 + AES-256-GCM authenticated encryption). Private keys are wrapped client-side with the user's password via PBKDF2-SHA256 + AES-256-GCM, and the server only stores/relays opaque ciphertext (`E2EE:v1:...`).
|
||||
- When `AllowDmE2ee: false`, the server rejects E2EE DM payloads and DMs are transmitted in standard plaintext visible to the server.
|
||||
- **User-Created Group Chats**:
|
||||
- Any authenticated user can create private multi-user Group Chats (separate from public channels), invite users, and leave groups.
|
||||
- Maximum member count per group chat is governed by `MaxGroupChatUsers` in `serversettings.json`.
|
||||
- **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).
|
||||
- **F1**: Active Conversation Chat (supports Public Channels, Group Chats, and E2EE/Plaintext DMs with lock badges, scrollable history, timestamps, role badges, file card indicators, bottom input box).
|
||||
- **F2**: Channel, Group Chat & DM Browser (browse and switch between channels, group chats, and DMs; create/invite/leave groups; start DMs).
|
||||
- **F3**: User Directory (member list, role tags, real-time online `●` / offline `○` presence, E2EE `[KEY]` indicator, and quick `[D] Direct Message`).
|
||||
- **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 `.dll` files in `./mods/` to dynamically extend the server using `AssemblyLoadContext`:
|
||||
|
|
@ -36,8 +44,9 @@ GsDChat provides a single-server architecture with SQLite persistence, dynamic D
|
|||
```
|
||||
GsDChat/
|
||||
├── GsDChat.slnx
|
||||
├── serversettings.json # Local persisted server configuration file
|
||||
├── src/
|
||||
│ ├── GsDChat.Core/ # Shared models, crypto, and network/UI protocols
|
||||
│ ├── GsDChat.Core/ # Shared models, E2EE & auth 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
|
||||
|
|
@ -72,7 +81,7 @@ By default, the server runs on `http://0.0.0.0:5000` with SQLite database in `./
|
|||
|
||||
#### Server Configuration (`serversettings.json` / CLI flags)
|
||||
|
||||
You can edit `src/GsDChat.Server/serversettings.json` or pass command-line arguments:
|
||||
Server settings are managed via a local, human-readable `serversettings.json` file (automatically created and formatted if missing). You can edit `./serversettings.json` directly or pass command-line arguments:
|
||||
|
||||
```json
|
||||
{
|
||||
|
|
@ -84,15 +93,18 @@ You can edit `src/GsDChat.Server/serversettings.json` or pass command-line argum
|
|||
"ServerWidePassword": "",
|
||||
"RegistrationMode": "Open",
|
||||
"DataDirectory": "data",
|
||||
"ModsDirectory": "mods",
|
||||
"MaxFileSizeMb": 50,
|
||||
"ServerName": "GsDChat Community Server",
|
||||
"Motd": "Welcome to GsDChat! Enjoy private and modular messaging."
|
||||
"Motd": "Welcome to GsDChat! Enjoy private and modular messaging.",
|
||||
"AllowDmE2ee": true,
|
||||
"MaxGroupChatUsers": 10
|
||||
}
|
||||
```
|
||||
|
||||
CLI Overrides:
|
||||
CLI Overrides (persisted back to `serversettings.json`):
|
||||
```bash
|
||||
dotnet run --project src/GsDChat.Server -- --port 8080 --server-password "MySecretCommunityPassword"
|
||||
dotnet run --project src/GsDChat.Server -- --port 8080 --allow-dm-e2ee true --max-group-users 15
|
||||
```
|
||||
|
||||
---
|
||||
|
|
@ -101,15 +113,12 @@ dotnet run --project src/GsDChat.Server -- --port 8080 --server-password "MySecr
|
|||
|
||||
### Option A: Standard Docker Compose
|
||||
|
||||
1. Copy `.env.example` to `.env` (already done by default) and customize variables:
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
1. Edit `serversettings.json` in the project root to configure your server name, MOTD, `AllowDmE2ee`, `MaxGroupChatUsers`, etc.
|
||||
2. Start the container:
|
||||
```bash
|
||||
docker compose up -d --build
|
||||
```
|
||||
Data (database + files) is persisted in `./data/` and mods in `./mods/`.
|
||||
`./serversettings.json` is mounted directly into the container (`/app/serversettings.json`) so all configuration changes persist cleanly across restarts alongside `./data/` and `./mods/`.
|
||||
|
||||
### Option B: Built-in Cloudflare Tunnel (`cloudflared`)
|
||||
|
||||
|
|
@ -155,7 +164,7 @@ GsDChat includes a responsive, zero-install WebClient built with pure HTML5, CSS
|
|||
- **Access**: Open `http://<server-ip>:5000/` or your Cloudflare Tunnel URL in any browser.
|
||||
- **Mobile Optimized**: Designed specifically for phones and touchscreens with responsive navigation tabs, bottom chat bar, and native file pickers.
|
||||
- **Offline / Private LAN Ready**: 100% self-contained with zero external CDN dependencies.
|
||||
- **Features**: Real-time WebSocket messaging, channel switching, online user presence, authenticated file uploads, and downloads. Session tokens are remembered in browser storage.
|
||||
- **Features**: Real-time WebSocket messaging, Public Channels, Group Chats (create, invite, leave), Direct Messages with Web Crypto API (`crypto.subtle`) P-256 ECDH + AES-256-GCM E2EE (interoperable with the C# TUI client), online user presence, authenticated file uploads, and downloads.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -164,8 +173,8 @@ GsDChat includes a responsive, zero-install WebClient built with pure HTML5, CSS
|
|||
| Key | Action |
|
||||
|---|---|
|
||||
| **F1** | Switch to **Chat** view |
|
||||
| **F2** | Switch to **Channels** view |
|
||||
| **F3** | Switch to **Users** directory view |
|
||||
| **F2** | Switch to **Channels / Groups / DMs** view |
|
||||
| **F3** | Switch to **Users** directory view (`D` to start DM) |
|
||||
| **F4** | Switch to **Files** transfer view |
|
||||
| **F5** | Switch to **Server Status** (SampleBot mod view) |
|
||||
| **Enter** (on F1) | Send message or run slash command |
|
||||
|
|
@ -176,9 +185,13 @@ GsDChat includes a responsive, zero-install WebClient built with pure HTML5, CSS
|
|||
|
||||
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.
|
||||
- `/join <name>` — Switch to a channel, group chat, or DM.
|
||||
- `/create <name> [topic]` — Create a new public channel (Admin/Owner).
|
||||
- `/dm <username>` — Start or open a Direct Message with a user.
|
||||
- `/group <name> [user1,user2,...]` — Create a new private Group Chat.
|
||||
- `/invite <username>` — Invite a user to the active Group Chat.
|
||||
- `/leave` — Leave the active Group Chat.
|
||||
- `/upload <local_path>` — Upload a file to the active conversation.
|
||||
- `/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).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue