A RCON client for executing commands on a remote RCON server.
This client implements the RCON protocol used by Minecraft servers and has the potential to work with other game servers as well, though it hasn't been extensively tested.
Open up a RCON session:
./rcon-cli -a <address> -p <password>Run a single command on the server:
./rcon-cli -a <address> -p <password> -c <command>Download the latest build for your platform from the latest release
You can also build your own executable. This requires:
git
go v1.26 or higher
makeRun these commands to build the executable:
git clone https://github.com/sch8ill/rcon
cd rcon
makeInstall the module using:
go get github.com/sch8ill/rconImport it:
import "github.com/sch8ill/rcon"Create a new RCON client:
client, err := rcon.Dial("localhost", "password", 5) // address, password, timeout
if err != nil {
panic(err)
}Execute a command over RCON:
output, err := client.ExecuteCmd("stop")
if err != nil {
panic(err)
}
fmt.Println(output)USAGE:
rcon [global options] command [command options] [arguments...]
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--address value, -a value address of the server you want to connect to (localhost:25575 for example) (default: "localhost")
--password value, -p value password of the RCON server you want to connect to (default: "minecraft")
--command value, -c value a single command to be executed
--timeout value, -t value timeout for the connection to the server (default: 7s)
--no-colors, --no-colours if the cli should not output colors (default: false)
--help, -h show help
--version, -v print the versionAvailable environment variables:
export DEFAULT_RCON_ADDRESS="localhost:25575"
export DEFAULT_RCON_PASSWORD="password"
export DEFAULT_RCON_TIMEOUT="10s"