Skip to content

kuxii2016/Serverpanel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverpanel.Web

A web-based game server management panel built with Blazor .NET 9. Manage game servers from your browser with real-time console, file manager, backups, and resource monitoring. Supports Minecraft, Source (Steam A2S), Infinite Rails, FiveM/RedM, Quake 3, Gamespy, and more.

Features

  • Server Management: Create, start, stop, restart, and monitor game servers
  • Console Access: Real-time console output with command input (batch-flushed to DB, max 512 chars per line)
  • File Manager: Upload, download, edit, delete, and zip files in server directories
  • Backup System: Create and restore server backups with prune options
  • Crash Detection: Automatic crash logging with exit codes and messages
  • History Recording: CPU, RAM, player counts, and network usage every 10s per server
  • System History Charts: Visual CPU/RAM/Disk graphs at /admin/system/history
  • Server Templates: Reusable server configurations for quick deployment
  • API Keys: Server-specific and global API keys with scoped permissions
  • User & Permission Management: Role-based access (Admin/User), per-server user assignments
  • Audit Log: Track all administrative actions with timestamps and user info
  • Two-Factor Auth (2FA): Required for sensitive actions
  • Query Protocol Selector: Choose the exact query protocol per server — avoids timeout chains and memory fragmentation
  • Resource Limits:
    • RAM limit per server (MB) — auto-stops server when exceeded
    • Storage auto-stop per server — stops when user's quota is reached
    • Configurable by admin in server create/settings
  • Memory Safety:
    • LOH compaction every 60s (forced, not optimized)
    • Console output read with fixed 4KB buffers (no large strings on LOH)
    • 30s query cache with failure caching
    • Process resources read via /proc/[pid]/status (Linux, VmRSS)
  • Security Features:
    • Cookie-based auth with HttpOnly, SameSite=Strict, Secure (non-dev)
    • Kestrel binds to 127.0.0.1:5000 only
    • CORS restricted to localhost:5000
    • Zip Slip protection in backup extraction
    • File endpoints require auth (admin or assigned user)
    • Setup page hides admin password after creation

Query Protocols

Each server can be configured with a specific query protocol in Settings. This prevents timeout chains and memory fragmentation when probing.

Protocol Transport Endpoint Games
Auto all tries every protocol Unknown servers
Minecraft TCP + UDP vanilla ping + GS4 query Minecraft (vanilla, Paper, Spigot, Forge)
Source (Steam A2S) UDP A2S_INFO/A2S_PLAYER CS:GO/CS2, TF2, Rust, Ark, Valheim, Palworld, 7 Days to Die, DayZ
Infinite Rails HTTP GET /status (JSON) Infinite Rails
FiveM / RedM HTTP GET /info.json (JSON) FiveM, RedM
Quake 3 UDP getstatus Quake 3 Arena, Call of Duty 1-4, Wolfenstein: ET, Jedi Academy, Urban Terror
Gamespy UDP info Battlefield 2, UT2004, Half-Life 1, Americas Army
None No network Local process status only

Tech Stack

  • Framework: .NET 9 Blazor (Interactive Server), self-contained publish
  • Database: MariaDB/MySQL via Entity Framework Core
  • Frontend: Blazor with Font Awesome icons, custom CSS
  • Charts: Chart.js for system history visualizations
  • Background Services: HistoryRecordingService (10s), SystemHistoryService (60s)

Getting Started

Prerequisites

  • .NET 9 SDK (for building) or a self-contained publish (no SDK needed at runtime)
  • MariaDB/MySQL server
  • A Java runtime (or other server executable) for game servers

Installation

  1. Build & publish:

    dotnet publish -c Release -r linux-x64 --self-contained
    
  2. Configure database connection in appsettings.json (deployed alongside the binary):

    "ConnectionStrings": {
      "DefaultConnection": "Server=localhost;Database=serverpanel;User=root;Password=yourpassword;"
    }
  3. Run the application:

    ./Serverpanel.Web
    
  4. Open http://localhost:5000/setup in your browser to create the admin account.

  5. Log in, create a server, and set the Query Protocol to match your game.

Using Server Templates

Templates allow you to pre-configure server settings for quick deployment:

  1. Navigate to Templates in the sidebar (admin)
  2. Click Create Template and fill in name, game type, start command, and start lines for Windows/Linux
  3. When creating a new server, select the template to auto-populate fields
  4. Templates can also be applied to existing servers (Settings → Template dropdown)

Resource Limits

  • RAM Limit: Set in MB per server (Create or Settings). Toggle to enable. Auto-stops the server when exceeded.
  • Storage Auto-Stop: Toggle per server. Stops the server if the user's StorageLimitBytes is reached.
  • Both options are admin-editable, visible to all.

2FA for Sensitive Actions

Two-factor authentication (TOTP) is enforced for:

  • Server deletion
  • Clear server directory
  • API key creation and deletion (server-level and global)

Memory Management

On long-running game servers with verbose output, the panel can accumulate large objects in the Large Object Heap (LOH). The panel includes:

  • Forced LOH compaction every 60s while servers are active
  • Fixed 4KB read buffer for console output (never allocates megabyte strings from binary pipe data)
  • Query caching with 30s TTL and separate failure cache (prevents repeated timeout chains)
  • Message truncation to 512 characters per console log line

If you observe high RAM usage, ensure the query protocol is set to exactly match your game (not "Auto").

Project Structure

Serverpanel.Web/
├── Components/
│   ├── Layout/          # MainLayout, sidebar, admin nav
│   └── Pages/
│       ├── Admin/       # Admin panel (users, system history, utils, settings)
│       ├── ApiKeys/     # API key management
│       ├── Auth/        # Login, setup, profile
│       ├── Servers/     # Server CRUD, detail, console, file manager
│       └── Templates/   # Server templates
├── Services/            # Business logic (A2S queries, backup, audit, auth, etc.)
├── Data/
│   ├── Models/          # Entity models (GameServer, User, ServerLog, etc.)
│   └── AppDbContext.cs  # EF Core context
├── Controllers/         # API endpoints, file download/upload
├── wwwroot/             # CSS, JS, fonts
├── Program.cs           # Startup, middleware, migration
└── appsettings.json     # Configuration

Screenshots

Dashboard Server Detail File Browser Settings