Skip to content

sebasslash/rcon-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rcon-go

A simple RCON client written in Go

Note: This client doesn't yet implement the full RCON protocol spec.

Installation

go get -u github.com/sebasslash/rcon-go

Example Usage

import (
    "log"

    rcon "github.com/sebasslash/rcon-go"
)

func main() {
	config := &rcon.RCONConfig{
		Host: "my-awesome-server-ip",
		Port: 27015,
		Password: "my-awesome-server-pwd",
		MaxPayloadSize: 4096,
	}

    client := &rcon.RCONClient{
        Config: config
    }

    err := client.Open()
    if err != nil {
        log.Fatal(err)
    }
    defer client.Close()

    // Using a Mordhau specific RCON command 
    resp, err := client.SendCommand("playerlist")
    if err != nil {
        log.Fatal(err)
    }
    
    log.Printf("Server response:\n %s", resp)
}

Running Tests

In order to run the tests, a few env variables are expected:

  1. RCON_GO_HOST - The host to test against
  2. RCON_GO_PORT - The port the RCON service is listening on
  3. RCON_GO_PWD - The password used for authentication
  4. RCON_GO_TEST_COMMAND - A test command to send to the server

About

A simple RCON client library in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages