Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Hezaerd/rcon-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RCON CLI

A robust command-line interface for communicating with Minecraft servers using the RCON (Remote Console) protocol.

Features

  • πŸ”Œ Full RCON Protocol Support - Complete implementation of the Minecraft RCON protocol
  • πŸš€ Async/Await - Built with Tokio for efficient async networking
  • 🎯 Multiple Modes - Single command execution, interactive sessions, and more
  • 🎨 Rich Output - Colored output and multiple formatting options (text/JSON)
  • πŸ”„ Auto-Reconnection - Automatic reconnection on connection loss
  • πŸ“¦ Response Fragmentation - Proper handling of large server responses
  • πŸ›‘οΈ Error Handling - Comprehensive error handling and validation

Installation

From Source

git clone https://github.com/etheria-project/rcon-cli.git
cd rcon-cli
cargo build --release

The binary will be available at target/release/rcon-cli.

Prerequisites: Rust 1.70+ and a Minecraft server with RCON enabled.

Quick Start

  1. Enable RCON in your server.properties:

    enable-rcon=true
    rcon.password=your_password_here
    rcon.port=25575
  2. Execute commands:

    # Single command
    ./rcon-cli -a localhost:25575 -p your_password exec "list"
    
    # Interactive session
    ./rcon-cli -a localhost:25575 -p your_password interactive

Usage

rcon-cli [OPTIONS] <COMMAND>

Global Options

  • -a, --address <HOST:PORT> - Server address (default: localhost:25575)
  • -p, --password <PASSWORD> - RCON password (or use RCON_PASSWORD env var)
  • -t, --timeout <SECONDS> - Connection timeout (default: 5)
  • -v, --verbose - Increase logging verbosity
  • -f, --format <FORMAT> - Output format: text or json
  • --no-color - Disable colored output

Commands

Execute Single Command

rcon-cli -a localhost:25575 -p secret exec "list"
rcon-cli -a localhost:25575 -p secret exec --time "weather clear"

Interactive Mode

rcon-cli -a localhost:25575 -p secret interactive --prompt "minecraft> "

Interactive commands: help, status, reconnect, quit/exit

Additional Commands

# Test connectivity
rcon-cli -a localhost:25575 -p secret ping -c 5

# Server information
rcon-cli -a localhost:25575 -p secret info --detailed

# List players
rcon-cli -a localhost:25575 -p secret players --uuids

Examples

Environment Variables & JSON Output

export RCON_PASSWORD="your_secret_password"
rcon-cli -a localhost:25575 -f json exec "list"

Common Minecraft Commands

# Player management
rcon-cli exec "kick player_name reason"
rcon-cli exec "gamemode creative player_name"

# World management
rcon-cli exec "time set day"
rcon-cli exec "weather clear"

# Server management
rcon-cli exec "save-all"
rcon-cli exec "whitelist add player_name"

Library Usage

use rcon_cli::{RconClient, RconConfig};
use std::net::SocketAddr;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let addr = "localhost:25575".parse::<SocketAddr>()?;
    let config = RconConfig::new(addr, "my_password");
    
    let mut client = RconClient::connect(config).await?;
    let response = client.execute_command("list").await?;
    
    println!("Server response: {}", response);
    Ok(())
}

Project Structure

src/
β”œβ”€β”€ lib.rs          # Library root and public API
β”œβ”€β”€ main.rs         # Binary entry point
β”œβ”€β”€ cli.rs          # Command-line interface definitions
β”œβ”€β”€ client.rs       # RCON client implementation
β”œβ”€β”€ protocol.rs     # RCON protocol and packet handling
└── error.rs        # Error types and handling

Releases

Creating a New Release

  1. Update changelog.md with your changes
  2. Create and push a version tag:
    git tag v1.1.0
    git push origin v1.1.0

When you push a version tag (v*.*.*), GitHub Actions automatically:

  • Builds cross-platform binaries (Windows, Linux, macOS)
  • Creates a GitHub release with changelog and downloadable archives
  • Updates the changelog with a new unreleased section

Security Notes

⚠️ Important: RCON is not encrypted. Use strong passwords, limit to trusted networks, and consider SSH tunneling for remote access.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for your changes
  4. Submit a pull request

License

MIT License - see the LICENSE file for details.

Built from πŸ’– by Etheria

This project is crafted with love by the Hezaerd for the Etheria Team. I'm passionate about creating tools that make Minecraft server management easier and more enjoyable.

Acknowledgments

About

CLI implementation of the RCON protocol for minecraft

Topics

Resources

License

Stars

Watchers

Forks

Languages