-
Notifications
You must be signed in to change notification settings - Fork 1
/
GDServer.cpp
188 lines (150 loc) · 4.95 KB
/
GDServer.cpp
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
/**
* LevelAPI - Geometry Dash level cacher with search functionality and more.
Copyright (C) 2024 Sergei Baigerov
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "GDServer.h"
#include "LevelRange.h"
#include "LevelRangeList.h"
#include "curl_backend.h"
#include "Translation.h"
#include "GDCrypto-patched/Include/GDCrypto/RobTopCipher.hpp"
using namespace gdcrypto;
using namespace LevelAPI::Backend;
std::vector<LevelAPI::LevelRange> _stub11 = {};
GDServer::GDServer() : _ranges(_stub11) {
m_eStatus = GSS_ONLINE;
}
GDServer::GDServer(std::vector<LevelRange> list) : _ranges(list) {
m_eStatus = GSS_ONLINE;
}
GDServer::GDServer(LevelRangeList list) : _ranges(list) {
m_eStatus = GSS_ONLINE;
}
GDServer::~GDServer() {
m_eStatus = GSS_OFFLINE;
}
LevelAPI::DatabaseController::Level *GDServer::getLevelMetaByID(int id, std::optional<CurlProxy> proxy) {
return nullptr;
}
int GDServer::getMaxLevelPageSize() {
return 0;
}
int GDServer::getMaxMapPackPageSize() {
return 0;
}
std::vector<LevelAPI::DatabaseController::Level *> GDServer::getLevelsBySearchType(int type, std::string str, int page, std::optional<CurlProxy> proxy) {
return {};
}
std::vector<LevelAPI::DatabaseController::Level *> GDServer::getLevelsBySearchType(int type, std::optional<CurlProxy> proxy) {
return getLevelsBySearchType(type, "", 0);
}
LevelAPI::DatabaseController::Level *GDServer::resolveLevelData(LevelAPI::DatabaseController::Level *level, std::optional<CurlProxy> proxy) {
return nullptr;
}
void GDServer::setDebug(bool d) {
m_bDebug = d;
}
bool GDServer::getDebug() {
return m_bDebug;
}
void GDServer::setCredentials(std::string u, std::string p) {
m_sUsername = u;
m_sPassword = p;
RobTopCipher gjpCipher(gdcrypto::vecFromArray(keys::GJP_KEY));;
m_sGJPPassword = gjpCipher.encode(m_sPassword);
}
GDServerUploadResult *GDServer::uploadLevel(DatabaseController::Level *level, std::optional<CurlProxy> proxy) {
return nullptr;
}
bool GDServer::login(std::optional<CurlProxy> proxy) {
return false;
}
int GDServer::getGameVersion() {
return 0;
}
std::string GDServer::_getDownloadLevelEndpointName() {
return "";
}
std::string GDServer::_getLevelListEndpointName() {
return "";
}
std::string GDServer::_getLoginAccountEndpointName() {
return "";
}
std::string GDServer::_getSecretValueStandard() {
return "";
}
std::string GDServer::_getSecretValueExtra() {
return "";
}
std::string GDServer::determineGVFromID(int id) {
return _ranges[id];
}
std::string GDServer::getServerName() {
return Frontend::Translation::getByKey("lapi.gdserver.name");
}
std::string GDServer::getServerIdentifier() {
return "gdserver";
}
#include "Level.h"
void GDServer::destroyLevelVector(std::vector<LevelAPI::DatabaseController::Level *> v) {
for (auto l : v) {
if (l != nullptr) delete l;
}
return;
}
std::vector<std::string> GDServer::_getCloudflareBans() {
return {
"error code: 1005",
"error code: 1006",
"error code: 1007",
"error code: 1008",
"error code: 1009",
"error code: 1012",
"error code: 1106"
};
}
bool GDServer::processCURLAnswer(CURLResult *res) {
_rateLimitLength = res->retry_after;
printf("res: %d/%d\n", res->http_status, res->result);
if (res->http_status != 200 || res->result != 0) {
std::string data = res->data;
auto pban_responses = _getCloudflareBans();
for (auto reason : pban_responses) {
if (data.find(reason) != std::string::npos) {
m_eStatus = GSS_PERMANENT_BAN;
}
}
return false;
}
return true;
}
CURLConnection *GDServer::_setupCURL(std::optional<CurlProxy> proxy, std::string secret) {
auto m_pLinkedCURL = new CURLConnection();
m_pLinkedCURL->setDebug(false);
if (proxy.has_value()) {
m_pLinkedCURL->setProxy(proxy.value());
}
m_pLinkedCURL->setData({
new CURLParameter("secret", secret),
new CURLParameter("gameVersion", getGameVersion())
});
return m_pLinkedCURL;
}
// get a list of levels based on the server response
std::vector<LevelAPI::DatabaseController::Level *> GDServer::getLevelsFromResponse(std::string &response) {
return {};
}
LevelAPI::DatabaseController::Level *GDServer::downloadLevel(int id, std::optional<CurlProxy> proxy) {
return nullptr;
}