rcon/README.md

41 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2021-03-07 18:30:09 +01:00
# rcon
A go written library for the [RCON Protocol](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol).
This is a fork from [james4k/rcon](https://github.com/james4k/rcon) with the support for go modules and with a rework of the original implementation for better readability.
## Usage
```golang
2021-04-06 18:03:06 +02:00
// Establish a connection.
2021-03-07 18:30:09 +01:00
remoteConsole, err := rcon.Dial("127.0.0.1", "password")
if err != nil {
log.Fatal(err)
2021-03-07 18:30:09 +01:00
}
// Close the connection at the end to free the used resources.
defer remoteConsole.Close()
2021-03-07 18:30:09 +01:00
// Send a command.
requestID, err := remoteConsole.Write("command")
if err != nil {
log.Fatal(err)
2021-03-07 18:30:09 +01:00
}
// Read the response.
2021-03-07 18:30:09 +01:00
response, responseID, err := remoteConsole.Read()
if err != nil {
log.Fatal(err)
2021-03-07 18:30:09 +01:00
}
if requestID != responseID {
log.Fatal("response id doesn't match the request id!")
2021-03-07 18:30:09 +01:00
}
fmt.Println(response)
```
## License
2021-04-06 18:03:06 +02:00
This lib is licensed under the [MIT License](LICENSE).
2021-03-07 18:30:09 +01:00
## Contributors
2021-04-06 18:03:06 +02:00
If you should encounter a bug or a missing feature don't hesitate to open an issue or even submit a pull-request.
2021-03-07 18:30:09 +01:00
Special thx to [nhh](https://github.com/nhh) and [dnltinney](https://github.com/dnltinney) for the great help debugging this lib.