go-battleye is a Go client for the BattlEye RCON Protocol.
go get -u github.com/multiplay/go-battleye
Using go-battleye is simple, just create a client then execute commands e.g.
package main
import (
"log"
battleye "github.com/multiplay/go-battleye"
)
func main() {
c, err := battleye.NewClient("192.168.1.102:2301", "mypass")
if err != nil {
log.Fatal(err)
}
defer c.Close()
resp, err := c.Exec("version")
if err != nil {
log.Fatal(err)
}
log.Println("server version:", resp)
}
Server broadcast messages arrive in a buffered read-only channel. By default, there is room for
100 messages. You can get more by using the MessageBuffer
option in the client constructor:
battleye.NewClient("192.168.1.102:2301", "mypass", battleye.MessageBuffer(500))
If the channel gets full, new messages will be dropped. It is your responsibility to drain the channel, e.g.:
func LogServerMessages(c *battleye.Client) {
for {
switch {
case msg := <-c.Messages():
log.Println(msg)
// Another case to exit the for loop.
// ...
}
}
}
Run integration test using your own BattlEye server:
go test -v -tags=integration -run=Integration -address=<BattlEye server address> -password=<admin password>
go-battleye is available under the BSD 2-Clause License.