An implementation of the Hell Let Loose RCon protocol in Go. The protocol itself is documented in a Community effort in this document.
Import the module as usual with go modules, then use it according to the example:
package main
import (
"context"
"github.com/floriansw/go-hll-rcon/rcon"
"log/slog"
"os"
"strconv"
)
func main() {
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo}))
port, err := strconv.Atoi(os.Getenv("PORT"))
if err != nil {
panic(err)
}
p, err := rcon.NewConnectionPool(rcon.ConnectionPoolOptions{
Logger: logger,
Hostname: os.Getenv("HOST"),
Port: port,
Password: os.Getenv("PASSWORD"),
})
if err != nil {
panic(err)
}
err = p.WithConnection(context.Background(), func(c *rcon.Connection) error {
m, err := c.Maps()
if err != nil {
println(err.Error())
return err
}
for _, n := range m {
println(n)
}
return nil
})
if err != nil {
panic(err)
}
}
Executing this code will list the available maps of the Hell Let Loose server.
go-hll-rcon
covers all available RCon commands from Hell Let Loose.
The available commands are documented in rcon/connection.go.