Categorygithub.com/wisp-gg/gamequery
repositorypackage
0.0.0-20211108193149-8c623c640ded
Repository: https://github.com/wisp-gg/gamequery.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

gamequery GoDoc

A Golang package for querying game servers

Supported protocols:

Source Query
Minecraft TCP & UDP

Sample code:

package main

import (
	"fmt"
	"github.com/wisp-gg/gamequery"
	"github.com/wisp-gg/gamequery/api"
)

func main() {
	res, protocol, err := gamequery.Detect(api.Request{
		IP: "127.0.0.1",
		Port: 27015,
	})
	if err != nil {
		fmt.Printf("failed to query: %s", err)
		return
	}

	fmt.Printf("Detected the protocol: %s\n", protocol)
	fmt.Printf("%+v\n", res)
}

NOTE: Ideally, you'd only want to use gamequery.Detect only once (or until one successful response), and then use gamequery.Query with the protocol provided. Otherwise, each gamequery.Detect call will try to query the game server with all possible protocols.