Giter VIP home page Giter VIP logo

rcon's Introduction

rcon

Go Report Card

A RCON client for executing commands on a remote RCON server.

This Go-based RCON client allows Minecraft server administrators to send commands to their server over a remote RCON connection. With this client, you can easily send commands and view output on the console without having to log in directly to the 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 with them.

To use the client, you will need to have access to the server's RCON password and IP address/hostname. Once connected, you can send commands through the client's terminal interface and receive output on the console like you would with the standard Minecraft server console.

Installation

Prebuild

Download the latest build for your platform from the latest release

Build

You can also build your own executable. This requires:

git
go v1.18 or higher
make

Run these commands to build the executable:

git clone https://github.com/Sch8ill/rcon
make -C rcon
mv rcon/build/rcon-cli rcon-cli
rm -rf rcon

Usage

CLI

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 version

Example commands

Move into the directory of the executable and open up a terminal.

Open up an interactive RCON terminal:

./rcon-cli -a <the-servers-address> -p <the-servers-password>

Run a single command on the server:

./rcon-cli -a <the-servers-address> -p <the-servers-password> -c <the-command-that-shall-be-executed>

Take a look at the other command flags for more features.

Environment Variables

Instead of specifying command line options each time, you can also use environment variables to set the default values. Environment variables are automatically checked and used if available. Environment variables take precedence over the default values.

Available environment variables:

DEFAULT_RCON_ADDRESS: Address of the server you want to connect to. DEFAULT_RCON_PASSWORD: Password of the RCON server you want to connect to. DEFAULT_RCON_TIMEOUT: Default timeout for the connection to the server. Example:

export DEFAULT_RCON_ADDRESS="my-server:25575"
export DEFAULT_RCON_PASSWORD="my-password"
export DEFAULT_RCON_TIMEOUT="10s"

Libary usage

Install the module using:

go get github.com/sch8ill/rcon

Import 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("some-command")
if err != nil {
  panic(err)
}

fmt.Println(output)

rcon's People

Contributors

sch8ill avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.