A go written library for the RCON Protocol.
Find a file
Augusto Dwenger J 05aea9e665
Fix packet parsing
With the old implementation we skipped one byte of the body and did not read
an empty body.
Not being able to read an empty body was not the only problem with the
old implementation. It could also happen that for what ever reason an
null byte was encoded inside of it and with the old implementation we
would stop at this null and ignore the rest.
2022-02-11 17:01:46 +01:00
.drone.yml Add Drone CI setup 2021-03-06 16:19:24 +01:00
.gitignore Add gitignore 2021-03-06 16:20:39 +01:00
go.mod Add go module 2021-03-02 18:39:59 +01:00
LICENSE Add copyright holder 2021-03-02 18:40:51 +01:00
rcon.go Fix packet parsing 2022-02-11 17:01:46 +01:00
rcon_test.go Move test password to a global constant 2021-04-06 18:06:59 +02:00
README.md Fix usage example 2022-02-07 20:33:47 +01:00

rcon

A go written library for the RCON Protocol.

This is a fork from james4k/rcon with the support for go modules and with a rework of the original implementation for better readability.

Usage

// Establish a connection.
remoteConsole, err := rcon.Dial("127.0.0.1", "password")
if err != nil {
    log.Fatal(err)
}
// Close the connection at the end to free the used resources.
defer remoteConsole.Close()

// Send a command.
requestID, err := remoteConsole.Write("command")
if err != nil {
    log.Fatal(err)
}

// Read the response.
response, responseID, err := remoteConsole.Read()
if err != nil {
    log.Fatal(err)
}
if requestID != responseID {
    log.Fatal("response id doesn't match the request id!")
}

fmt.Println(response)

License

This lib is licensed under the MIT License.

Contributors

If you should encounter a bug or a missing feature don't hesitate to open an issue or even submit a pull-request.

Special thx to nhh and dnltinney for the great help debugging this lib.