X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/18caba20e60d31488fc27402515a811f689b0672..3cc6c36fcf3f0c6449debeb56e53c2ede03efc26:/projects/sgauthstress/main.cpp?ds=inline

diff --git a/projects/sgauthstress/main.cpp b/projects/sgauthstress/main.cpp
index 71388477..21df6d74 100644
--- a/projects/sgauthstress/main.cpp
+++ b/projects/sgauthstress/main.cpp
@@ -29,12 +29,14 @@
 #include <csignal>
 #include <iostream>
 
-#include "stg/ia.h"
 #include "stg/common.h"
 #include "stg/store.h"
+#include "stg/user_conf.h"
 
 #include "settings.h"
 #include "store_loader.h"
+#include "proto.h"
+#include "user.h"
 
 time_t stgTime;
 bool running;
@@ -47,22 +49,6 @@ void Usage()
 std::cout << "Usage:\n\nsgauth <path_to_config>" << std::endl;
 }
 //-----------------------------------------------------------------------------
-void StatUpdate(const LOADSTAT &, void *)
-{
-}
-//-----------------------------------------------------------------------------
-void StatusChanged(int, void *)
-{
-}
-//-----------------------------------------------------------------------------
-void ShowMessage(const string &, int, int, int, void *)
-{
-}
-//-----------------------------------------------------------------------------
-void ShowError(const string &, int, void *)
-{
-}
-//-----------------------------------------------------------------------------
 void CatchTERM(int)
 {
 running = false;
@@ -109,6 +95,11 @@ if (settings.ReadSettings())
 
 SetSignalHandlers();
 
+PROTO proto(settings.GetServerName(),
+            settings.GetServerPort(),
+            settings.GetLocalPort(),
+            1);
+
 STORE_LOADER storeLoader(settings.GetModulesPath(), settings.GetStoreModuleSettings());
 if (storeLoader.Load())
     {
@@ -125,21 +116,26 @@ if (dataStore->GetUsersList(&userList))
     return -1;
     }
 
-std::cout << "Successfully loaded " << userList.size() << " users" << std::endl;
-
-IA_CLIENT_PROT proto(settings.GetServerName(), settings.GetServerPort(), settings.GetLocalPort());
-
-proto.SetLogin(settings.GetLogin());
-proto.SetPassword(settings.GetPassword());
-
-proto.SetStatusChangedCb(StatusChanged, NULL);
-proto.SetInfoCb(ShowMessage, NULL);
-proto.SetErrorCb(ShowError, NULL);
-proto.SetStatChangedCb(StatUpdate, NULL);
-
-proto.Start();
+std::vector<std::string>::const_iterator it;
+for (it = userList.begin(); it != userList.end(); ++it)
+    {
+    USER_CONF userConf;
+    if (dataStore->RestoreUserConf(&userConf, *it))
+        {
+        std::cerr << "Failed to read user conf: '" << dataStore->GetStrError() << "'" << std::endl;
+        return -1;
+        }
+    proto.AddUser(
+            USER(
+                *it,
+                userConf.password,
+                userConf.ips[0].ip
+            ),
+            true
+    );
+    }
 
-proto.Connect();
+std::cout << "Successfully loaded " << proto.UserCount() << " users" << std::endl;
 
 running = true;
 while (running)
@@ -147,10 +143,6 @@ while (running)
     usleep(200000);
     }
 
-proto.Disconnect();
-
-proto.Stop();
-
 storeLoader.Unload();
 
 return 0;