Application: Move some string literal URLs to functions

This commit is contained in:
Lion Kortlepel 2021-03-18 23:30:52 +01:00
parent c372e63bd1
commit e6109c98bd
4 changed files with 8 additions and 4 deletions

View File

@ -49,6 +49,10 @@ public:
static inline TSettings Settings {};
static std::string GetBackendUrlForAuth() { return "auth.beammp.com"; }
static std::string GetBackendHostname() { return "beammp.com"; }
static std::string GetBackendUrlForSocketIO() { return "https://backend.beammp.com"; }
private:
static inline std::string mPPS;
static std::unique_ptr<TConsole> mConsole;

View File

@ -27,7 +27,7 @@ SocketIO::SocketIO() noexcept
mClient.set_logs_quiet();
mClient.set_reconnect_delay(10000);
mClient.connect("https://backend.beammp.com");
mClient.connect(Application::GetBackendUrlForSocketIO());
}
SocketIO::~SocketIO() {

View File

@ -36,12 +36,12 @@ void THeartbeatThread::operator()() {
Body += "&pps=" + Application::PPS();
T = Http::POST("beammp.com", "/heartbeatv2", {}, Body, false);
T = Http::POST(Application::GetBackendHostname(), "/heartbeatv2", {}, Body, false);
if (T.substr(0, 2) != "20") {
//Backend system refused server startup!
std::this_thread::sleep_for(std::chrono::milliseconds(500));
T = Http::POST("beammp.com", "/heartbeatv2", {}, Body, false);
T = Http::POST(Application::GetBackendHostname(), "/heartbeatv2", {}, Body, false);
// TODO backup2 + HTTP flag (no TSL)
if (T.substr(0, 2) != "20") {
warn("Backend system refused server! Server might not show in the public list");

View File

@ -261,7 +261,7 @@ void TNetwork::Authentication(SOCKET TCPSock) {
}
if (!Rc.empty()) {
Rc = Http::POST("auth.beammp.com", "/pkToUser", {}, R"({"key":")" + Rc + "\"}", true);
Rc = Http::POST(Application::GetBackendUrlForAuth(), "/pkToUser", {}, R"({"key":")" + Rc + "\"}", true);
}
debug("Auth response: " + Rc);