source-rcon-server 1.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package source-rcon-server --version 1.3.0
NuGet\Install-Package source-rcon-server -Version 1.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="source-rcon-server" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add source-rcon-server --version 1.3.0
#r "nuget: source-rcon-server, 1.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install source-rcon-server as a Cake Addin
#addin nuget:?package=source-rcon-server&version=1.3.0

// Install source-rcon-server as a Cake Tool
#tool nuget:?package=source-rcon-server&version=1.3.0

Source RCON Library is an easy to use, single-class solution to create a Valve source RCON server which supports authentication, IP Whitelisting, a command manager and much more!

Build and Tests Status

AppVeyor AppVeyor tests

Coverage

Codecov

NuGet

Install-Package source-rcon-server

Examples

Hosted Examples

Server

2018-01-28_12-49-23

https://github.com/Subtixx/source-rcon-library/tree/master/Examples/ServerExample

Client

2018-01-28_12-52-10-e

https://github.com/Subtixx/source-rcon-library/tree/master/Examples/ClientExample

Setup

Minimum setup server

var server = new RemoteConServer(IPAddress.Any, 27015);
server.StartListening();

Configuration

This library allows you to configure certain things, here I'll explain what you can configure and how it affects the server.

EmptyPayloadKick

When the client is authenticated (already entered his password), the server checks the payload (or body as it's called on the wiki) before processing the packet. If the payload is empty and EmptyPayloadKick is true, the client gets disconnected from the RCON server.

EnableIpWhitelist / IpWhitelist

Sometimes it's necessary to protect the RCON server from intruders. This setting will allow you to specify a wildcard based IP Whitelist to check against when a new client connects.

InvalidPacketKick

The server will ensure that the client will only sent packets (after authentication) that are of type ExecCommand. If this is not the case, and the setting is true, the client will be disconnected if he sents a packet with a different type.

MaxPasswordTries

To protect the server against brute force attacks it checks if the client has exceeded the maximum allowed of tries specified by this setting. If he has he will be disconnected immediately

Password

This is the password that has to be entered before any commands can be executed

SendAuthImmediately

Sometimes client libraries don't match the specification, this was the case when testing the library. If you've trouble using a specific client, and haven't tried setting this to true this might help. (If not please open an issue!)

UseCustomCommandHandler / OnCommandReceived

Sometimes you just want to do it yourself. Setting UseCustomCommandHandler to true and adding an eventhandler to OnCommandReceived will ignore the built-in CommandManager and sent all commands to the eventhandler instead

Debug

This will sent debug messages to System.Diagnostics.Debug.WriteLine and Console.WriteLine

MaxConnectionsPerIp

To disallow spamming the server with connections you can limit how many clients can connect from a single IP

MaxConnections

With this setting you can limit how many total connections the server accepts at once

IpBanList

Temporary list of IPs which are banned. You have to handle saving and loading yourself. Additionally this allows you to make a command (For example called rcon-ban to ban specific clients from the RCON connections). The value (since it's a dictionary) specifies the unix timestamp (Use DateTimeExtensions to get that value) when the ban is lifted. To ban someone forever you can use int.MaxValue

BanMinutes

This specifies how long a client will be banned when he fails to authenticate MaxPasswordTries.

Adding Commands

There are two main ways to create commands, either as LAMBDA expression or as Class Method. You can optionally specify a usage and description to in a custom help command (Example is in RCONServerLibExample), if you don't specify it it'll be empty by default.

public void Add(string name, CommandHandler handler)
public void Add(string name, string description, CommandHandler handler)
public void Add(string name, string usage, string description, CommandHandler handler)

LAMBDA expression

public static class Program
{
    public static int Main(string[] args)
    {
        var server = new RemoteConServer(IPAddress.Any, 27015);
        server.CommandManager.Add("hello", "Echos back world", (command, arguments) => {
            return "world";
        });
    }
}

Class Method

public static class Program
{
    public static int Main(string[] args)
    {
        var server = new RemoteConServer(IPAddress.Any, 27015);
        server.CommandManager.Add("hello", "", Hello_Command);
        
        server.StartListening();
        while (true)
        {
        }
    }
    
    public string Hello_Command(string command, IList<string> args)
    {
        return "world";
    }
}

Contributing

Not much here yet. Feel free to fork and sent pull-requests.

ToDo List

  • Split packets at 4096 bytes

References

Product Compatible and additional computed target framework versions.
.NET Framework net35 is compatible.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.1 941 8/24/2019
1.3.0 1,105 1/29/2018
1.2.0 1,082 1/26/2018
1.0.8-release 1,003 1/24/2018
1.0.0 1,263 1/23/2018