-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (44 loc) · 880 Bytes
/
main.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
package main
import (
"bufio"
"fmt"
"os"
"strings"
"./rcon"
)
const addr = "192.168.0.30"
const port = "25575"
func main() {
/*
conn, err := net.Dial("tcp", addr+":"+port)
if err != nil {
fmt.Println(err)
return
}
defer conn.Close()
fmt.Println("Connected to", addr+":"+port)
inputReader := bufio.NewReader(os.Stdin)
for {
input, _ := inputReader.ReadString('\n')
conn.Write([]byte(input))
}
*/
Rcon := new(rcon.Rcon)
Rcon.Host = addr
Rcon.Port = port
Rcon.Password = "logitech"
Rcon.Connect()
defer Rcon.Close()
inputReader := bufio.NewReader(os.Stdin)
for {
fmt.Print("> ")
input, _ := inputReader.ReadString('\n')
input = strings.Replace(input, "\n", "", -1)
switch input {
case "exit":
return
}
response, _ := Rcon.Command(strings.Replace(input, "\n", "", -1))
fmt.Println("Response:", response)
}
}