go-svrquery is a Go client for talking to game servers using various query protocols.
- Support for various game server query protocol's including: ** SQP, TF2E
go get -u github.com/multiplay/go-svrquery
Using go-svrquery is simple just create a client and then send commands e.g.
package main
import (
"log"
"time"
"github.com/multiplay/go-svrquery/lib/svrquery"
)
func main() {
c, err := svrquery.NewClient("tf2e", "192.168.1.102:10011")
if err != nil {
log.Fatal(err)
}
defer c.Close()
r, err := c.Query()
if err != nil {
log.Fatal(err)
}
log.Printf("%#v\n", r)
}
A cli is available in github releases and also at https://github.com/multiplay/go-svrquery/tree/master/cmd/cli
This enables you make queries to servers using the specified protocol, and returns the response in pretty json.
./go-svrquery -addr localhost:12121 -proto sqp
{
"version": 1,
"address": "localhost:12121",
"server_info": {
"current_players": 1,
"max_players": 2,
"server_name": "Name",
"game_type": "Game Type",
"build_id": "",
"map": "Map",
"port": 1000
}
}
This tool also provides the ability to start a very basic sample server using a given protocol.
Currently, only sqp
is supported
./go-svrquery -server :12121 -proto sqp
Starting sample server using protocol sqp on :12121
go-svrquery is available under the BSD 2-Clause License.