Documentation ¶
Overview ¶
query package implements the mincraft query protocol. This package is strictly compliant with the following documentation : https://wiki.vg/Query.
Index ¶
Constants ¶
const (
MagicValue uint16 = 65277
)
Variables ¶
var ( FullStatRequestPadding = [4]byte{0x00, 0x00, 0x00, 0x00} FullStatResponsePadding1 = [11]byte{0x73, 0x70, 0x6C, 0x69, 0x74, 0x6E, 0x75, 0x6D, 0x00, 0x80, 0x00} FullStatResponsePadding2 = [10]byte{0x01, 0x70, 0x6C, 0x61, 0x79, 0x65, 0x72, 0x5F, 0x00, 0x00} )
Functions ¶
This section is empty.
Types ¶
type BasicStat ¶
type BasicStat struct { MOTD string `json:"motd"` GameType string `json:"gameType"` Map string `json:"map"` NumPlayers int `json:"numPlayers"` MaxPlayers int `json:"maxPlayers"` HostPort int `json:"hostPort"` HostIP string `json:"hostIp"` }
BasicStat contains basic stat query informations.
type FullStat ¶
type FullStat struct { Properties map[string]string `json:"properties"` OnlinePlayers []string `json:"onlinePlayers"` }
FullStat contains full stat query informations.
type QueryClient ¶
type QueryClient struct { // options SkipSRVLookup bool ForceUDPProtocolForSRVLookup bool DialTimeout time.Duration ReadTimeout time.Duration // contains filtered or unexported fields }
QueryClient is the query client. challengeToken isn't stored in the client as it can change in the lifetime of a client, while session ID doesn't.
func NewClient ¶
func NewClient(hostname string, port int) *QueryClient
NewClient returns a well-formed *QueryClient.
func (*QueryClient) BasicStat ¶
func (client *QueryClient) BasicStat(challengeToken uint32) (BasicStat, error)
BasicStat sends a basic stat query to the server, and returns the formatted result.
func (*QueryClient) Connect ¶
func (client *QueryClient) Connect() error
Connect establishes a connection via UDP.
func (*QueryClient) Disconnect ¶
func (client *QueryClient) Disconnect() error
Disconnect closes the connection. Connection is made not usable anymore no matter if the it closed properly or not.
func (*QueryClient) FullStat ¶
func (client *QueryClient) FullStat(challengeToken uint32) (FullStat, error)
FullStat sends a full stat query to the server, and returns the formatted result.
func (*QueryClient) Handshake ¶
func (client *QueryClient) Handshake() (uint32, error)
Handshake sends a handshake query to the server, and returns the challenge token if successful.