Coder Social home page Coder Social logo

gorcon / rcon-cli Goto Github PK

View Code? Open in Web Editor NEW
455.0 16.0 44.0 146 KB

RCON client for executing queries on game server.

License: MIT License

Go 93.58% Shell 3.36% Dockerfile 1.06% Makefile 2.00%
rcon rcon-cli project-zomboid conan-exiles ark-survival-evolved rcon-protocol steam minecraft csgo projectzomboid

rcon-cli's Introduction

rcon-cli

Mentioned in Awesome-Selfhosted GitHub Build Go Coverage Go Report Card GitHub All Releases Docker Pulls

CLI for executing queries on a remote Source dedicated game server, using the RCON protocol.

Supported Games

Open pull request if you have successfully used a package with another game with rcon support and add it to the list.

Installation

Download the binary for your platform from the latest releases

See Changelog for release details

Docker

docker pull outdead/rcon

Usage

USAGE:
   rcon [options] [commands...]

GLOBAL OPTIONS:
   --address value, -a value   Set host and port to remote server. Example 127.0.0.1:16260
   --password value, -p value  Set password to remote server
   --type value, -t value      Specify type of connection (default: rcon)
   --log value, -l value       Path to the log file. If not specified it is taken from the config
   --config value, -c value    Path to the configuration file (default: rcon.yaml)
   --env value, -e value       Config environment with server credentials (default: default)
   --skip, -s                  Skip errors and run next command (default: false)
   --timeout value, -T value   Set dial and execute timeout (default: 10s)
   --help, -h                  show help (default: false)
   --version, -v               print the version (default: false)

Rcon CLI can be run in two modes - in the mode of a single query and in the mode of reading the input stream

Single mode

Server address, password and command to server must be specified in flags at startup. Example:

./rcon -a 127.0.0.1:16260 -p mypassword command

It is possible to send several commands in one request. Example:

./rcon -a 127.0.0.1:16260 -p mypassword command "command with several words" 'command "with double quotes"'

If commands passed, they sent in a single mode. The response displayed, and the CLI will exit.

Interactive input stream mode

To run CLI in interactive mode run rcon without commands. Example:

./rcon -a 127.0.0.1:16260 -p mypassword

Use ^C to terminate or type command :q to exit.

In Docker

docker run -it --rm outdead/rcon ./rcon [options] [commands...]

You can add your config file as volume:

docker run -it --rm \
      -v /path/to/rcon-local.yaml:/rcon.yaml \
      outdead/rcon ./rcon -c rcon.yaml -e default players

Configuration file

For more convenient use, the ability to create the rcon.yaml configuration file provided. You can save the host and port of the remote server and its password. If the configuration file exists, and the default block filled in it, then at startup the -a and -p flags can be omitted. Examples:

./rcon -a 127.0.0.1:16260 players
./rcon status
./rcon -p mypassword
./rcon

Default configuration file name is rcon.yaml. File must be saved in yaml format. It is also possible to set the environment name and connection parameters for each server. You can enable logging requests and responses. To do this, you need to define the log variable in the environment blocks. You can do this for each server separately and create different log files for them. If the path to the log file not specified, then logging will not be conducted.

default:
  address: "127.0.0.1:16260"
  password: "password"
  log: "rcon-default.log"
zomboid:
  address: "127.0.0.1:16260"
  password: "password"
  log: "rcon-zomboid.log"
rust:
  address: "127.0.0.1:28003"
  password: "password"
7dtd:
  address: "172.19.0.2:8081"
  password: "password"
  type: "telnet"

Args

You can choose the environment at the start:

./rcon -e rust status
./rcon -e zomboid

Set custom config file:

./rcon -c /path/to/config/file.yaml

Use -l argument to specify path to log file:

./rcon -l /path/to/file.log

Use -t argument to specify the protocol type:

# 7 Days to Die
./rcon -a 172.19.0.2:8081 -p password -t telnet version

# Rust
./rcon -a 127.0.0.1:28016 -p password -t web status

Use -T argument to specify dial and execute timeout:

./rcon -a 172.19.0.2:8081 -p password -t telnet -T 10s version

Contribute

If you think that you have found a bug, create an issue and indicate your operating system, platform, and the game on which the error reproduced. Also describe what you were doing so that the error could be reproduced.

License

MIT License, see LICENSE

rcon-cli's People

Contributors

coolapso avatar haloghen avatar jakelunn avatar nodiscc avatar outdead avatar quintenqvd0 avatar rfvgyhn avatar sunstep avatar zhufucdev 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

rcon-cli's Issues

Working with palworld!... but

Hey there, i have not been able to run it on docker due to my lack of exp and a docker-compose file.

but it is working if i use it directly! my only problem is that i cannot send strings with spaces.
image

PalWorld i/o timeout

➜  rcon ./rcon
Waiting commands for 127.0.0.1:25575 (or type :q to exit)
> showplayers
name,playeruid,steamid
**,**,**
cli: execute: rcon: read tcp 127.0.0.1:33370->127.0.0.1:25575: i/o timeout
➜  rcon

ENV

Ubuntu 22.4

rcon.yaml

default:
  address: "127.0.0.1:25575" # host:port, for example 127.0.0.1:16260
  password: ""
  log: "rcon-default.log"
  type: "" # rcon, telnet, web.
  timeout: "60s"

Windows - Command with double quotes treated as separate commands

Tested on a Zomboid server on Win10 - 22H2, but had same issue on a previous version.

Issue: Command with double quotes treated as multiple commands on windows systems

Expected behaviour: 'command "string-for-command"' passes the command with "string-for-command" to rcon server

Experienced behaviour: command is treated by rcon client as multiple separate commands

Not working in Powershell - PSVersion - 5.1.19041.2364
Haven't tested on other versions of powershell.
image

Not working in cmd:
image

Working in WSL - Ubuntu:
image

Also works in my Linux server with no problems

Feature Request: Modify rcon.yaml Reading Method

In Linux, I would like to place rcon in /usr/local/bin and call it as a comand, but it throws an error when the rcon.yaml file is missing in the current directory.

Here is my suggestion: allow rcon.yaml to be optional if not found. When searching for rcon.yaml, I recommend that it first searches the current folder. If not found, it should then search the user's home folder. If still not found, it should proceed to search the /etc folder. If not found in any of these locations, the rcon.yaml file can be skipped.

Public IP support for config

I am having trouble with getting a public IP to work on my config. It works when I call the variables directly but when it's in the config, it tries to map from my local IP I guess.

Here's what my config looks like

default:
  address: "123.123.123.0:28016"
  password: "password"
  type: "rust"

and the output when I try running the default and manually

C:\Users\User>rcon -c status
read tcp 192.168.1.2:4719->123.123.123.0:28016: i/o timeout
C:\Users\User>rcon -a 123.123.123.0:28016 -p password -t web -c status
hostname: hi there
rest here

Crash when entering environment variable

I have been trying for hours now to enter the ./rcon -e zomboid command after editing my .yaml file with all the correct information. Every time I enter it the console just crashes out. No idea why. Only thing I have to go on is that when I type ./rcon -e all by itself it loads the default information, which is empty but it does run and asks for a password, then crashes when I enter.

No longer works with Rust

default:
  address: "127.0.0.1:28016" # host:port, for example 127.0.0.1:16260
  password: "test1234"
  log: "rcon-default.log"
  type: "web" # rcon, telnet, web.
  timeout: "10s"

C:\rustserver>rcon test
cli: execute: auth: rcon: rcon: read packet size: read tcp 127.0.0.1:64172->127.0.0.1:28016: i/o timeout

cli: websocket: authentication failed

Hi.

  1. I build rcon-cli on my macOS 10.15.7 (Catalina)
  2. Connect my RUST server: ./rcon-cli -a ip:port -p pass -t web
  3. In server rust config enable rconweb (rconweb="1")
  4. I get an error: cli: websocket: authentication failed

When i change rconweb="0" (in my RUST server conf) and write command:
./rcon-cli -a ip:port -p pass -t rcon, rcon-cli work normaly.

How to make it work with rconweb="1"?
screen

[QUESTION] Plugin for Unraid

Hi @outdead,

is it okay for you if I distribute your rcon-cli as a plugin for Unraid so that Unraid users can easily make use of it?
Since I was in search for a new source for a reliable rcon cli client I found your repository, which I actually really like because it's based on golang.

Currently I have a plugin for rcon that is based of another repository, that seems to be not maintained anymore, see my plugin here.

If you have a PayPal or sponsor link let me know and I'm happy to change the Donation link in the plugin to that.

Cheers,
Christoph

Critical Vulnerability in the rcon-cli binary

Hi! first of all, thank you for creating this package, i've included it by default in my Palworld docker container. I did however find something worth noting.

The binary uses stdlib v1.19.3 which includes multiple Critical and High vulnerabilities.
image

Would it be possible to provide a release with the stdlib updated to a more recent version?

Thanks in advance

"rcon.yaml" Does Not Seem To Load By Default

Is there something I'm missing about the default configuration path?

I put it in the current working directory, and it doesn't load it.
I put it in my home folder, and it doesn't load it.
I put it next to the executable, and it doesn't load it.
I made it a dot file, and it doesn't load it.

It seems that feature is just not working?

Rust with web rcon enabled

using command ./rcon -t web -a x.x.x.x:28017 -p password the result is 'not implemented'

Command is sent from the server hosting the rust dedicated server

Web RCON support

Would it be possible to support Web RCON? It uses websockets and can have some benefits over the older source rcon https://github.com/Facepunch/webrcon#rust

Another monitoring tool I use (Battlemetrics) recommends web rcon over source rcon for connection to their site so I am kind of stuck using web rcon for best compatibility with that app.

I did find this https://github.com/bodrich/rust-cmd-webrcon which appears to be a Go Web RCON client. Might be useful for seeing how they did it possibly?
Edit:
Found one more
https://github.com/diametric/rustcon

V Rising

hello,

does this support V Rising?

Support for Quake 1/2/3 Rcon

Howdy! Is there any interest in adding support for rcon with older Quake servers? Could be it's own type, like -t quake.

❯ quake3-rcon IP_ADDRESS RCON_PASS PORT
initialized. write your rcon commands here (send by pressing Enter):
status
server: print
Rcon Packet REDACTED
map              : jerms_da4
...
❯ rcon -a IP_ADDRESS:PORT -p RCON_PASS
cli: auth: rcon: dial tcp IP_ADDRESS:PORT: connect: connection refused

https://github.com/thbaumbach/node-quake3-rcon

[Feature Request] Please add extended install/release instructions with hash-values

Hey @outdead how are you?

I would love to see extended install instructions in the release informations.
Here is an example of what i mean by that:
Supercronic ( https://github.com/aptible/supercronic/releases ) goes the "Ansible-check" way which is very helpful, to make sure you get what you wanted, because you can check the hashsum, and if by any chance thats wrong your ci-pipeline fails on purpose.

Would you be able to add extended install/release/package informations to your releases please?

Cannot use empty password in action mode

When connecting to an rcon server, you may legitimately want to provide an empty string for a password. This is possible in interactive mode, however in 'action' mode, an error will always be thrown if password is not specified, or even if it is with an empty string:

if ses.Password == "" {
return ErrEmptyPassword
}

This makes it impossible to connect to servers with an empty password in action mode. I would propose either adding a flag that allows an empty password, or simply not throwing this error at all since an empty password is a legitimate use-case.

If you're interested in accepting either proposal, I'm also willing to make a PR if you would like.

Is it really work with Palwolrd?

Both Single mode and Interactive mode will report i/o timeout and exit after executing THE FIRST command and printing the output in 10 seconds.
image

rcon.yaml

palworld:
  address: "192.168.1.110:25575"
  password: "xxx"
  log: "palworldRCON.log"
  type: "rcon"
  timeout: "1s"

Does not work with ARK

Ark requires the query port as part of the connection as of a few patches ago.

When using this with ARK you will get dial tcp $IP:$PORT: i/o timeout

Crash on Connection

Using Windows 11.

After entering ip:port and password, the cmd immediately closes with no error given.

Problem persists after disabling anti-virus and restarting computer.

cannot connect with my rust server with +rcon.web "1"

`rcon.exe -a MYIP:28015 -p MyRconPassword -t web
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x54f9c9]

goroutine 1 [running]:
github.com/gorcon/websocket.(*Conn).Close(0x0, 0xc0000a6f80, 0xc00014e120)
/media/pk/hdd/projects/repos/github.com/gorcon/rcon-cli/vendor/github.com/gorcon/websocket/websocket.go:122 +0x29
github.com/gorcon/rcon-cli/internal/executor.(*Executor).Close(0xc0000ec3c0, 0x7, 0xc0000d7e88)
/media/pk/hdd/projects/repos/github.com/gorcon/rcon-cli/internal/executor/executor.go:261 +0x42
github.com/gorcon/rcon-cli/internal/executor.(*Executor).Run(0xc0000ec3c0, 0xc0000e0000, 0x7, 0x8, 0x6bb920, 0xc0000a6f80)
/media/pk/hdd/projects/repos/github.com/gorcon/rcon-cli/internal/executor/executor.go:81 +0x165
main.main()
/media/pk/hdd/projects/repos/github.com/gorcon/rcon-cli/main.go:17 +0x16b`

we use +rcon.web" "1", possible to have a fix please?

Add trace mode

Games are updated and the rcon client for them stops working. Add the --trace flag to display client steps to the stdout. This will help to identify errors.

PZ "Players" command timeout when unsupported characters present

When player names have invisible characters such as " ‎ ‎", which appears as "-ΓÇÄ ΓÇÄ ΓÇÄ" in the console, RCON will timeout with the following error on the server:

LOG : General , 1709045530266> 97.774.271> RCON: new connection Socket[addr=/127.0.0.1,port=55902,localport=] LOG : General , 1709045530267> 97.774.272> RCON: ID=0 Type=3 Body='' Socket[addr=/127.0.0.1,port=55902,localport=] ERROR: General , 1709045530370> 97.774.374> java.nio.BufferOverflowException ERROR: General , 1709045530370> 97.774.375> at java.base/java.nio.HeapByteBuffer.put(Unknown Source) ERROR: General , 1709045530370> 97.774.375> at java.base/java.nio.ByteBuffer.put(Unknown Source) ERROR: General , 1709045530370> 97.774.375> at zombie.network.RCONServer$ClientThread.handleResponse(RCONServer.java:280) ERROR: General , 1709045530370> 97.774.375> at zombie.network.RCONServer$ClientThread.handlePacket(RCONServer.java:213) ERROR: General , 1709045530370> 97.774.375> at zombie.network.RCONServer$ClientThread.runInner(RCONServer.java:165) ERROR: General , 1709045530370> 97.774.375> at zombie.network.RCONServer$ClientThread.run(RCONServer.java:121)

These player names are visible when running the "players" command directly on the server console itself, but throws this BufferOverflowException when done via RCON.

Config File Type Specified But Ignored

I have run into an issue using version 0.10.3 where I have specified my environment information in the rcon.yaml file but when I execute a command using this environment I get the following error "cli: execute: auth: rcon: invalid authentication packet type response". The 7 Days to Die server console logs "ERR Exception in thread TelnetClient". I am running this on a Windows 10 PC with the 7 Days to Die dedicated server version Alpha 20.7(b1).

My rcon.yaml file looks like this:

7Days1:
address: "hostremoved:portremoved"
password: "fakepassword"
type: "telnet"
log: "rcon-7days1.log"
timeout: "10s"

When I enter the following command ".\rcon.exe -e 7Days1 version" is when I get the above mentioned error of "cli: execute: auth: rcon: invalid authentication packet type response".

If I however change my command to ".\rcon.exe -e 7Days1 -t telnet version" I get no errors and I get the expected command output of "2023-06-09T13:56:56 1017.056 INF Executing command 'version' by Telnet from 127.0.0.1:65409
Game version: Alpha 20.7 (b1) Compatibility Version: Alpha 20.7
Mod Server_Info_Window: 1.0.9
Mod More Animals All Biomes Medium (A19/A20): MAAB-1.0".

It seems to me that the type parameter is being ignored in the yaml file and it is defaulting to rcon no matter what.

7DTD Multiple words are not possible

No matter what I do, I cannot use the Say command in 7DTD.

It is not possible to use multiple words.
say Hello World
'say Hello World'
'say "Hello World"'
"say Hello World"
"say 'Hello World'"
Not working. Either only say arrives or only the first word of the message.

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.