Skip to content

code-lime/Rcon.AspNetCore.Server

Repository files navigation

Rcon.AspNetCore.Server

Rcon.AspNetCore.Server is a library for building RCON (Remote Console) servers on ASP.NET Core, featuring authentication, command processing, and efficient buffer serialization.

Features

  • Asynchronous RCON connection handling based on ConnectionHandler
  • Client authentication and command execution via a user-provided handler
  • Full support for the standard Source RCON protocol
  • Flexible packet serialization/deserialization (Little Endian, UTF-8)
  • Efficient buffer operations via Span/Memory and IBufferWriter<T>
  • Easy integration with ASP.NET Core logging

Getting Started

Example: Handling an RCON Connection

using Microsoft.AspNetCore.Connections;
using Microsoft.Extensions.Logging;
using Rcon.AspNetCore.Server;

// Implement your custom RCON server logic
public class MyRconServer : IRconServer
{
    public string Password => "my_secret_password";

    public Task<string> ExecuteAsync(string command, CancellationToken cancellationToken)
    {
        // Your command processing logic (e.g. game server management)
        return Task.FromResult($"Executed: {command}");
    }
}

// Register the handler and configure Kestrel in your Startup/Program.cs
builder.Services
    .AddSingleton<IRconServer, MyRconServer>();
builder.WebHost
    .ConfigureKestrel(options => options
        .ListenAnyIP(1234, v => v.UseConnectionHandler<RconConnectionHandler>()));

Main Types

RconConnectionHandler

Handles connections according to the RCON protocol:

  • Reads and parses packets
  • Authenticates clients
  • Invokes commands via IRconServer
  • Builds and sends responses

PacketType

Enum representing RCON packet types:

  • AuthRequest — Authentication request
  • AuthResponse — Authentication response
  • CommandRequest — Command execution request
  • CommandResponse — Command response

IRconServer

Interface for user-provided authentication and command handling:

public interface IRconServer
{
    string Password { get; }
    Task<string> ExecuteAsync(string command, CancellationToken cancellationToken);
}

BinaryPrimitivesExtensions, StringExtensions

Utilities for efficient serialization/deserialization of primitives and strings into buffers, optimized for network protocol handling.

Protocol Workflow

  1. Client connects to the server via TCP/QUIC (e.g., through Kestrel)
  2. Sends an authentication packet (AuthRequest)
  3. Upon successful authentication, client can send commands (CommandRequest)
  4. Server responds with results (CommandResponse)
  5. All packets use Little Endian byte order and UTF-8 for strings

Client Example

You can use ARRCON or other Source RCON-compatible tools for testing.

Dependencies

For integration testing, the project uses the external RCON client ARRCON, licensed under GNU GPLv3.
It is not included with the library and is used only as a separate CLI tool during test execution.

Requirements

  • .NET 8.0 or later
  • ASP.NET Core (Kestrel)

License

MIT


Rcon.AspNetCore.Server is a lightweight foundation for integrating RCON into your .NET servers and game projects.

About

Library for building RCON (Remote Console) servers on ASP.NET Core.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages