]> git.stg.codes - stg.git/blobdiff - projects/stargazer/user_impl.cpp
Implemented IA protocol errors logging.
[stg.git] / projects / stargazer / user_impl.cpp
index 5bb0069fb6f04b79a476001e135d09ddd7a3176d..37178dd696d0bb3f77ad8776c17f7b490426fddb 100644 (file)
@@ -544,7 +544,7 @@ ScanMessage();
 return 0;
 }
 //-----------------------------------------------------------------------------
-void USER_IMPL::Unauthorize(const AUTH * auth)
+void USER_IMPL::Unauthorize(const AUTH * auth, const std::string & reason)
 {
 STG_LOCKER lock(&mutex, __FILE__, __LINE__);
 /*
@@ -555,6 +555,7 @@ if (!authorizedBy.erase(auth))
 
 if (authorizedBy.empty())
     {
+    lastDisconnectReason = reason;
     lastIPForDisconnect = currIP;
     currIP = 0; // DelUser in traffcounter
     return;
@@ -673,7 +674,12 @@ if (!fakeDisconnect)
     connected = false;
     }
 
-if (store->WriteUserDisconnect(login, up, down, sessionUpload, sessionDownload, cash, freeMb, reason))
+std::string reasonMessage(reason);
+if (!lastDisconnectReason.empty())
+    reasonMessage += ": " + lastDisconnectReason;
+
+if (store->WriteUserDisconnect(login, up, down, sessionUpload, sessionDownload,
+                               cash, freeMb, reasonMessage))
     {
     WriteServLog("Cannot write disconnect for user %s.", login.c_str());
     WriteServLog("%s", store->GetStrError().c_str());