X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/6441f493875d484d2b50712ceeeaee9f07e79b64..0cc864dabe50dc3012380bd957241d508335e1da:/projects/sgauthstress/main.cpp?ds=inline diff --git a/projects/sgauthstress/main.cpp b/projects/sgauthstress/main.cpp index 21df6d74..2388254d 100644 --- a/projects/sgauthstress/main.cpp +++ b/projects/sgauthstress/main.cpp @@ -28,6 +28,8 @@ #include #include +#include +#include #include "stg/common.h" #include "stg/store.h" @@ -98,7 +100,7 @@ SetSignalHandlers(); PROTO proto(settings.GetServerName(), settings.GetServerPort(), settings.GetLocalPort(), - 1); + 10); STORE_LOADER storeLoader(settings.GetModulesPath(), settings.GetStoreModuleSettings()); if (storeLoader.Load()) @@ -116,23 +118,38 @@ if (dataStore->GetUsersList(&userList)) return -1; } -std::vector::const_iterator it; -for (it = userList.begin(); it != userList.end(); ++it) +std::list ips; { - USER_CONF userConf; - if (dataStore->RestoreUserConf(&userConf, *it)) + std::vector::const_iterator it; + for (it = userList.begin(); it != userList.end(); ++it) { - std::cerr << "Failed to read user conf: '" << dataStore->GetStrError() << "'" << std::endl; - return -1; + 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 + ) + ); + ips.push_back(userConf.ips[0].ip); } - proto.AddUser( - USER( - *it, - userConf.password, - userConf.ips[0].ip - ), - true - ); + } + +if (!proto.Start()) + { + std::cerr << "Failed to start listening thread: '" << proto.GetStrError() << "'" << std::endl; + return -1; + } + +std::list::const_iterator it; +for (it = ips.begin(); it != ips.end(); ++it) + { + proto.Connect(*it); } std::cout << "Successfully loaded " << proto.UserCount() << " users" << std::endl; @@ -143,6 +160,8 @@ while (running) usleep(200000); } +proto.Stop(); + storeLoader.Unload(); return 0;