X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/8e80bb9cec2c90dd61f810fb1525932a434288eb..2196a3a0cdc5384c082febb7f4aa5994cc7d80db:/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h diff --git a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h index 83e4d7a5..65c15c7b 100644 --- a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h +++ b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h @@ -22,7 +22,6 @@ #include "stg/auth.h" #include "stg/store.h" #include "stg/module_settings.h" -#include "stg/notifer.h" #include "stg/user_ips.h" #include "stg/user.h" #include "stg/users.h" @@ -41,9 +40,13 @@ #include #include #include +#include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#include +#pragma GCC diagnostic pop #include -#include //#define IA_DEBUG (1) //#define IA_PHASE_DEBUG (1) @@ -116,9 +119,9 @@ struct IA_USER { protoVer(0), password("NO PASSWORD") { - unsigned char keyL[PASSWD_LEN]; + char keyL[PASSWD_LEN]; memset(keyL, 0, PASSWD_LEN); - strncpy((char *)keyL, password.c_str(), PASSWD_LEN); + strncpy(keyL, password.c_str(), PASSWD_LEN); Blowfish_Init(&ctx, keyL, PASSWD_LEN); #ifdef IA_DEBUG @@ -157,9 +160,9 @@ struct IA_USER { protoVer(ver), password(user->GetProperties().password.Get()) { - unsigned char keyL[PASSWD_LEN]; + char keyL[PASSWD_LEN]; memset(keyL, 0, PASSWD_LEN); - strncpy((char *)keyL, password.c_str(), PASSWD_LEN); + strncpy(keyL, password.c_str(), PASSWD_LEN); Blowfish_Init(&ctx, keyL, PASSWD_LEN); #ifdef IA_DEBUG @@ -209,21 +212,7 @@ private: class AUTH_IA; using UserPtr = STG::User*; //----------------------------------------------------------------------------- -class DEL_USER_NOTIFIER: public STG::NotifierBase { -public: - explicit DEL_USER_NOTIFIER(AUTH_IA & a) : auth(a) {} - virtual ~DEL_USER_NOTIFIER() {} - - void Notify(const UserPtr & user); -private: - DEL_USER_NOTIFIER(const DEL_USER_NOTIFIER & rvalue); - DEL_USER_NOTIFIER & operator=(const DEL_USER_NOTIFIER & rvalue); - - AUTH_IA & auth; -}; -//----------------------------------------------------------------------------- class AUTH_IA : public STG::Auth { -friend class DEL_USER_NOTIFIER; public: AUTH_IA(); ~AUTH_IA() override; @@ -249,8 +238,8 @@ private: AUTH_IA(const AUTH_IA & rvalue); AUTH_IA & operator=(const AUTH_IA & rvalue); - static void * Run(void *); - static void * RunTimeouter(void * d); + void Run(std::stop_token token); + void RunTimeouter(std::stop_token token); int PrepareNet(); int FinalizeNet(); void DelUser(UserPtr u); @@ -306,7 +295,7 @@ private: int Timeouter(); int SendError(uint32_t ip, uint16_t port, int protoVer, const std::string & text); - int Send(uint32_t ip, uint16_t port, const char * buffer, size_t len); + int Send(uint32_t ip, uint16_t port, const void* buffer, size_t len); int RealSendMessage6(const STG::Message & msg, uint32_t ip, IA_USER & user); int RealSendMessage7(const STG::Message & msg, uint32_t ip, IA_USER & user); int RealSendMessage8(const STG::Message & msg, uint32_t ip, IA_USER & user); @@ -317,8 +306,6 @@ private: AUTH_IA_SETTINGS iaSettings; STG::ModuleSettings settings; - bool nonstop; - bool isRunningRun; bool isRunningRunTimeouter; @@ -327,9 +314,9 @@ private: mutable std::map ip2user; - pthread_t recvThread; - pthread_t timeouterThread; - mutable pthread_mutex_t mutex; + std::jthread m_thread; + std::jthread m_timeouterThread; + mutable std::mutex m_mutex; int listenSocket; @@ -348,7 +335,7 @@ private: uint32_t enabledDirs; - DEL_USER_NOTIFIER onDelUserNotifier; + STG::ScopedConnection m_onDelUserConn; STG::PluginLogger logger; @@ -368,9 +355,3 @@ class UnauthorizeUser : std::unary_function & AUTH_IA * auth; }; -//----------------------------------------------------------------------------- -inline -void DEL_USER_NOTIFIER::Notify(const UserPtr & user) -{ - auth.DelUser(user); -}