mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-06-17 14:12:25 +00:00
Sentry: report any issue with backend.beammp or auth.beammp responses
This commit is contained in:
@@ -84,7 +84,9 @@ if (UNIX)
|
|||||||
elseif (WIN32)
|
elseif (WIN32)
|
||||||
add_definitions(/DSECRET_SENTRY_URL="${BEAMMP_SECRET_SENTRY_URL}")
|
add_definitions(/DSECRET_SENTRY_URL="${BEAMMP_SECRET_SENTRY_URL}")
|
||||||
include(FindLua)
|
include(FindLua)
|
||||||
|
message(STATUS "Looking for libz")
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
|
message(STATUS "Looking for RapidJSON")
|
||||||
find_package(RapidJSON CONFIG REQUIRED)
|
find_package(RapidJSON CONFIG REQUIRED)
|
||||||
target_include_directories(BeamMP-Server PRIVATE ${RAPIDJSON_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
|
target_include_directories(BeamMP-Server PRIVATE ${RAPIDJSON_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
|
||||||
target_link_libraries(BeamMP-Server PRIVATE ws2_32 ZLIB::ZLIB ${LUA_LIBRARIES} ${OPENSSL_LIBRARIES} commandline sioclient_tls)
|
target_link_libraries(BeamMP-Server PRIVATE ws2_32 ZLIB::ZLIB ${LUA_LIBRARIES} ${OPENSSL_LIBRARIES} commandline sioclient_tls)
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ public:
|
|||||||
~TSentry();
|
~TSentry();
|
||||||
|
|
||||||
void Log(sentry_level_t level, const std::string& logger, const std::string& text);
|
void Log(sentry_level_t level, const std::string& logger, const std::string& text);
|
||||||
|
void AddExtra(const std::string& key, const sentry_value_t& value);
|
||||||
|
void AddExtra(const std::string& key, const std::string& value);
|
||||||
void LogException(const std::exception& e, const std::string& file, const std::string& line);
|
void LogException(const std::exception& e, const std::string& file, const std::string& line);
|
||||||
void AddErrorBreadcrumb(const std::string& msg, const std::string& file, const std::string& line);
|
void AddErrorBreadcrumb(const std::string& msg, const std::string& file, const std::string& line);
|
||||||
|
|
||||||
|
|||||||
+16
-1
@@ -25,7 +25,22 @@ void TSentry::Log(sentry_level_t level, const std::string& logger, const std::st
|
|||||||
if (!mValid) {
|
if (!mValid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sentry_capture_event(sentry_value_new_message_event(level, logger.c_str(), text.c_str()));
|
auto Msg = sentry_value_new_message_event(level, logger.c_str(), text.c_str());
|
||||||
|
sentry_capture_event(Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TSentry::AddExtra(const std::string& key, const sentry_value_t& value) {
|
||||||
|
if (!mValid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sentry_set_extra(key.c_str(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TSentry::AddExtra(const std::string& key, const std::string& value) {
|
||||||
|
if (!mValid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AddExtra(key.c_str(), sentry_value_new_string(value.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSentry::LogException(const std::exception& e, const std::string& file, const std::string& line) {
|
void TSentry::LogException(const std::exception& e, const std::string& file, const std::string& line) {
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ void THeartbeatThread::operator()() {
|
|||||||
if (T.substr(0, 2) != "20") {
|
if (T.substr(0, 2) != "20") {
|
||||||
warn("Backend system refused server! Server might not show in the public list");
|
warn("Backend system refused server! Server might not show in the public list");
|
||||||
debug("server returned \"" + T + "\"");
|
debug("server returned \"" + T + "\"");
|
||||||
|
if (T.size() > std::string("YOU_SHALL_NOT_PASS").size()
|
||||||
|
&& Application::Settings.Key.size() == 36) {
|
||||||
|
Sentry.AddExtra("response", T);
|
||||||
|
Sentry.AddExtra("body", Body);
|
||||||
|
Sentry.Log(SENTRY_LEVEL_ERROR, "default", "wrong backend response format");
|
||||||
|
}
|
||||||
isAuth = false;
|
isAuth = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -280,8 +280,10 @@ void TNetwork::Authentication(SOCKET TCPSock) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto RequestString = R"({"key":")" + Rc + "\"}";
|
||||||
|
|
||||||
if (!Rc.empty()) {
|
if (!Rc.empty()) {
|
||||||
Rc = Http::POST(Application::GetBackendUrlForAuth(), "/pkToUser", {}, R"({"key":")" + Rc + "\"}", true);
|
Rc = Http::POST(Application::GetBackendUrlForAuth(), "/pkToUser", {}, RequestString, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
json::Document AuthResponse;
|
json::Document AuthResponse;
|
||||||
@@ -294,6 +296,9 @@ void TNetwork::Authentication(SOCKET TCPSock) {
|
|||||||
if (!AuthResponse.IsObject()) {
|
if (!AuthResponse.IsObject()) {
|
||||||
ClientKick(*Client, "Backend returned invalid auth response format.");
|
ClientKick(*Client, "Backend returned invalid auth response format.");
|
||||||
error("Backend returned invalid auth response format. This should never happen.");
|
error("Backend returned invalid auth response format. This should never happen.");
|
||||||
|
Sentry.AddExtra("response", Rc);
|
||||||
|
Sentry.AddExtra("key", RequestString);
|
||||||
|
Sentry.Log(SENTRY_LEVEL_ERROR, "default", "wrong backend response format");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user