-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
71 lines (60 loc) · 1.49 KB
/
main.go
File metadata and controls
71 lines (60 loc) · 1.49 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"bytes"
"dofus-proxy/config"
"dofus-proxy/cosmetic"
connection "dofus-proxy/proto/connection/connection"
game "dofus-proxy/proto/game/message"
"dofus-proxy/proxy"
"os"
"os/exec"
"strings"
"time"
)
const (
CONNECTION_PROXY_PORT = 5555
GAME_PROXY_PORT = 5556
CONFIG_PORT = 1234
DOFUS_PROCESS = "Dofus.exe"
)
func isProcessRunning(process string) bool {
cmd := exec.Command("tasklist")
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
return false
}
return strings.Contains(out.String(), process)
}
func main() {
file, err := os.OpenFile("log.txt", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
return
}
defer file.Close()
os.Stdout = file
undoRedirectZaap, err := config.RedirectZaap(CONFIG_PORT)
if err != nil {
return
}
defer undoRedirectZaap()
originalHost, err := config.Run(CONNECTION_PROXY_PORT, CONFIG_PORT)
if err != nil {
return
}
connectionProxy := proxy.New("Connection", &connection.Message{})
gameProxy := proxy.New("Game", &game.Message{})
connectionProxy.AddLogListener()
gameProxy.AddLogListener()
cosmetic.AddCosmeticInventoryModifier(gameProxy)
cosmetic.AddCosmeticInventoryEquipFilter(gameProxy)
connectionProxy.AddConnectionModifier(gameProxy, GAME_PROXY_PORT)
go connectionProxy.Listen(originalHost, CONNECTION_PROXY_PORT)
for !isProcessRunning(DOFUS_PROCESS) {
time.Sleep(5 * time.Second)
}
for isProcessRunning(DOFUS_PROCESS) {
time.Sleep(5 * time.Second)
}
}