-
Notifications
You must be signed in to change notification settings - Fork 28
/
servers.go
58 lines (48 loc) · 914 Bytes
/
servers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package steamapi
import (
"net"
"net/url"
)
type RegionId int
const (
World RegionId = 255
USEast RegionId = iota
USWest
SouthAmerica
Europe
Asia
Australia
MiddleEast
Africa
)
type serverInfoJson struct {
Response struct {
Success bool
Servers []ServerInfo
}
}
type ServerInfo struct {
Addr string
// Seems to always be 65534
// TODO: find out meaning of value
Gmsindex uint32
Message string
AppId uint64
GameDir string
Region RegionId
VACSecured bool `json:"secure"`
LANOnly bool `json:"lan"`
GamePort uint16
SpecPort uint16
}
func GetServerInfo(ip net.IP) ([]ServerInfo, error) {
getServerInfo := NewSteamMethod("ISteamApps", "GetServersAtAddress", 1)
vals := url.Values{}
vals.Add("addr", ip.String())
var resp serverInfoJson
err := getServerInfo.Request(vals, &resp)
if err != nil {
return nil, err
}
return resp.Response.Servers, nil
}