Coder Social home page Coder Social logo

tiiffi / mcrcon Goto Github PK

View Code? Open in Web Editor NEW
782.0 24.0 111.0 146 KB

Rcon client for Minecraft

Home Page: https://github.com/Tiiffi/mcrcon/

License: zlib License

C 85.86% Makefile 6.16% Roff 7.97%
rcon mcrcon minecraft remote-control remote-access remote-admin-tool game-server mojang administration remote-administration-tool

mcrcon's Introduction

mcrcon

mcrcon is console based Minecraft rcon client for remote administration and server maintenance scripts.


Installing:

via packet manager:

See https://pkgs.org/download/mcrcon for available packages in various Linux distros (note that available packages might be outdated).

building from sources:
git clone https://github.com/Tiiffi/mcrcon.git
cd mcrcon
make
sudo make install

Check INSTALL.md for more details.

Precompiled binaries (if provided)*: https://github.com/Tiiffi/mcrcon/releases/latest

*At the moment binaries are provided for Linux and Windows.


Usage:

mcrcon [OPTIONS] [COMMANDS]

Sends rcon commands to Minecraft server.

Option:
  -H            Server address (default: localhost)
  -P            Port (default: 25575)
  -p            Rcon password
  -t            Terminal mode
  -s            Silent mode
  -c            Disable colors
  -r            Output raw packets
  -w            Wait for specified duration (seconds) between each command (1 - 600s)
  -h            Print usage
  -v            Version information

Server address, port and password can be set using following environment variables:

MCRCON_HOST
MCRCON_PORT
MCRCON_PASS
Notes:
  • mcrcon will start in terminal mode if no commands are given
  • Command-line options will override environment variables
  • Rcon commands with spaces must be enclosed in quotes

Example:

Send three commands ("say", "save-all", "stop") and wait five seconds between the commands.

mcrcon -H my.minecraft.server -p password -w 5 "say Server is restarting!" save-all stop


Enable rcon on server

Remember to enable rcon by adding following lines to server.properties file.

enable-rcon=true
rcon.port=25575
rcon.password=your_rcon_pasword

Contact:

License

This project is licensed under the zlib License - see the LICENSE file for details.


Master: Master build Develop: Develop build

mcrcon's People

Contributors

addisong avatar hagb avatar jbaldus avatar kabiroberai avatar meatballhat avatar northkill avatar srakitnican avatar taingra avatar terokorp avatar tiiffi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mcrcon's Issues

Solution: Error 111 - Connection Refused

I had been having this recurring issue where mcrcon inexplicably breaks. Looking online, it appears that others have had this issue and (like me) failed to find a solution. I suspect that this fork/project is just out of date and abandoned.

For those of you using something like this guide to set up your server infrastructure, this mcrcon issue breaks a lot of stuff. The solution is to use the screen tool to run the server instead:

screen java -Xmx1024M -Xms512M -jar server.jar nogui

You should update any systemd processes accordingly. You can find information on screen here. The server instance thus runs in the background, and you can access the console at any point with screen -r.

Does not match expected packet size

Sometimes when I type the help command( ./mcrcon -p "password" -H IP -P Port "help"), it returns "Warning: recv() return value (1408) does not match expected packet size (3133)."

Can't use mcrcon with minecraft server by using docker

Hi Tiiffi

I want to ask you a question regarding my minecraft server by using docker

I have packaged two MC server (MC 1.16.5 and MC forge 1.12 )image by using docker
I already set up the rcon command in server.properties of two server.

one set up as :
rcon.port=25575
rcon.password=XXXXXX
enable-rcon=true

the other set up as:
rcon.port=25574
rcon.password=XXXXXX
enable-rcon=true

Then , I use mcrcon , but the program always show "Connection fail ".

I am not sure where the question is.

Sincerely,
Charlie

Error 111

I have followed an installation via the linuxize dot com website.

At the stage of connection to the console everything was working fine. I then rebooted my VM and now I get the message

Connection Failed
Error 111: Connection refused

Any ideas?

Error Number 0

Hello, I have a issue on my CLI. I have changed rcon=true rcon.port=25566 rcon.password=testing
This is on localhost so I dont care for my credentials. When I run mcrcon --password testing -t 0.0.0.0 -p 25566 I get OSError: [WinError 10049] The requested address is not valid in its context then I try again by doing
mcrcon -t localhost -p 25565
Password: testing
...
OSError: [Errno 0] Error

Any help is appreciated.

How do I run mcrcon from cron inside a python script?

So my script is working fine, I'm using python to use mcrcon, this works perfectly fine until I tell this script to run from Cron, where it just does not work.

output = subprocess.getoutput(['mcrcon -P 25333 -p TOPSERET spigot:tps'])

How do I fix this? Do I have to add mcrcon to crons path? but its inside python which makes it even more confusing.

Error

mcrcon.c: In function ‘get_line’:
mcrcon.c:708:10: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
fgets(buffer, bsize, stdin);
^

incorrect location provided in INSTALL.md

hi it seems that on Centos 7 make install installs binaries here:
/usr/local/bin/mcrcon
instead of
/usr/share/bin/mcrcon

and same for MAN page which is installed here:
/usr/local/share/man/man1/mcrcon.1

Instead of :
/usr/share/man/man1/mcrcon.1

I think the INSTALL.md should be updated with this information

Reloading ResourceManager

I have gotten everything until I run the command: tail -f /opt/minecraft/server/logs/latest.log It then gets stuck on Reloading ResourceManager: Default I reset my pi 3 times and tried each time and nothing has worked. If anyone needs anything extra to help please let me know! Thanks!

Cant use in Bash/Python

I have a perfect running command, but every time I try and run an mcrcon command in either bash or python, it dousnt accept any of the parameters and just says:
mcrcon: error: argument -p/--port: invalid int value: 'password'
This is what its running:
mcrcon -P 23943 -p paassword spigot:tps

some commands output empty lines

so i was playing around with the demo and for some reason, when i try certain commands like

f f

it just outputs an empty line, at first i thought it had something to do with factions not being supported for whatever reason but if i do

f help

it works fine
also, the f f command outputs on the server, but not in the demo script

Can't get mcrcon to work on Mac OSX 11.1

I am playing around with making a MC server work inside of docker. I am following this tutorial: https://www.youtube.com/watch?v=TxjvC6GRjkU&t=924s.

Everything worked fine but i can't get mcrcon to work on my Mac. I tried to use the steps that are in the description but when I do sudo make install I get an error saying:
ginstall -vD mcrcon /usr/local/bin/mcrcon make: ginstall: No such file or directory make: *** [install] Error 1.

Am I doing something wrong or is this a known issue?

Automatic Filling

is it possible to edit .bat or .exe so when i run lauch.bat it will autofill credentials?

How do you use mcrcon?

Below is the file from which I extracted mcrcon.
mcrcon-master.zip
I can't figure out how to use mcrcon. I ran makefile and it gave me this:
Last login: Mon Sep 21 17:10:45 on ttys001
arthurmeadenew@Arthur-Meade ~ % /Users/arthurmeadenew/Desktop/mcrcon-master/Makefile ; exit;
/Users/arthurmeadenew/Desktop/mcrcon-master/Makefile: line 9: EXENAME: command not found
/Users/arthurmeadenew/Desktop/mcrcon-master/Makefile: line 10: PREFIX: command not found
INSTALL: =: No such file or directory
/Users/arthurmeadenew/Desktop/mcrcon-master/Makefile: line 13: LINKER: command not found
RM: =: No such file or directory
RM: rm: No such file or directory
RM: -v: No such file or directory
RM: -f: No such file or directory
clang: error: no such file or directory: '='
clang: error: no such file or directory: 'gcc'
clang: error: no input files
/Users/arthurmeadenew/Desktop/mcrcon-master/Makefile: line 17: CFLAGS: command not found
/Users/arthurmeadenew/Desktop/mcrcon-master/Makefile: line 18: EXTRAFLAGS: command not found
/Users/arthurmeadenew/Desktop/mcrcon-master/Makefile: line 20: syntax error near unexpected token $(OS),' /Users/arthurmeadenew/Desktop/mcrcon-master/Makefile: line 20: ifeq ($(OS), Windows_NT)'

[Process completed]

Is there supposed to be those errors? And when I go into terminal and type in mcrcon it says,
zsh: command not found: mcrcon
What do I do? I don't really know hardly anything about coding. I am trying to run this on macOS Catalina 10.15.5 and the latest update on the changelog.md file and the top update is 0.7.1, so I assume I am running that. Thanks for the help!!

How to install mcrcon on windows

I don't have a lot of experience in all of this and I have a few questions.
Do I run the installation in the command line?
I cloned the reposetory, did cd mcrcon but when I try to run make it prompts an error message along the lines of "unkown command" (I don't know the exact translation because my cmd is not in english). The install.md says something about C Library and POSIX getopt support dependencys but I have no clue how I would install these if it was the problem.
Can someone help me how to install mcrcon properly?

Filesystem Hierachy Standard

Makefile install location does not adhere to Filesystem Hierachy Standard

/usr/share and /usr/local/share is meant for architecture independent data files.

The mcrcon binary, is clearly architecture dependent. The correct path should be /usr/local.

See this document for more info http://www.pathname.com/fhs/pub/fhs-2.3.pdf

I will create a pull request...

where can i find the dependencies..

sorry for such a stupid question, but i'm really not sure where to find "C Library" and "POSIX getopt support",

pc is Windows 10, if that helps? not sure.. i've tried googling but i didnt find anything :( sorry

Possible race-condition, decode_packet hangs, 100% CPU usage, very frequently

When attempting to execute command /save-off my script freezes with 100% CPU usage very frequently. When I abort the script with the good old interrupt signal it reveals this:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/mcrcon-0.0.0-py3.6.egg/mcrcon.py", line 52, in receive_packet
  File "/usr/local/lib/python3.6/site-packages/mcrcon-0.0.0-py3.6.egg/mcrcon.py", line 23, in decode_packet
mcrcon.IncompletePacket: 14

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./backup.py", line 17, in <module>
    rcon.backup(backup_output)
  File "/usr/local/games/minecraft/mmm.py", line 54, in backup
    mcrcon.command(self.sock, '/save-off')
  File "/usr/local/lib/python3.6/site-packages/mcrcon-0.0.0-py3.6.egg/mcrcon.py", line 86, in command
  File "/usr/local/lib/python3.6/site-packages/mcrcon-0.0.0-py3.6.egg/mcrcon.py", line 55, in receive_packet
KeyboardInterrupt

mmm.py is a utility module I wrote that depends on mcrcon. This is part of a script I configured, backup.py, to run nightly backups via cron (i.e. /save-off, do the backup using rsync, /save-on).

The script eventually runs through to completion but only after abort and reattempt several times making it unusable as a cron job. I would presume the response from the RCon server when calling /save-off is non-deterministic and causing decode_packet to choke.

Upon examining the source code in Minecraft, it appears prone to race condition:

        RConConsoleSource.instance.resetLog();
        this.commandManager.executeCommand(RConConsoleSource.instance, commandString);
        return RConConsoleSource.instance.getLogContents();

It executes the command and then hopes that the command will fill the log with some output (what if some other command does that?). This code is very bad so I wouldn't be surprised if a reliable resolution isn't possible.

aarch64 builds

Useful for those using Raspberry Pis.
While it is easy to compile through gcc, it wouldn't hurt to provide binaries.

Invalid Packet size (-551878174)

I'm getting an error when trying gto connect mcrcron in Windows 7 to Linux MC. Latest version.

Warning: invalid packet size (-551878174). Must over 10 and less than 4096.
Authentication failed!

Command line is:
@mcrcon.exe -t -H redacted.com -P 12345 -p redactedpassword

Name: mcrcon (minecraft rcon)
Version: 0.7.1
Date: 02.01.2020

What I Have To Run?

There Is No exe or msi And All The Stuff Is Out Of Mind What I Have To Runnnnnnnn?

Bug with command send

I tried the example on GitHub and using the "create_shortcut.bat" file, but it only signs me automaticly in and the commands were not send :?
I am using Win10.

Used Script:

@mcrcon.exe -t -H xxx.xxx.xxx.x -P 25575 -p xxxx -w 5 "say Server is restarting!" save-all stop

Result
pic

Please use release feature

As I am packaging this sources, I have no way to reference a release other then using git snapshots. Please consider using GitHub's release feature, so that code can be referenced by release to a specific point in time.

mcron c-tcl

Hi there, just wondering if you could make a tcl version of this great tool to be used with eggdrop bots to control Minecraft servers via IRC?

Always returns exit code 1

Every command executed results in mcrcon returning exit code 1 instead of 0 independent whether the command succeeded or not.

I've tested it with the following servers:

  • Spigot with Minecraft 1.12.2
  • Spigot with Minecraft 1.14.4
  • Forge with Minecraft 1.12.2
  • Forge with Minecraft 1.14.4

new lines

The output does not know how to handle 'new line' characters. It displays all output on a single line.
Same on windows and linux.
I don't know C that well, but I think line 713 might be the problem.

GitHub and Sourceforge sources differ

As found here: https://bugzilla.redhat.com/show_bug.cgi?id=1392599 there seems to be some difference between two sources.


--- /tmp/github-mcrcon.c	2016-11-12 10:04:36.309383200 +0100
+++ /tmp/sourceforge-mcrcon.c	2012-08-31 00:07:06.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, Tiiffi <tiiffi -> gmail_dot_com>
+ * Copyright (c) 2012, Tiiffi <tiiffi_at_gmail_dot_com>
  *
  * This software is provided 'as-is', without any express or implied
  * warranty. In no event will the authors be held liable for any damages
@@ -62,7 +62,7 @@
  *  - Program makes use of C99 feature (variable-length arrays) so "-std=gnu99" flag on
  *    GCC-compiler must be used to avoid unecessary warnings.
  *
- *  - Rcon receive buffer is now bigger (2024 bytes -> 10240 bytes).
+ *  - Rcon receive buffer is now bigger (2048 bytes -> 10240 bytes).
  *     * Thanks to 'gman_ftw' @ Bukkit forums.
  *
  *  - Fixed invalid error message when receiving empty rcon packet (10 bytes).

-w is it actually seconds?

Seems like it is not accurate for time? Doing more testing.

mcrcon.exe -s -H 127.0.0.1 -P 1111 -w 5 "say shutdown in 5 mins"
mcrcon.exe -s -H 127.0.0.1 -P 1111 -w 240 "say shutdown in 1 min" -w 60 stop

[03May2021 03:06:49.219] [RCON Listener #1/INFO] [net.minecraft.network.rcon.RConThread/]: Thread RCON Client /127.0.0.1 started
[03May2021 03:06:49.224] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer/]: [Rcon] shutdown in 5 mins
[03May2021 03:06:59.229] [RCON Client /127.0.0.1 #4/INFO] [net.minecraft.network.rcon.ClientThread/]: Thread RCON Client /127.0.0.1 shutting down
[03May2021 03:06:59.237] [RCON Listener #1/INFO] [net.minecraft.network.rcon.RConThread/]: Thread RCON Client /127.0.0.1 started
[03May2021 03:06:59.237] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer/]: [Rcon] shutdown in 1 min
[03May2021 03:07:14.240] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer/]: [Rcon: Stopping the server]
[03May2021 03:07:14.241] [RCON Client /127.0.0.1 #5/INFO] [net.minecraft.network.rcon.ClientThread/]: Thread RCON Client /127.0.0.1 shutting down
[03May2021 03:07:14.270] [Server thread/INFO] [ipsis.woot.setup.ModSetup/]: onServerStop
[03May2021 03:07:14.276] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Stopping server
[03May2021 03:07:14.277] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Saving players

Connection Failed

I set up rcon on my server and it seems to be working on the server. Trying to connect to the server results to an error "Connection Failed" with no further info. The server is PaperMC 1.16.5. I tried using the launch.bat and the cmd. Both didn't work. Using mcrcon 7.1

Strange caracters in the terminal

Hello,

When I launch mcron in a linux terminal, the arrows to move inside the line are not recognised :

brownie@localhost:/tmp/mcrcon$ ./mcrcon -t
Logged in. Type 'quit' or 'exit' to quit.
>help
--------- Help: Index (1/11) --------------------
Use /help [n] to get page n of help.
Aliases: Lists command aliases
Bukkit: All commands for Bukkit
dynmap: All commands for dynmap
Minecraft: All commands for Minecraft
WorldBorder: All commands for WorldBorder
/advancement: A Mojang provided command.
/ban: A Mojang provided command.
/ban-ip: A Mojang provided command.
>ban @test^[[D^[[D

The @test^[[D^[[D are arrows keystrokes to the left, after writing test

I don't know if the issue is related to the terminal or the software.

Regards,

Brownie

How to use it?

I am a Chinese student, rented a server, can you tell me how to use RCON?
I don't often in making online, you can contact my email.
My email is “[email protected]” (qq is China's communication software)
Sorry, my English is not very good, so I use translation software to communicate, may not be accurate.

Cannot connect on my VPS

I tried using mcrcon for an ARK: Survival Evolved server. It works perfectly fine in my windows subsystem for linux, but when I try to run it on my vps it does not give me any response whatsoever and eventually times out (see screenshots)
Both run a newly compiled version 0.7.1

WSL:
WindowsSubsystemForLinux

VPS:
VPS

Flaky responses to commands issued when using MCRCON console

The responses to commands issued on the MCRCON console are missing, incomplete or inconsistent (read very frustrating).

I'm running a Minecraft-Spigot server using Docker-Compose with luckperms and essentialsX. This is all running on my Asustor NAS I'm using the latest Windows version of MCRCON to connect to the Minecraft server and using it, I can issue game commands that have the desired effect. However MCRON does not bring the responses back properly. Typing '?' gives the help screen but typing '? luckperms' gives just a basic 2 line response except once in a while I will get a list of lp commands. If I repeat the exact command, I will get a difference more basic response. If I type in a full 'lp' command, for instance
lp user <username> permission set luckperms.* true
it will work but I will get no response in MCRCON. If I type lp editor, I get nothing.

I am new to this so if there is something basic I'm missing please let me know. I can send my yml file if you think it will help.

Executing in Different Worlds?

I am trying to execute a series of commands in "The End", and I can run them from the command line in the game, but not from within MCRCON. Any thoughts? (a "worldswitch" command? something like that?). Much appreciated! Love the tool. Works great on my server. Thanks!

Environment variables don't work

Both in systemd and via bash script I can't get mcrcon to recognize my environment variables unless I export them, which systemd doesn't do. This is non-standard behavior for reading environment variables, which means they can't be used with systemd.

root@minecraft:~# MCRCON_PORT=25575
root@minecraft:~# MCRCON_PASS=password
root@minecraft:~# echo $MCRCON_PORT $MCRCON_PASS
25575 password
root@minecraft:~# mcrcon
You must give password (-p password).
Try 'mcrcon -h' or 'man mcrcon' for help.
root@minecraft:~# export MCRCON_PORT
root@minecraft:~# export MCRCON_PASS
root@minecraft:~# echo $MCRCON_PORT $MCRCON_PASS
25575 password
root@minecraft:~# mcrcon
Connection failed.
Error 111: Connection refused

I was expecting Connection failed on the first run of mcrcon, got You must give password (-p password). instead.

Compilation issue

Howdy,

I'm trying to compile mcrcon, the latest version, and am getting the following error:

cc -std=gnu99 -Wall -Wextra -Wpedantic -Os -s -fstack-protector-strong -o mcrcon mcrcon.c
mcrcon.c: In function ‘get_line’:
mcrcon.c:752:2: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
(void) fgets(buffer, bsize, stdin);

Can you help me out?

Thanks.

Password shown in plain text

Currently the password is specified in plain text when invoking mcrcon.
Example:
./mcrcon -H localhost -P 25575 -p MY_PASSWORD

This obviously allows anyone to see the password on the screen while typing it in and also saves the password to ~/.bash_history.
A solution to this is to allow entering the password via a prompt when -p is not specified.

Pull Request #50 implements this kind of prompt (haven't tested it yet, but looks very promising)

mcrcon encoding issue?

Hi, I installed mcrcon and it connects just fine, but in the terminal I have some sort of encoding problem. My terminal is set to use UTF-8 (gnome 3/arch linux), but up-arrow gives instead of command history output you can see on the bottom line and ? gives this output with strange characters. Could you help with this please?

�--------- �Help: Index (1/23) �--------------------
�Use /help [n] to get page n of help.
�Aliases: �Lists command aliases
�Bukkit: �All commands for Bukkit
�Essentials: �All commands for Essentials
�EssentialsSpawn: �All commands for EssentialsSpawn
�Minecraft: �All commands for Minecraft
�/achievement: �A Mojang provided command.
�/afk: �Marks you as away-from-keyboard.
�/antioch: �A little surprise for operators.
> ^[[A

Commands seem to work ok, it is just strange characters that get appended

> who
ÂThere are Â3Â out of maximum Â20Â players online.

That is when I set encoding to Western ISO-8895-1

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.