forked from kidoman/go-steam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rcon.go
50 lines (46 loc) · 811 Bytes
/
rcon.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
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/kidoman/go-steam"
log "github.com/sirupsen/logrus"
)
func main() {
debug := flag.Bool("debug", false, "debug")
flag.Parse()
if *debug {
steam.SetLog(log.New())
}
addr := os.Getenv("ADDR")
pass := os.Getenv("RCON_PASSWORD")
if addr == "" || pass == "" {
fmt.Println("Please set ADDR & RCON_PASSWORD.")
return
}
for {
o := &steam.ConnectOptions{RCONPassword: pass}
rcon, err := steam.Connect(addr, o)
if err != nil {
fmt.Println(err)
time.Sleep(1 * time.Second)
continue
}
defer rcon.Close()
for {
resp, err := rcon.Send("status")
if err != nil {
fmt.Println(err)
break
}
fmt.Println(resp)
time.Sleep(5 * time.Second)
}
}
}
func must(err error) {
if err != nil {
panic(err)
}
}