Source-checkedLibraries & compatibility

rcon

by AviiNL · for Valheim

Add RCON communication protocol to BepInEx compatible games

4.9KDownloads
3 yr agoLast updated
BepInExLoaders
ThunderstoreSource

About rcon

From Thunderstore

Add RCON communication protocol to BepInEx compatible games

RCON

This is an RCON library for BepInEx compatible games that do not ship with a native RCON implementation, like Valheim.

Usage

Add rcon.dll to your BepInEx/plugins folder. Run the server at least once to generate the required config files.

Configuration

The configuration file will be generated as BepInEx/config/nl.avii.plugins.rcon.cfg

Open this file with your favorite editor and change enabled to true. Change the port number to something close to the game port, for Valheim I've used GamePort+2, and at least on Nitrado game servers, I am able to connect to it. (not sure about other providers)

> NOTE: If you host your own dedicated server, make sure to port forward the selected port if you wish to connect to it remotely.

The password field is self-explanatory.

After changing the values, restart the server.

Commands

This library does not ship with commands but is intended to be used as a dependency for other plugins.

Add a reference to rcon.dll to your own project

Adding a command

There are 2 ways to register commands from your own plugins.

Inline command example

[BepInPlugin("com.bepinex.plugins.example", "Example", "1.0")]
[BepInDependency("nl.avii.plugins.rcon", BepInDependency.DependencyFlags.HardDependency)]
[BepInProcess("valheim_server.exe")]
public class Plugin : BaseUnityPlugin
{
    rcon.rcon RCON;
 
    void OnEnable()
    {
        RCON = GetComponent<rcon.rcon>();
        if (RCON == null)
        {
            Logger.LogError("rcon plugin not loaded");
            return;
        }
 
        RCON.RegisterCommand(this, "test", (args) =>
        {
            Logger.LogInfo("Command 'test' execution");
 
            return "string to return to rcon client";
        });
    }
 
    void OnDisable()
    {
        if (RCON == null)
        {
            Logger.LogError("rcon plugin not loaded");
            return;
        }
 
        RCON.UnRegisterCommand(this, "test");
    }
}

Or using a separate class handler, register the command in OnEnable() of your plugin:

RCON.RegisterCommand<TestCommand>(this, "test");

And Unregister in OnDisable()

RCON.UnRegisterCommand(this, "test");

Add create a TestCommand.cs class

using rcon;
class TestCommand : AbstractCommand
{
    public override string onCommand(string[] args)
    {
        // This will be executed on `test`
        // There is a protected property called "Plugin"
        // which holds a reference to your plugin class
        return "string to return to rcon client";
    }
}

Unknown Command Handler

If an issued command can not be found, the library fires an the rcon.OnUnknownCommand event.

This is an example to forward unknown commands to a connected client based on their steamid

void OnEnable()
{
    ...
    
    RCON.OnUnknownCommand += RCON_OnUnknownCommand;
}

private string RCON_OnUnknownCommand(string command, string[] args)
{
    var arguments = args.ToList();
    string steamid = arguments.First();
    if (steamid == null)
    {
        return "Unknown command";
    }
 
    List<ZNetPeer> peers = (List<ZNetPeer>)AccessTools.Field(typeof(ZNet), "m_peers").GetValue(ZNet.instance);
    var peer = peers.Where(x => ((ZSteamSocket)x.m_socket).GetPeerID().ToString().Trim().ToLower() == steamid.Trim().ToLower()).FirstOrDefault();
    if (peer == null)
        return $"Player with steamid {steamid} not connected";
 
    arguments.RemoveAt(0);
 
    ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "ExamplePlugin", command, arguments);
 
    return $"Command {command} forwarded to {peer.m_uid}";
}

Highlights

From source data

Loaders

Runs on BepInEx.

Footprint

Rated a light load on a server.

Dependencies

Needs 1 other project installed alongside it.

rcon on Nxeon

From our catalogue
One-click install
Supported on Nxeon Valheim servers, for BepInEx servers. We download it from Thunderstore, place it, and restart the server.
Server side
Required on the server
Server type needed
BepInEx
Server load
light
Smallest plan we suggest
Valheim — 4 GB (4 GB RAM). This follows our own load rating above, not a benchmark.
Latest build
1.0.5, released 2024-03-24

Game versions by loader

LoaderGame versionsNewest
BepInEx

From 4 recorded builds of rcon.

Recent builds

BuildReleasedGame versionsLoaders
1.0.52024-03-24n/aBepInEx
1.0.42024-03-24n/aBepInEx
0.0.22023-02-04n/aBepInEx
0.0.12021-03-27n/aBepInEx

Dependencies

Declared by the newest build that lists any. Required ones are installed with it on one-click installs.

Run rcon on a Valheim server

Pick a server or deploy a new one above; it is installed in one click.

What kind of mod it is

From the catalog
Listed on Thunderstore as “Core”

Libraries & compatibility

Foundations and fixes other mods build on. Usually installed because something else needs it.

Runs on your server

From source side support

Thunderstore lists rcon as required on the server. Check its Thunderstore page to see whether players need it too.

Compatibility

Game
Valheim
Loaders
BepInEx
Runs on
Serverrequired on the server
Requires
One-click install needs a BepInEx server. 1 other project installed alongside it.

Verified at the source

  • ✓ThunderstoreOfficial listing, checked 2026-10-02Open ↗
  • ✓AuthorAviiNL, as published on Thunderstore
  • ✓LicenseNot published by the sourceFree

rcon, answered

Generated from the mod’s own source data.

Do my players need to install rcon?

Thunderstore lists rcon as required on the server. Check its Thunderstore page to see whether players need it too.

Which loaders does it support?

BepInEx.

Is it free?

Yes. rcon is free to download from Thunderstore.

How do I add it to my Nxeon server?

Use “Add to a server” on this page, or open NxLabs from your dashboard. We install it, restart your server and switch it on.

NxLabs

Run rcon on a Valheim server.

Deploy in about a minute from $9.99 a month, then add rcon in one click.