Giter VIP home page Giter VIP logo

minecraftrcon's Introduction

Rcon

Circle CI

This is a Spigot plugin for Minecraft servers that allows console commands to be received over HTTP.

This is an alternative to Minecraft's native rcon functionality, which has unresolved issues such as the following:

This plugin does not do any authentication by default. This plugin is intended to listen on localhost or another restricted address for use by scripts running on the same server. By default, the plugin listens to port 25576 on localhost. (This is configurable in the plugin's config.yml.)

This plugin does not implement the native rcon protocol. It expects a client to make a POST request to the path "/command", and to include a POST body parameter named "command" containing the Minecraft console command to run. When the Rcon plugin receives a POST request, the special header "X-Anti-CSRF: 1" must be included. (This is a protection against CSRF attacks: if you run this plugin on your computer set to only listen localhost, and you browse the internet on your computer, then a website you visit can tell your browser to make a POST request to any address including to the Rcon plugin, but the website can't tell your browser to include arbitrary headers, so the website won't be able to trigger Rcon commands.)

After the command is executed, all of the server's logs for a game tick are mirrored to the response so that the client gets the output from the command. Other output from the logs may be captured in this too.

Commands can be sent by using curl in a terminal like this:

$ curl http://localhost:25576/command -H 'X-Anti-CSRF: 1' --data-urlencode 'command=list'
There are 1/20 players online:
DaringMacil

Tip: You should add the --fail flag to make curl exit with a nonzero exit code on unsuccessful server responses if you're using curl from a script.

The Rcon plugin also responds to GET requests to the following paths:

  • /info: This returns a JSON object containing information about the server.
{
  "name": "Unknown Server",
  "version": "git-Spigot-642f6d2-fbe3046 (MC: 1.12.2)",
  "motd": "A Minecraft Server",
  "currentPlayerCount": 1,
  "maxPlayerCount": 20,
  "players": [
    {
      "name": "DaringMacil"
    }
  ]
}
  • /healthcheck: This endpoint responds with a 200 status if the Rcon plugin is working.

Installing

Download the latest Rcon jar file from the project's Releases page. Place the jar file in the plugins/ directory. After the first run, the file plugins/Rcon/config.yml file will be generated with default values.

Configuration

In the plugins/Rcon directory, the config.yml file can be customized to set the port and address that Rcon listens on. The default "localhost" address means that Rcon will only be accessible from the computer running the Rcon plugin. If the address value is set to "all", then it's important to configure Rcon to require authorization or to configure the system's firewall to restrict access to the port.

You can set Rcon to require a user name and password over HTTP Basic authentication by creating a file "htpasswd" in the plugins/Rcon directory. The file must be a text file that on each line contains a username, a colon, and a bcrypt hash. This file may be generated by the htpasswd utility (included in apache2-utils) as follows:

$ htpasswd -Bc htpasswd myusername
New password: 
Re-type new password: 
Adding password for user myusername

When the htpasswd file is present, Rcon will block any requests that are not authenticated as a user in the file. When using curl, you can supply the username and password by using the --user flag.

This plugin records some usage metrics to https://bstats.org/plugin/bukkit/Rcon. You can opt out of this by placing enabled: false in plugins/bStats/config.yml.

Sponge Alternative

This plugin is only for Spigot. I don't plan on porting it to Sponge because Web-API exists for Sponge and accomplishes what this plugin does and much more.

minecraftrcon's People

Contributors

macil 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.