-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
144 lines (123 loc) · 4.23 KB
/
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package main
import (
"Waffle/bancho"
"Waffle/bancho/bot"
"Waffle/bancho/chat"
"Waffle/bancho/client_manager"
"Waffle/bancho/irc"
"Waffle/bancho/lobby"
"Waffle/bancho/misc"
"Waffle/bancho/osu/b1815"
"Waffle/bancho/spectator"
"Waffle/config"
"Waffle/database"
"Waffle/helpers"
"Waffle/scheduler"
"crypto/md5"
"encoding/hex"
"os"
"strings"
"time"
)
func EnsureDirectoryExists(name string) bool {
_, err := os.Stat(name)
if err == nil {
return false
}
_ = os.Mkdir(name, os.ModePerm)
return true
}
func main() {
EnsureDirectoryExists("logs")
EnsureDirectoryExists("screenshots")
EnsureDirectoryExists("release")
EnsureDirectoryExists("replays")
EnsureDirectoryExists("direct_thumbnails")
EnsureDirectoryExists("mp3_previews")
EnsureDirectoryExists("oszs")
EnsureDirectoryExists("osus")
EnsureDirectoryExists("avatars")
EnsureDirectoryExists("bss_temp")
helpers.InitializeLogger() //Initializes Logging, logs to both console and to a file
chat.InitializeChannels() //Initializes Chat channels
client_manager.InitializeClientManager() //Initializes the client manager
spectator.InitializeClientManager() //Initializes the spectator client manager
lobby.InitializeLobby() //Initializes the multi lobby
bot.WaffleBotInitializeCommands() //Initializes Chat Commands
misc.InitializeStatistics() //Initializes Statistics
b1815.InitializeCompatibilityLists() //Initializes Client Compatibility lists
config.ReadConfiguration() //Initializes all Configurable things
scheduler.InitializeJobScheduler() //Initializes the Scheduler
database.Initialize() //Initializes Database Connection and things
database.InitializeMigrations() //Initializes Database Migrations
database.InitializeDatabaseVersion() //Initializes the Current Database Version
switch len(os.Args) {
case 2:
switch os.Args[1] {
case "migrate":
database.RunNecessaryMigrations()
return
case "more_data":
GetAdditionalBeatmapInfo()
return
case "eyup":
InitialDiffCalcEyup()
return
}
case 3:
switch os.Args[1] {
case "beatmap_versions":
RunBeatmapClientVersionDetector(os.Args[2], false)
case "beatmap_importer":
BeatmapImporter(os.Args[2])
case "osz_renamer":
RenameOszs(os.Args[2])
case "osu_mover":
MoveOsuFiles(os.Args[2])
case "migrate":
database.RunNecessaryMigrations()
}
return
case 4:
switch os.Args[1] {
case "beatmap_versions":
RunBeatmapClientVersionDetector(os.Args[2], os.Args[3] == "write")
}
}
//Ensure all the updater items exist
result, items := database.UpdaterGetUpdaterItems()
if result == -1 {
helpers.Logger.Printf("[Updater Checks] Failed to retrieve updater information!!!!!")
}
for _, item := range items {
_, fileError := os.Stat("release/" + item.ServerFilename)
if fileError != nil {
helpers.Logger.Printf("[Updater Checks] Updater Item File %s does not exist or cannot be accessed!\n", item.ServerFilename)
helpers.Logger.Printf("[Updater Checks] You can download the Updater Bundle here: https://eevee-sylveon.s-ul.eu/XqLHU708\n")
}
//Zip files will always have a mismatches hash, as they will be extracted client side
if strings.HasSuffix(item.ServerFilename, ".zip") {
continue
}
fileData, readErr := os.ReadFile("release/" + item.ServerFilename)
if readErr != nil {
helpers.Logger.Printf("[Updater Checks] Updater Item File %s does not exist or cannot be accessed!\n", item.ServerFilename)
helpers.Logger.Printf("[Updater Checks] You can download the Updater Bundle here: https://eevee-sylveon.s-ul.eu/XqLHU708\n")
}
fileHash := md5.Sum(fileData)
fileHashString := hex.EncodeToString(fileHash[:])
if item.FileHash != fileHashString {
helpers.Logger.Printf("[Updater Checks] Updater Item File %s has mismatched MD5 Hashes!\n", item.ServerFilename)
helpers.Logger.Printf("[Updater Checks] Your hashes need to match in the database!\n")
helpers.Logger.Printf("[Updater Checks] You can download the Updater Bundle here: https://eevee-sylveon.s-ul.eu/XqLHU708\n")
}
}
bot.CreateWaffleBot() //Creates WaffleBot
go bancho.RunBancho()
go RunWeb()
go irc.RunIrcSSL()
go irc.RunIrc()
for {
time.Sleep(2 * time.Second)
}
}