This repository has been archived by the owner on Jun 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
240 lines (233 loc) · 5.11 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
package main
import (
"fmt"
"github.com/ViRb3/optic-go"
"log"
"net/http"
"time"
)
var defaultHeaders = map[string]string{
"Accept-Language": "en-US",
"Connection": "keep-alive",
"Origin": "https://www.twitch.tv",
"Referer": "https://www.twitch.tv",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) " +
"twitch-desktop-electron-platform/1.0.0 Chrome/78.0.3904.130 Electron/7.3.3 Safari/537.36 desklight/8.57.0",
}
type CustomTripper struct{}
func (t CustomTripper) RoundTrip(req *http.Request) (*http.Response, error) {
for key, val := range defaultHeaders {
req.Header.Set(key, val)
}
return http.DefaultTransport.RoundTrip(req)
}
func main() {
tester, err := opticgo.NewTester(opticgo.Config{
ApiUrl: opticgo.MustUrl("https://addons-ecs.forgesvc.net/api/v2/"),
ProxyListenAddr: "",
OpticUrl: opticgo.MustUrl("http://localhost:8889"),
DebugPrint: false,
RoundTripper: CustomTripper{},
InternetCheckTimeout: 10 * time.Second,
})
if err != nil {
log.Fatalln(err)
}
errChan, _ := tester.Start(getTests())
errText := ""
for err := range errChan {
errText += err.Error() + "\n"
}
if errText != "" {
log.Fatalln(errText)
}
}
func getTests() []opticgo.TestDefinition {
return []opticgo.TestDefinition{
// ---------------------------------------------------------------------------------------------
// Addon
// ---------------------------------------------------------------------------------------------
{
"Get Addons Database Timestamp",
nil,
fmt.Sprintf("addon/timestamp"),
"GET",
},
{
"Addon Search",
nil,
fmt.Sprintf("addon/search"+
"?categoryId=%d"+
"&gameId=%d"+
"&gameVersion=%s"+
"&index=%d"+
"&pageSize=%d"+
"&searchFilter=%s"+
"§ionId=%d"+
"&sort=%d",
0, 432, "1.12.2", 0, 25, "ultimate", 4471, 0),
"GET",
},
{
"Get Addon Info",
nil,
fmt.Sprintf("addon/%d", 310806),
"GET",
},
{
"Get Multiple Addons",
[]int64{310806, 304026},
fmt.Sprintf("addon"),
"POST",
},
{
"Get Featured Addons",
struct {
GameId int `json:"GameId"`
AddonIds []int64 `json:"addonIds"`
FeaturedCount int `json:"featuredCount"`
PopularCount int `json:"popularCount"`
UpdatedCount int `json:"updatedCount"`
}{
432,
[]int64{},
6,
14,
14,
},
fmt.Sprintf("addon/featured"),
"POST",
},
{
"Get Addon by Fingerprint",
[]int64{3028671922},
"fingerprint",
"POST",
},
{
"Get Addon Description",
nil,
fmt.Sprintf("addon/%d/description", 310806),
"GET",
},
{
"Get Addon File Changelog",
nil,
fmt.Sprintf("addon/%d/file/%d/changelog", 310806, 2657461),
"GET",
},
{
"Get Addon File Download URL",
nil,
fmt.Sprintf("addon/%d/file/%d/download-url", 296062, 2724357),
"GET",
},
{
"Get Addon File Information",
nil,
fmt.Sprintf("addon/%d/file/%d", 310806, 2657461),
"GET",
},
{
"Get Addon Files",
nil,
fmt.Sprintf("addon/%d/files", 304026),
"GET",
},
// ---------------------------------------------------------------------------------------------
// Category
// ---------------------------------------------------------------------------------------------
{
"Get Category Info",
nil,
fmt.Sprintf("category/%d", 423),
"GET",
},
{
"Get Category List",
nil,
fmt.Sprintf("category"),
"GET",
},
{
"Get Category Section Info",
nil,
fmt.Sprintf("category/section/%d", 6),
"GET",
},
{
"Get Category Timestamp",
nil,
fmt.Sprintf("category/timestamp"),
"GET",
},
// ---------------------------------------------------------------------------------------------
// Game
// ---------------------------------------------------------------------------------------------
{
"Get Game Info",
nil,
fmt.Sprintf("game/%d", 432),
"GET",
},
{
"Get Games List",
nil,
fmt.Sprintf("game"),
"GET",
},
{
"Get Addon-Supported Games List",
nil,
fmt.Sprintf("game?supportsAddons"),
"GET",
},
// ---------------------------------------------------------------------------------------------
// Minecraft
// ---------------------------------------------------------------------------------------------
{
"Get Minecraft Version Info",
nil,
fmt.Sprintf("minecraft/version/%s", "1.12.2"),
"GET",
},
{
"Get Minecraft Version List",
nil,
fmt.Sprintf("minecraft/version"),
"GET",
},
{
"Get Minecraft Version Timestamp",
nil,
fmt.Sprintf("minecraft/version/timestamp"),
"GET",
},
{
"Get Modloaders for Version",
nil,
fmt.Sprintf("minecraft/modloader?version=1.12.2"),
"GET",
},
{
"Get Modloader Info",
nil,
fmt.Sprintf("minecraft/modloader/%s", "forge-12.17.0.1980"),
"GET",
},
{
"Get Modloader List",
nil,
fmt.Sprintf("minecraft/modloader"),
"GET",
},
{
"Get Modloader Timestamp",
nil,
fmt.Sprintf("minecraft/modloader/timestamp"),
"GET",
},
}
}