Skip to content

mpawlowski/go-a2s

 
 

Repository files navigation

Go A2S

Build Status Go Report Card GoDoc

An implementation of Source A2S Queries

Godoc is available here: https://godoc.org/github.com/rumblefrog/go-a2s

Note: Only supports Source engine and above, Goldsource is not supported

Guides

Installing

go get -u github.com/rumblefrog/go-a2s

Querying

package main

import (
    "github.com/rumblefrog/go-a2s"
)

func main() {
    client, err := a2s.NewClient("ServerIP:Port")

    if err != nil {
        // Handle error
    }

    defer client.Close()

    info, err := client.QueryInfo() // QueryInfo, QueryPlayer, QueryRules

    if err != nil {
        // Handle error
    }

    // ...
}

Setting client options

package main

import (
    "github.com/rumblefrog/go-a2s"
)

func main() {
    client, err := a2s.NewClient(
        "ServerIP:Port",
        a2s.SetMaxPacketSize(14000), // Some engine does not follow the protocol spec, and may require bigger packet buffer
        a2s.TimeoutOption(time.Second * 5), // Setting timeout option. Default is 3 seconds
        // ... Other options
    )

    if err != nil {
        // Handle error
    }

    defer client.Close()

    // ...
}

Credits

  • Dvander's Blaster for the packet logics
  • xPaw's PHP Source Query for query specific logics

About

Golang implementation of Source Query

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%