From: Maxim Mamontov Date: Fri, 18 Mar 2011 14:25:23 +0000 (+0200) Subject: Rename BASE_AUTH and BASE_STORE to AUTH and STORE X-Git-Tag: 2.407-rc3~152 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/ede91934442fd804d7b818971a44e3ad795cb01f Rename BASE_AUTH and BASE_STORE to AUTH and STORE --- diff --git a/include/Makefile b/include/Makefile deleted file mode 100644 index 416f82d9..00000000 --- a/include/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# $Id: Makefile,v 1.2 2005/10/11 12:18:55 nobunaga Exp $ -############################################################################### - -#LIB_NAME = includes - -#INCS = *.h -#include ../Makefile.in - -all: - echo hi - -install: - echo install \ No newline at end of file diff --git a/include/base_settings.h b/include/base_settings.h deleted file mode 100644 index 1b9366e8..00000000 --- a/include/base_settings.h +++ /dev/null @@ -1,55 +0,0 @@ - /* - $Revision: 1.5 $ - $Date: 2010/03/04 11:49:52 $ - $Author: faust $ - */ - -#ifndef BASE_SETTINGS_H -#define BASE_SETTINGS_H - -#include -#include -#include - -using namespace std; - -//----------------------------------------------------------------------------- -struct PARAM_VALUE -{ - PARAM_VALUE() - : param(), - value() - {}; - bool operator==(const PARAM_VALUE & rhs) const - { return !strcasecmp(param.c_str(), rhs.param.c_str()); }; - - bool operator<(const PARAM_VALUE & rhs) const - { return strcasecmp(param.c_str(), rhs.param.c_str()) < 0; }; - - string param; - vector value; -}; -//----------------------------------------------------------------------------- -struct MODULE_SETTINGS -{ - MODULE_SETTINGS() - : moduleName(), - moduleParams() - {}; - MODULE_SETTINGS(const MODULE_SETTINGS & rvalue) - : moduleName(rvalue.moduleName), - moduleParams(rvalue.moduleParams) - {}; - bool operator==(const MODULE_SETTINGS & rhs) const - { return !strcasecmp(moduleName.c_str(), rhs.moduleName.c_str()); }; - - bool operator<(const MODULE_SETTINGS & rhs) const - { return strcasecmp(moduleName.c_str(), rhs.moduleName.c_str()) < 0; }; - -string moduleName; -vector moduleParams; -}; -//----------------------------------------------------------------------------- -#endif //BASE_SETTINGS_H - - diff --git a/include/base_store.h b/include/base_store.h deleted file mode 100644 index c35b49c7..00000000 --- a/include/base_store.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Author : Boris Mikhailenko - */ - - /* - $Revision: 1.16 $ - $Date: 2010/01/19 11:09:48 $ - $Author: faust $ - */ - -#ifndef BASE_STORE_H -#define BASE_STORE_H - -#include -#include -#include - -#include "user_stat.h" -#include "user_conf.h" -#include "corp_conf.h" -#include "service_conf.h" -#include "admin_conf.h" -#include "tariff_conf.h" -#include "base_settings.h" -#include "stg_message.h" - -using namespace std; -//----------------------------------------------------------------------------- -class BASE_STORE -{ -public: - virtual ~BASE_STORE(){}; - virtual int GetUsersList(vector * usersList) const = 0; - virtual int AddUser(const string & login) const = 0; - virtual int DelUser(const string & login) const = 0; - virtual int SaveUserStat(const USER_STAT & stat, const string & login) const = 0; - virtual int SaveUserConf(const USER_CONF & conf, const string & login) const = 0; - virtual int RestoreUserStat(USER_STAT * stat, const string & login) const = 0; - virtual int RestoreUserConf(USER_CONF * conf, const string & login) const = 0; - - virtual int WriteUserChgLog(const string & login, - const string & admLogin, - uint32_t admIP, - const string & paramName, - const string & oldValue, - const string & newValue, - const string & message = "") const = 0; - - virtual int WriteUserConnect(const string & login, uint32_t ip) const = 0; - - virtual int WriteUserDisconnect(const string & login, - const DIR_TRAFF & up, - const DIR_TRAFF & down, - const DIR_TRAFF & sessionUp, - const DIR_TRAFF & sessionDown, - double cash, - double freeMb, - const std::string & reason) const = 0; - - virtual int WriteDetailedStat(const map & statTree, - time_t lastStat, - const string & login) const = 0; - - virtual int AddMessage(STG_MSG * msg, const string & login) const = 0; - virtual int EditMessage(const STG_MSG & msg, const string & login) const = 0; - virtual int GetMessage(uint64_t id, STG_MSG * msg, const string & login) const = 0; - virtual int DelMessage(uint64_t id, const string & login) const = 0; - virtual int GetMessageHdrs(vector * hdrsList, const string & login) const = 0; - - - virtual int SaveMonthStat(const USER_STAT & stat, int month, int year, const string & login) const = 0; - - virtual int GetAdminsList(vector * adminsList) const = 0; - virtual int SaveAdmin(const ADMIN_CONF & ac) const = 0; - virtual int RestoreAdmin(ADMIN_CONF * ac, const string & login) const = 0; - virtual int AddAdmin(const string & login) const = 0; - virtual int DelAdmin(const string & login) const = 0; - - virtual int GetTariffsList(vector * tariffsList) const = 0; - virtual int AddTariff(const string & name) const = 0; - virtual int DelTariff(const string & name) const = 0; - virtual int SaveTariff(const TARIFF_DATA & td, const string & tariffName) const = 0; - virtual int RestoreTariff(TARIFF_DATA * td, const string & tariffName) const = 0; - - virtual int GetCorpsList(vector * corpsList) const = 0; - virtual int SaveCorp(const CORP_CONF & cc) const = 0; - virtual int RestoreCorp(CORP_CONF * cc, const string & name) const = 0; - virtual int AddCorp(const string & name) const = 0; - virtual int DelCorp(const string & name) const = 0; - - virtual int GetServicesList(vector * corpsList) const = 0; - virtual int SaveService(const SERVICE_CONF & sc) const = 0; - virtual int RestoreService(SERVICE_CONF * sc, const string & name) const = 0; - virtual int AddService(const string & name) const = 0; - virtual int DelService(const string & name) const = 0; - - virtual void SetSettings(const MODULE_SETTINGS & s) = 0; - virtual int ParseSettings() = 0; - virtual const string & GetStrError() const = 0; - virtual const string & GetVersion() const = 0; -}; -//----------------------------------------------------------------------------- - -#endif //BASE_STORE_H - diff --git a/include/module_setting.h b/include/module_setting.h new file mode 100644 index 00000000..a1baf33c --- /dev/null +++ b/include/module_setting.h @@ -0,0 +1,51 @@ + /* + $Revision: 1.5 $ + $Date: 2010/03/04 11:49:52 $ + $Author: faust $ + */ + +#ifndef MODULE_SETTINGS_H +#define MODULE_SETTINGS_H + +#include // strcasecmp +#include +#include + +//----------------------------------------------------------------------------- +struct PARAM_VALUE +{ + PARAM_VALUE() + : param(), + value() + {} + bool operator==(const PARAM_VALUE & rhs) const + { return !strcasecmp(param.c_str(), rhs.param.c_str()); } + + bool operator<(const PARAM_VALUE & rhs) const + { return strcasecmp(param.c_str(), rhs.param.c_str()) < 0; } + + std::string param; + std::vector value; +}; +//----------------------------------------------------------------------------- +struct MODULE_SETTINGS +{ + MODULE_SETTINGS() + : moduleName(), + moduleParams() + {} + MODULE_SETTINGS(const MODULE_SETTINGS & rvalue) + : moduleName(rvalue.moduleName), + moduleParams(rvalue.moduleParams) + {} + bool operator==(const MODULE_SETTINGS & rhs) const + { return !strcasecmp(moduleName.c_str(), rhs.moduleName.c_str()); } + + bool operator<(const MODULE_SETTINGS & rhs) const + { return strcasecmp(moduleName.c_str(), rhs.moduleName.c_str()) < 0; } + + std::string moduleName; + std::vector moduleParams; +}; +//----------------------------------------------------------------------------- +#endif diff --git a/include/plugin.h b/include/plugin.h index 089202ba..b474f463 100644 --- a/include/plugin.h +++ b/include/plugin.h @@ -38,18 +38,17 @@ class TRAFFCOUNTER; class SETTINGS; -class BASE_STORE; +class STORE; class MODULE_SETTINGS; -class PLUGIN : private NONCOPYABLE -{ +class PLUGIN : private NONCOPYABLE { public: virtual ~PLUGIN() = 0; virtual void SetUsers(USERS * u) = 0; virtual void SetTariffs(TARIFFS * t) = 0; virtual void SetAdmins(ADMINS * a) = 0; virtual void SetTraffcounter(TRAFFCOUNTER * tc) = 0; - virtual void SetStore(BASE_STORE * st) = 0; + virtual void SetStore(STORE * st) = 0; virtual void SetStgSettings(const SETTINGS * s) = 0; virtual void SetSettings(const MODULE_SETTINGS & s) = 0; virtual int ParseSettings() = 0; diff --git a/include/store.h b/include/store.h new file mode 100644 index 00000000..7721f31c --- /dev/null +++ b/include/store.h @@ -0,0 +1,116 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Author : Boris Mikhailenko + */ + + /* + $Revision: 1.16 $ + $Date: 2010/01/19 11:09:48 $ + $Author: faust $ + */ + +#ifndef STORE_H +#define STORE_H + +#include +#include +#include + +#include "user_stat.h" +#include "user_conf.h" +#include "corp_conf.h" +#include "service_conf.h" +#include "admin_conf.h" +#include "tariff_conf.h" +#include "settings.h" +#include "stg_message.h" + +//----------------------------------------------------------------------------- +class STORE { +public: + virtual int GetUsersList(std::vector * usersList) const = 0; + virtual int AddUser(const std::string & login) const = 0; + virtual int DelUser(const std::string & login) const = 0; + virtual int SaveUserStat(const USER_STAT & stat, const std::string & login) const = 0; + virtual int SaveUserConf(const USER_CONF & conf, const std::string & login) const = 0; + virtual int RestoreUserStat(USER_STAT * stat, const std::string & login) const = 0; + virtual int RestoreUserConf(USER_CONF * conf, const std::string & login) const = 0; + + virtual int WriteUserChgLog(const std::string & login, + const std::string & admLogin, + uint32_t admIP, + const std::string & paramName, + const std::string & oldValue, + const std::string & newValue, + const std::string & message = "") const = 0; + + virtual int WriteUserConnect(const std::string & login, uint32_t ip) const = 0; + + virtual int WriteUserDisconnect(const std::string & login, + const DIR_TRAFF & up, + const DIR_TRAFF & down, + const DIR_TRAFF & sessionUp, + const DIR_TRAFF & sessionDown, + double cash, + double freeMb, + const std::string & reason) const = 0; + + virtual int WriteDetailedStat(const TRAFF_STAT & statTree, + time_t lastStat, + const std::string & login) const = 0; + + virtual int AddMessage(STG_MSG * msg, const std::string & login) const = 0; + virtual int EditMessage(const STG_MSG & msg, const std::string & login) const = 0; + virtual int GetMessage(uint64_t id, STG_MSG * msg, const std::string & login) const = 0; + virtual int DelMessage(uint64_t id, const std::string & login) const = 0; + virtual int GetMessageHdrs(vector * hdrsList, const std::string & login) const = 0; + + virtual int SaveMonthStat(const USER_STAT & stat, int month, int year, const std::string & login) const = 0; + + virtual int GetAdminsList(std::vector * adminsList) const = 0; + virtual int SaveAdmin(const ADMIN_CONF & ac) const = 0; + virtual int RestoreAdmin(ADMIN_CONF * ac, const std::string & login) const = 0; + virtual int AddAdmin(const std::string & login) const = 0; + virtual int DelAdmin(const std::string & login) const = 0; + + virtual int GetTariffsList(std::vector * tariffsList) const = 0; + virtual int AddTariff(const std::string & name) const = 0; + virtual int DelTariff(const std::string & name) const = 0; + virtual int SaveTariff(const TARIFF_DATA & td, const std::string & tariffName) const = 0; + virtual int RestoreTariff(TARIFF_DATA * td, const std::string & tariffName) const = 0; + + virtual int GetCorpsList(std::vector * corpsList) const = 0; + virtual int SaveCorp(const CORP_CONF & cc) const = 0; + virtual int RestoreCorp(CORP_CONF * cc, const std::string & name) const = 0; + virtual int AddCorp(const std::string & name) const = 0; + virtual int DelCorp(const std::string & name) const = 0; + + virtual int GetServicesList(std::vector * corpsList) const = 0; + virtual int SaveService(const SERVICE_CONF & sc) const = 0; + virtual int RestoreService(SERVICE_CONF * sc, const std::string & name) const = 0; + virtual int AddService(const std::string & name) const = 0; + virtual int DelService(const std::string & name) const = 0; + + virtual void SetSettings(const MODULE_SETTINGS & s) = 0; + virtual int ParseSettings() = 0; + virtual const std::string & GetStrError() const = 0; + virtual const std::string & GetVersion() const = 0; +}; +//----------------------------------------------------------------------------- + +#endif diff --git a/include/user.h b/include/user.h index cac12d57..d67182b2 100644 --- a/include/user.h +++ b/include/user.h @@ -71,11 +71,10 @@ public: virtual time_t GetConnectedModificationTime() const = 0; virtual int GetAuthorized() const = 0; virtual int Authorize(uint32_t ip, - const std::string & iface, uint32_t enabledDirs, - const BASE_AUTH * auth) = 0; - virtual void Unauthorize(const BASE_AUTH * auth) = 0; - virtual bool IsAuthorizedBy(const BASE_AUTH * auth) const = 0; + const AUTH * auth) = 0; + virtual void Unauthorize(const AUTH * auth) = 0; + virtual bool IsAuthorizedBy(const AUTH * auth) const = 0; virtual int AddMessage(STG_MSG * msg) = 0; diff --git a/projects/convertor/main.cpp b/projects/convertor/main.cpp index 58ff7fbd..5985f5a6 100644 --- a/projects/convertor/main.cpp +++ b/projects/convertor/main.cpp @@ -33,7 +33,7 @@ #include #include "common.h" -#include "base_store.h" +#include "store.h" #include "settings.h" #include "conffiles.h" @@ -43,7 +43,7 @@ #include "service_conf.h" #include "admin_conf.h" #include "tariff_conf.h" -#include "base_settings.h" +#include "module_settings.h" #include "stg_message.h" using namespace std; @@ -54,8 +54,8 @@ int main(int argc, char **argv) { printfd(__FILE__, "Start\n"); -BASE_STORE * fromStore = NULL; -BASE_STORE * toStore = NULL; +STORE * fromStore = NULL; +STORE * toStore = NULL; SETTINGS * settings = NULL; @@ -112,8 +112,8 @@ if (!dst_lh) return -1; } -BASE_STORE * (*GetSourceStore)(); -BASE_STORE * (*GetDestStore)(); +STORE * (*GetSourceStore)(); +STORE * (*GetDestStore)(); GetSourceStore = (BASE_STORE * (*)())dlsym(src_lh, "GetStore"); if (!GetSourceStore) { diff --git a/projects/stargazer/Makefile b/projects/stargazer/Makefile index 2b3bf3fb..29d61b1a 100644 --- a/projects/stargazer/Makefile +++ b/projects/stargazer/Makefile @@ -6,17 +6,17 @@ include ../../Makefile.conf PROG = stargazer -SRCS = ./admin.cpp \ - ./admins.cpp \ +SRCS = ./admin_impl.cpp \ + ./admins_impl.cpp \ ./main.cpp \ ./settings.cpp \ ./stg_timer.cpp \ - ./tariff.cpp \ - ./tariffs.cpp \ + ./tariff_impl.cpp \ + ./tariffs_impl.cpp \ ./traffcounter.cpp \ - ./user.cpp \ + ./user_impl.cpp \ ./user_property.cpp \ - ./users.cpp \ + ./users_impl.cpp \ ./plugin_runner.cpp \ ./store_loader.cpp \ ./pidfile.cpp \ @@ -142,7 +142,7 @@ endif endif endif -deps: $(SRCS) ../../Makefile.conf +deps: $(SRCS) ../../Makefile.conf $(MAKE) -C $(DIR_LIBSRC) includes @>deps ;\ for file in $(SRCS); do\ diff --git a/projects/stargazer/admins_impl.h b/projects/stargazer/admins_impl.h index 8318fc21..c40f2659 100644 --- a/projects/stargazer/admins_impl.h +++ b/projects/stargazer/admins_impl.h @@ -32,6 +32,7 @@ #define ADMINS_IMPL_H #include + #include #include @@ -39,26 +40,26 @@ #include "admin.h" #include "admin_impl.h" #include "stg_locker.h" -#include "base_store.h" +#include "store.h" #include "noncopyable.h" class ADMINS_IMPL : private NONCOPYABLE, public ADMINS { public: - ADMINS_IMPL(BASE_STORE * st); - virtual ~ADMINS_IMPL() {}; + ADMINS_IMPL(STORE * st); + virtual ~ADMINS_IMPL() {} int Add(const string & login, const ADMIN & admin); int Del(const string & login, const ADMIN & admin); int Change(const ADMIN_CONF & ac, const ADMIN & admin); void PrintAdmins() const; - const ADMIN * GetSysAdmin() const { return &stg; }; - const ADMIN * GetNoAdmin() const { return &noAdmin; }; + const ADMIN * GetSysAdmin() const { return &stg; } + const ADMIN * GetNoAdmin() const { return &noAdmin; } bool FindAdmin(const std::string & l, ADMIN ** admin); bool AdminExists(const std::string & login) const; bool AdminCorrect(const std::string & login, const std::string & password, ADMIN * admin) const; - const std::string & GetStrError() const { return strError; }; + const std::string & GetStrError() const { return strError; } int OpenSearch() const; int SearchNext(int, ADMIN_CONF * ac) const; @@ -73,11 +74,12 @@ private: ADMIN_IMPL stg; ADMIN_IMPL noAdmin; list data; - BASE_STORE * store; - STG_LOGGER & WriteServLog; + STORE * store; + STG_LOGGER & WriteServLog; mutable map searchDescriptors; mutable unsigned int handle; mutable pthread_mutex_t mutex; - std::string strError; + std::string strError; }; + #endif diff --git a/projects/stargazer/main.cpp b/projects/stargazer/main.cpp index aa8bdef5..12fa7383 100644 --- a/projects/stargazer/main.cpp +++ b/projects/stargazer/main.cpp @@ -46,8 +46,9 @@ #include "settings.h" #include "user.h" -#include "users.h" -#include "admins.h" +#include "users_impl.h" +#include "admins_impl.h" +#include "tariffs_impl.h" #include "common.h" #include "traffcounter.h" #include "base_plugin.h" @@ -549,9 +550,9 @@ if (loop.Start()) dataStore = storeLoader.GetStore(); WriteServLog("Storage plugin: %s. Loading successfull.", dataStore->GetVersion().c_str()); -tariffs = new TARIFFS(dataStore); -admins = new ADMINS(dataStore); -users = new USERS(settings, dataStore, tariffs, admins->GetSysAdmin()); +tariffs = new TARIFFS_IMPL(dataStore); +admins = new ADMINS_IMPL(dataStore); +users = new USERS_IMPL(settings, dataStore, tariffs, *admins->GetSysAdmin()); traffCnt = new TRAFFCOUNTER(users, tariffs, settings->GetRulesFileName()); traffCnt->SetMonitorDir(settings->GetMonitorDir()); diff --git a/projects/stargazer/plugin_runner.cpp b/projects/stargazer/plugin_runner.cpp index 180713c0..335d790e 100644 --- a/projects/stargazer/plugin_runner.cpp +++ b/projects/stargazer/plugin_runner.cpp @@ -33,7 +33,7 @@ #include "conffiles.h" //----------------------------------------------------------------------------- -PLUGIN_RUNNER::PLUGIN_RUNNER(const string & pFileName, +PLUGIN_RUNNER::PLUGIN_RUNNER(const std::string & pFileName, const MODULE_SETTINGS & ms, ADMINS * a, TARIFFS * t, @@ -106,7 +106,7 @@ if (isPluginLoaded) isPluginLoaded = 0; } //----------------------------------------------------------------------------- -BASE_PLUGIN * PLUGIN_RUNNER::GetPlugin() +PLUGIN * PLUGIN_RUNNER::GetPlugin() { return plugin; } @@ -168,16 +168,16 @@ libHandle = dlopen(pluginFileName.c_str(), RTLD_NOW); if (!libHandle) { - errorStr = string("Plugin loading failed. ") + dlerror(); + errorStr = std::string("Plugin loading failed. ") + dlerror(); printfd(__FILE__, "%s\n", errorStr.c_str()); return -1; } -BASE_PLUGIN * (*GetPlugin)(); -GetPlugin = (BASE_PLUGIN * (*)())dlsym(libHandle, "GetPlugin"); +PLUGIN * (*GetPlugin)(); +GetPlugin = (PLUGIN * (*)())dlsym(libHandle, "GetPlugin"); if (!GetPlugin) { - errorStr = string("GetPlugin() not found. ") + dlerror(); + errorStr = std::string("GetPlugin() not found. ") + dlerror(); return -1; } plugin = GetPlugin(); @@ -216,7 +216,7 @@ if (isPluginLoaded) return 0; } //----------------------------------------------------------------------------- -const string & PLUGIN_RUNNER::GetStrError() const +const std::string & PLUGIN_RUNNER::GetStrError() const { return errorStr; } @@ -231,4 +231,3 @@ uint16_t PLUGIN_RUNNER::GetStopPosition() const return plugin->GetStopPosition(); } //----------------------------------------------------------------------------- - diff --git a/projects/stargazer/plugin_runner.h b/projects/stargazer/plugin_runner.h index 2889300d..95ddd680 100644 --- a/projects/stargazer/plugin_runner.h +++ b/projects/stargazer/plugin_runner.h @@ -26,28 +26,28 @@ #ifndef PLUGIN_RUNNER_H #define PLUGIN_RUNNER_H + #include + #include -#include "base_plugin.h" -#include "base_settings.h" +#include "plugin.h" +#include "module_settings.h" #include "traffcounter.h" #include "tariffs.h" #include "admins.h" #include "users.h" -using namespace std; //----------------------------------------------------------------------------- -class PLUGIN_RUNNER -{ +class PLUGIN_RUNNER { public: - PLUGIN_RUNNER(const string & pluginFileName, + PLUGIN_RUNNER(const std::string & pluginFileName, const MODULE_SETTINGS & ms, ADMINS * admins, TARIFFS * tariffs, USERS * users, TRAFFCOUNTER * tc, - BASE_STORE * store, + STORE * store, const SETTINGS * s); PLUGIN_RUNNER(const PLUGIN_RUNNER & rvalue); ~PLUGIN_RUNNER(); @@ -60,9 +60,9 @@ public: int Restart(); bool IsRunning(); - const string & GetStrError() const; - BASE_PLUGIN * GetPlugin(); - const string & GetFileName() const { return pluginFileName; }; + const std::string & GetStrError() const; + PLUGIN * GetPlugin(); + const std::string & GetFileName() const { return pluginFileName; } int Load(); int Unload(); @@ -71,12 +71,12 @@ public: uint16_t GetStopPosition() const; private: - string pluginFileName; - string pluginSettingFileName; + std::string pluginFileName; + std::string pluginSettingFileName; - BASE_PLUGIN * plugin; + PLUGIN * plugin; int isPluginLoaded; - string errorStr; + std::string errorStr; void * libHandle; bool isRunning; @@ -84,12 +84,10 @@ private: ADMINS * admins; TARIFFS * tariffs; USERS * users; - BASE_STORE * store; + STORE * store; TRAFFCOUNTER * traffCnt; const SETTINGS * stgSettings; MODULE_SETTINGS modSettings; }; //----------------------------------------------------------------------------- #endif //PLUGIN_RUNNER_H - - diff --git a/projects/stargazer/plugins/authorization/ao/ao.cpp b/projects/stargazer/plugins/authorization/ao/ao.cpp index 1690611b..cb7fe2d3 100644 --- a/projects/stargazer/plugins/authorization/ao/ao.cpp +++ b/projects/stargazer/plugins/authorization/ao/ao.cpp @@ -29,7 +29,9 @@ $Author: faust $ #include #include "ao.h" -#include "../../../user.h" +#include "user.h" +#include "users.h" +#include "../../../user_property.h" #include "../../../eventloop.h" class AO_CREATOR @@ -61,10 +63,10 @@ AO_CREATOR aoc; //----------------------------------------------------------------------------- // ëÌÁÓÓ ÄÌÑ ÐÏÉÓËÁ ÀÚÅÒÁ × ÓÐÉÓËÅ ÎÏÔÉÆÉËÁÔÏÒÏ× template -class IS_CONTAINS_USER: public binary_function +class IS_CONTAINS_USER: public binary_function { public: - bool operator()(varType notifier, user_iter user) const + bool operator()(varType notifier, USER_PTR user) const { return notifier.GetUser() == user; }; @@ -72,7 +74,7 @@ public: //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return aoc.GetPlugin(); } @@ -116,7 +118,7 @@ int AUTH_AO::Start() { GetUsers(); -list::iterator users_iter; +list::iterator users_iter; /*onAddUserNotifier.SetAuthorizator(this); onDelUserNotifier.SetAuthorizator(this);*/ @@ -141,7 +143,7 @@ if (!isRunning) users->DelNotifierUserAdd(&onAddUserNotifier); users->DelNotifierUserDel(&onDelUserNotifier); -list::iterator users_iter; +list::iterator users_iter; users_iter = usersList.begin(); while (users_iter != usersList.end()) { @@ -168,7 +170,7 @@ uint16_t AUTH_AO::GetStopPosition() const return 70; } //----------------------------------------------------------------------------- -void AUTH_AO::SetUserNotifiers(user_iter u) +void AUTH_AO::SetUserNotifiers(USER_PTR u) { // ---------- AlwaysOnline ------------------- CHG_BEFORE_NOTIFIER BeforeChgAONotifier(*this, u); @@ -182,8 +184,8 @@ BeforeChgAONotifierList.push_front(BeforeChgAONotifier); AfterChgAONotifier.SetUser(u);*/ AfterChgAONotifierList.push_front(AfterChgAONotifier); -u->property.alwaysOnline.AddBeforeNotifier(&(*BeforeChgAONotifierList.begin())); -u->property.alwaysOnline.AddAfterNotifier(&(*AfterChgAONotifierList.begin())); +u->GetProperty().alwaysOnline.AddBeforeNotifier(&(*BeforeChgAONotifierList.begin())); +u->GetProperty().alwaysOnline.AddAfterNotifier(&(*AfterChgAONotifierList.begin())); // ---------- AlwaysOnline end --------------- // ---------- IP ------------------- @@ -198,12 +200,12 @@ BeforeChgIPNotifierList.push_front(BeforeChgIPNotifier); AfterChgIPNotifier.SetUser(u);*/ AfterChgIPNotifierList.push_front(AfterChgIPNotifier); -u->property.ips.AddBeforeNotifier(&(*BeforeChgIPNotifierList.begin())); -u->property.ips.AddAfterNotifier(&(*AfterChgIPNotifierList.begin())); +u->GetProperty().ips.AddBeforeNotifier(&(*BeforeChgIPNotifierList.begin())); +u->GetProperty().ips.AddAfterNotifier(&(*AfterChgIPNotifierList.begin())); // ---------- IP end --------------- } //----------------------------------------------------------------------------- -void AUTH_AO::UnSetUserNotifiers(user_iter u) +void AUTH_AO::UnSetUserNotifiers(USER_PTR u) { // --- AlwaysOnline --- IS_CONTAINS_USER > IsContainsUserAOB; @@ -218,7 +220,7 @@ aoBIter = find_if(BeforeChgAONotifierList.begin(), if (aoBIter != BeforeChgAONotifierList.end()) { - aoBIter->GetUser()->property.alwaysOnline.DelBeforeNotifier(&(*aoBIter)); + aoBIter->GetUser()->GetProperty().alwaysOnline.DelBeforeNotifier(&(*aoBIter)); BeforeChgAONotifierList.erase(aoBIter); } @@ -228,7 +230,7 @@ aoAIter = find_if(AfterChgAONotifierList.begin(), if (aoAIter != AfterChgAONotifierList.end()) { - aoAIter->GetUser()->property.alwaysOnline.DelAfterNotifier(&(*aoAIter)); + aoAIter->GetUser()->GetProperty().alwaysOnline.DelAfterNotifier(&(*aoAIter)); AfterChgAONotifierList.erase(aoAIter); } // --- AlwaysOnline end --- @@ -246,7 +248,7 @@ ipBIter = find_if(BeforeChgIPNotifierList.begin(), if (ipBIter != BeforeChgIPNotifierList.end()) { - ipBIter->GetUser()->property.ips.DelBeforeNotifier(&(*ipBIter)); + ipBIter->GetUser()->GetProperty().ips.DelBeforeNotifier(&(*ipBIter)); BeforeChgIPNotifierList.erase(ipBIter); } @@ -256,7 +258,7 @@ ipAIter = find_if(AfterChgIPNotifierList.begin(), if (ipAIter != AfterChgIPNotifierList.end()) { - ipAIter->GetUser()->property.ips.DelAfterNotifier(&(*ipAIter)); + ipAIter->GetUser()->GetProperty().ips.DelAfterNotifier(&(*ipAIter)); AfterChgIPNotifierList.erase(ipAIter); } // --- IP end --- @@ -264,7 +266,7 @@ if (ipAIter != AfterChgIPNotifierList.end()) //----------------------------------------------------------------------------- void AUTH_AO::GetUsers() { -user_iter u; +USER_PTR u; int h = users->OpenSearch(); if (!h) { @@ -285,16 +287,16 @@ while (1) users->CloseSearch(h); } //----------------------------------------------------------------------------- -void AUTH_AO::Unauthorize(user_iter u) const +void AUTH_AO::Unauthorize(USER_PTR u) const { u->Unauthorize(this); } //----------------------------------------------------------------------------- -void AUTH_AO::UpdateUserAuthorization(user_iter u) const +void AUTH_AO::UpdateUserAuthorization(USER_PTR u) const { -if (u->property.alwaysOnline) +if (u->GetProperty().alwaysOnline) { - USER_IPS ips = u->property.ips; + USER_IPS ips = u->GetProperty().ips; if (ips.OnlyOneIP()) { if (u->Authorize(ips[0].ip, "", 0xFFffFFff, this) == 0) @@ -304,19 +306,19 @@ if (u->property.alwaysOnline) } } //----------------------------------------------------------------------------- -void AUTH_AO::AddUser(user_iter u) +void AUTH_AO::AddUser(USER_PTR u) { SetUserNotifiers(u); usersList.push_back(u); UpdateUserAuthorization(u); } //----------------------------------------------------------------------------- -void AUTH_AO::DelUser(user_iter u) +void AUTH_AO::DelUser(USER_PTR u) { Unauthorize(u); UnSetUserNotifiers(u); -list::iterator users_iter; +list::iterator users_iter; users_iter = usersList.begin(); while (users_iter != usersList.end()) @@ -348,4 +350,3 @@ void CHG_AFTER_NOTIFIER::Notify(const varParamType &, const varPar EVENT_LOOP_SINGLETON::GetInstance().Enqueue(auth, &AUTH_AO::UpdateUserAuthorization, user); } //----------------------------------------------------------------------------- - diff --git a/projects/stargazer/plugins/authorization/ao/ao.h b/projects/stargazer/plugins/authorization/ao/ao.h index 2a9ff3e0..4c0c344a 100644 --- a/projects/stargazer/plugins/authorization/ao/ao.h +++ b/projects/stargazer/plugins/authorization/ao/ao.h @@ -27,98 +27,92 @@ #ifndef AO_H #define AO_H -#include #include -#include "base_auth.h" -#include "base_store.h" + +#include +#include + +#include "auth.h" +#include "store.h" #include "notifer.h" #include "user_ips.h" -#include "../../../users.h" +#include "user.h" -using namespace std; - -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); class AUTH_AO; +class USERS; //----------------------------------------------------------------------------- template -class CHG_BEFORE_NOTIFIER: public PROPERTY_NOTIFIER_BASE -{ +class CHG_BEFORE_NOTIFIER: public PROPERTY_NOTIFIER_BASE { public: - CHG_BEFORE_NOTIFIER(AUTH_AO & a, user_iter u) : user(u), auth(a) {} + CHG_BEFORE_NOTIFIER(AUTH_AO & a, USER_PTR u) : user(u), auth(a) {} void Notify(const varParamType & oldValue, const varParamType & newValue); - //void SetUser(user_iter u) { user = u; } - user_iter GetUser() {return user; } - //void SetAuthorizator(const AUTH_AO * a) { auth = a; } + USER_PTR GetUser() const { return user; } private: - user_iter user; + USER_PTR user; const AUTH_AO & auth; }; //----------------------------------------------------------------------------- template -class CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE -{ +class CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE { public: - CHG_AFTER_NOTIFIER(AUTH_AO & a, user_iter u) : user(u), auth(a) {} + CHG_AFTER_NOTIFIER(AUTH_AO & a, USER_PTR u) : user(u), auth(a) {} void Notify(const varParamType & oldValue, const varParamType & newValue); - //void SetUser(user_iter u) { user = u; } - user_iter GetUser() {return user; } - //void SetAuthorizator(const AUTH_AO * a) { auth = a; } + USER_PTR GetUser() const { return user; } private: - user_iter user; + USER_PTR user; const AUTH_AO & auth; }; //----------------------------------------------------------------------------- -class AUTH_AO_SETTINGS -{ +class AUTH_AO_SETTINGS { public: - const string& GetStrError() const { static string s; return s; } + const std::string & GetStrError() const { static std::string s; return s; } int ParseSettings(const MODULE_SETTINGS &) { return 0; } }; //----------------------------------------------------------------------------- -class AUTH_AO :public BASE_AUTH -{ +class AUTH_AO :public AUTH { public: AUTH_AO(); virtual ~AUTH_AO(){}; void SetUsers(USERS * u); - void SetTariffs(TARIFFS *){}; - void SetAdmins(ADMINS *){}; - void SetTraffcounter(TRAFFCOUNTER *){}; - void SetStore(BASE_STORE *){}; - void SetStgSettings(const SETTINGS *){}; + void SetTariffs(TARIFFS *) {} + void SetAdmins(ADMINS *) {} + void SetTraffcounter(TRAFFCOUNTER *) {} + void SetStore(STORE *) {} + void SetStgSettings(const SETTINGS *) {} int Start(); int Stop(); - int Reload() { return 0; }; + int Reload() { return 0; } bool IsRunning(); void SetSettings(const MODULE_SETTINGS & s); int ParseSettings(); - const string & GetStrError() const; - const string GetVersion() const; + const std::string & GetStrError() const; + const std::string GetVersion() const; uint16_t GetStartPosition() const; uint16_t GetStopPosition() const; - void AddUser(user_iter u); - void DelUser(user_iter u); + void AddUser(USER_PTR u); + void DelUser(USER_PTR u); - void UpdateUserAuthorization(user_iter u) const; - void Unauthorize(user_iter u) const; + void UpdateUserAuthorization(USER_PTR u) const; + void Unauthorize(USER_PTR u) const; int SendMessage(const STG_MSG & msg, uint32_t ip) const; private: void GetUsers(); - void SetUserNotifiers(user_iter u); - void UnSetUserNotifiers(user_iter u); + void SetUserNotifiers(USER_PTR u); + void UnSetUserNotifiers(USER_PTR u); - mutable string errorStr; + mutable std::string errorStr; AUTH_AO_SETTINGS aoSettings; - USERS * users; - list usersList; + USERS * users; + std::list usersList; bool isRunning; MODULE_SETTINGS settings; @@ -135,14 +129,12 @@ private: list > BeforeChgIPNotifierList; list > AfterChgIPNotifierList; - class ADD_USER_NONIFIER: public NOTIFIER_BASE - { + class ADD_USER_NONIFIER: public NOTIFIER_BASE { public: - ADD_USER_NONIFIER(AUTH_AO & a) : auth(a) {}; - virtual ~ADD_USER_NONIFIER(){}; + ADD_USER_NONIFIER(AUTH_AO & a) : auth(a) {} + virtual ~ADD_USER_NONIFIER() {} - //void SetAuthorizator(AUTH_AO * a) { auth = a; } - void Notify(const user_iter & user) + void Notify(const USER_PTR & user) { auth.AddUser(user); } @@ -151,14 +143,12 @@ private: AUTH_AO & auth; } onAddUserNotifier; - class DEL_USER_NONIFIER: public NOTIFIER_BASE - { + class DEL_USER_NONIFIER: public NOTIFIER_BASE { public: - DEL_USER_NONIFIER(AUTH_AO & a) : auth(a) {}; - virtual ~DEL_USER_NONIFIER(){}; + DEL_USER_NONIFIER(AUTH_AO & a) : auth(a) {} + virtual ~DEL_USER_NONIFIER() {} - //void SetAuthorizator(AUTH_AO * a) { auth = a; } - void Notify(const user_iter & user) + void Notify(const USER_PTR & user) { auth.DelUser(user); } @@ -171,5 +161,3 @@ private: //----------------------------------------------------------------------------- #endif - - diff --git a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp index 47ff002d..3918f0b3 100644 --- a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp +++ b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp @@ -39,6 +39,10 @@ #include "inetaccess.h" #include "common.h" +#include "stg_locker.h" +#include "tariff.h" +#include "../../../settings.h" +#include "../../../user_property.h" extern volatile const time_t stgTime; @@ -74,7 +78,7 @@ IA_CREATOR iac; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return iac.GetPlugin(); } @@ -642,7 +646,7 @@ Decrypt(&ctxS, login, buffer + 8, PASSWD_LEN / 8); uint32_t sip = *((uint32_t*)&outerAddr.sin_addr); uint16_t sport = htons(outerAddr.sin_port); -user_iter user; +USER_PTR user; if (users->FindByName(login, &user) == 0) { printfd(__FILE__, "User %s FOUND!\n", user->GetLogin().c_str()); @@ -769,7 +773,7 @@ while (it != ip2user.end()) return 0; } //----------------------------------------------------------------------------- -int AUTH_IA::PacketProcessor(char * buff, int dataLen, uint32_t sip, uint16_t sport, int protoVer, user_iter * user) +int AUTH_IA::PacketProcessor(char * buff, int dataLen, uint32_t sip, uint16_t sport, int protoVer, USER_PTR * user) { STG_LOCKER lock(&mutex, __FILE__, __LINE__); // ôÕÔ ÓÏÂÒÁÎÙ ÏÂÒÁÂÏÔÞÉËÉ ÒÁÚÎÙÈ ÐÁËÅÔÏ× @@ -816,10 +820,10 @@ iaUser = &(it->second); if (iaUser->port != sport) iaUser->port = sport; -if (iaUser->password != (*user)->property.password.Get()) +if (iaUser->password != (*user)->GetProperty().password.Get()) { - InitEncrypt(&iaUser->ctx, (*user)->property.password.Get()); - iaUser->password = (*user)->property.password.Get(); + InitEncrypt(&iaUser->ctx, (*user)->GetProperty().password.Get()); + iaUser->password = (*user)->GetProperty().password.Get(); } buff += offset; @@ -843,13 +847,13 @@ else pn = pi->second; } -if ((*user)->property.disabled.Get()) +if ((*user)->GetProperty().disabled.Get()) { SendError(sip, sport, protoVer, "õÞÅÔÎÁÑ ÚÁÐÉÓØ ÚÁÂÌÏËÉÒÏ×ÁÎÁ"); return 0; } -if ((*user)->property.passive.Get()) +if ((*user)->GetProperty().passive.Get()) { SendError(sip, sport, protoVer, "õÞÅÔÎÁÑ ÚÁÐÉÓØ ÚÁÍÏÒÏÖÅÎÁ"); return 0; @@ -863,7 +867,7 @@ if ((*user)->GetAuthorized() && (*user)->GetCurrIP() != sip) return 0; } -user_iter u; +USER_PTR u; if (users->FindByIPIdx(sip, &u) == 0 && u->GetLogin() != (*user)->GetLogin()) { printfd(__FILE__, "IP address alredy in use. IP \'%s\'", inet_ntostring(sip).c_str()); @@ -873,7 +877,7 @@ if (users->FindByIPIdx(sip, &u) == 0 && u->GetLogin() != (*user)->GetLogin()) } // ôÅÐÅÒØ ÍÙ ÄÏÌÖÎÙ ÐÒÏ×ÅÒÉÔØ, ÍÏÖÅÔ ÌÉ ÐÏÌØÚÏ×ÁÔÅÌØ ÐÏÄËÌÀÞÉÔÓÑ Ó ÜÔÏÇÏ ÁÄÒÅÓÁ. -int ipFound = (*user)->property.ips.Get().IsIPInIPS(sip); +int ipFound = (*user)->GetProperty().ips.Get().IsIPInIPS(sip); if (!ipFound) { printfd(__FILE__, "User %s. IP address is incorrect. IP \'%s\'\n", (*user)->GetLogin().c_str(), inet_ntostring(sip).c_str()); @@ -891,15 +895,15 @@ switch (pn) { case 6: connSyn6 = (CONN_SYN_6*)(buff - offset); - ret = Process_CONN_SYN_6(connSyn6, &(it->second), user, sip); + ret = Process_CONN_SYN_6(connSyn6, &(it->second), sip); break; case 7: connSyn7 = (CONN_SYN_7*)(buff - offset); - ret = Process_CONN_SYN_7(connSyn7, &(it->second), user, sip); + ret = Process_CONN_SYN_7(connSyn7, &(it->second), sip); break; case 8: connSyn8 = (CONN_SYN_8*)(buff - offset); - ret = Process_CONN_SYN_8(connSyn8, &(it->second), user, sip); + ret = Process_CONN_SYN_8(connSyn8, &(it->second), sip); break; } @@ -910,13 +914,13 @@ switch (pn) switch (protoVer) { case 6: - Send_CONN_SYN_ACK_6(iaUser, user, sip); + Send_CONN_SYN_ACK_6(iaUser, sip); break; case 7: - Send_CONN_SYN_ACK_7(iaUser, user, sip); + Send_CONN_SYN_ACK_7(iaUser, sip); break; case 8: - Send_CONN_SYN_ACK_8(iaUser, user, sip); + Send_CONN_SYN_ACK_8(iaUser, sip); break; } break; @@ -926,13 +930,13 @@ switch (pn) switch (protoVer) { case 6: - ret = Process_CONN_ACK_6(connAck, iaUser, user, sip); + ret = Process_CONN_ACK_6(connAck, iaUser, sip); break; case 7: - ret = Process_CONN_ACK_7(connAck, iaUser, user, sip); + ret = Process_CONN_ACK_7(connAck, iaUser, sip); break; case 8: - ret = Process_CONN_ACK_8((CONN_ACK_8*)(buff - offset), iaUser, user, sip); + ret = Process_CONN_ACK_8((CONN_ACK_8*)(buff - offset), iaUser, sip); break; } @@ -963,13 +967,13 @@ switch (pn) switch (protoVer) { case 6: - ret = Process_ALIVE_ACK_6(aliveAck, iaUser, user, sip); + ret = Process_ALIVE_ACK_6(aliveAck, iaUser, sip); break; case 7: - ret = Process_ALIVE_ACK_7(aliveAck, iaUser, user, sip); + ret = Process_ALIVE_ACK_7(aliveAck, iaUser, sip); break; case 8: - ret = Process_ALIVE_ACK_8((ALIVE_ACK_8*)(buff - offset), iaUser, user, sip); + ret = Process_ALIVE_ACK_8((ALIVE_ACK_8*)(buff - offset), iaUser, sip); break; } break; @@ -981,13 +985,13 @@ switch (pn) switch (protoVer) { case 6: - ret = Process_DISCONN_SYN_6(disconnSyn, iaUser, user, sip); + ret = Process_DISCONN_SYN_6(disconnSyn, iaUser, sip); break; case 7: - ret = Process_DISCONN_SYN_7(disconnSyn, iaUser, user, sip); + ret = Process_DISCONN_SYN_7(disconnSyn, iaUser, sip); break; case 8: - ret = Process_DISCONN_SYN_8((DISCONN_SYN_8*)(buff - offset), iaUser, user, sip); + ret = Process_DISCONN_SYN_8((DISCONN_SYN_8*)(buff - offset), iaUser, sip); break; } @@ -1014,13 +1018,13 @@ switch (pn) switch (protoVer) { case 6: - ret = Process_DISCONN_ACK_6(disconnAck, iaUser, user, sip, it); + ret = Process_DISCONN_ACK_6(disconnAck, iaUser, sip, it); break; case 7: - ret = Process_DISCONN_ACK_7(disconnAck, iaUser, user, sip, it); + ret = Process_DISCONN_ACK_7(disconnAck, iaUser, sip, it); break; case 8: - ret = Process_DISCONN_ACK_8((DISCONN_ACK_8*)(buff - offset), iaUser, user, sip, it); + ret = Process_DISCONN_ACK_8((DISCONN_ACK_8*)(buff - offset), iaUser, sip, it); break; } @@ -1042,7 +1046,7 @@ switch (pn) return 0; } //----------------------------------------------------------------------------- -void AUTH_IA::DelUser(user_iter u) +void AUTH_IA::DelUser(USER_PTR u) { STG_LOCKER lock(&mutex, __FILE__, __LINE__); @@ -1249,7 +1253,7 @@ Send(ip, user.port, buffer, len); return 0; } //----------------------------------------------------------------------------- -int AUTH_IA::Process_CONN_SYN_6(CONN_SYN_6 *, IA_USER * iaUser, user_iter *, uint32_t) +int AUTH_IA::Process_CONN_SYN_6(CONN_SYN_6 *, IA_USER * iaUser, uint32_t) { if (!(iaUser->phase.GetPhase() == 1 || iaUser->phase.GetPhase() == 3)) return -1; @@ -1261,22 +1265,22 @@ printfd(__FILE__, "Phase changed from %d to 2. Reason: CONN_SYN_6\n", iaUser->ph return 0; } //----------------------------------------------------------------------------- -int AUTH_IA::Process_CONN_SYN_7(CONN_SYN_7 * connSyn, IA_USER * iaUser, user_iter * user, uint32_t sip) +int AUTH_IA::Process_CONN_SYN_7(CONN_SYN_7 * connSyn, IA_USER * iaUser, uint32_t sip) { -return Process_CONN_SYN_6(connSyn, iaUser, user, sip); +return Process_CONN_SYN_6(connSyn, iaUser, sip); } //----------------------------------------------------------------------------- -int AUTH_IA::Process_CONN_SYN_8(CONN_SYN_8 * connSyn, IA_USER * iaUser, user_iter * user, uint32_t sip) +int AUTH_IA::Process_CONN_SYN_8(CONN_SYN_8 * connSyn, IA_USER * iaUser, uint32_t sip) { #ifdef ARCH_BE SwapBytes(connSyn->dirs); #endif -int ret = Process_CONN_SYN_6((CONN_SYN_6*)connSyn, iaUser, user, sip); +int ret = Process_CONN_SYN_6((CONN_SYN_6*)connSyn, iaUser, sip); enabledDirs = connSyn->dirs; return ret; } //----------------------------------------------------------------------------- -int AUTH_IA::Process_CONN_ACK_6(CONN_ACK_6 * connAck, IA_USER * iaUser, user_iter *, uint32_t sip) +int AUTH_IA::Process_CONN_ACK_6(CONN_ACK_6 * connAck, IA_USER * iaUser, uint32_t sip) { #ifdef ARCH_BE SwapBytes(connAck->len); @@ -1307,12 +1311,12 @@ printfd(__FILE__, "Invalid phase or control number. Phase: %d. Control number: % return -1; } //----------------------------------------------------------------------------- -int AUTH_IA::Process_CONN_ACK_7(CONN_ACK_7 * connAck, IA_USER * iaUser, user_iter * user, uint32_t sip) +int AUTH_IA::Process_CONN_ACK_7(CONN_ACK_7 * connAck, IA_USER * iaUser, uint32_t sip) { -return Process_CONN_ACK_6(connAck, iaUser, user, sip); +return Process_CONN_ACK_6(connAck, iaUser, sip); } //----------------------------------------------------------------------------- -int AUTH_IA::Process_CONN_ACK_8(CONN_ACK_8 * connAck, IA_USER * iaUser, user_iter *, uint32_t sip) +int AUTH_IA::Process_CONN_ACK_8(CONN_ACK_8 * connAck, IA_USER * iaUser, uint32_t sip) { #ifdef ARCH_BE SwapBytes(connAck->len); @@ -1342,7 +1346,7 @@ printfd(__FILE__, "Invalid phase or control number. Phase: %d. Control number: % return -1; } //----------------------------------------------------------------------------- -int AUTH_IA::Process_ALIVE_ACK_6(ALIVE_ACK_6 * aliveAck, IA_USER * iaUser, user_iter *, uint32_t) +int AUTH_IA::Process_ALIVE_ACK_6(ALIVE_ACK_6 * aliveAck, IA_USER * iaUser, uint32_t) { #ifdef ARCH_BE SwapBytes(aliveAck->len); @@ -1359,12 +1363,12 @@ if ((iaUser->phase.GetPhase() == 3) && (aliveAck->rnd == iaUser->rnd + 1)) return 0; } //----------------------------------------------------------------------------- -int AUTH_IA::Process_ALIVE_ACK_7(ALIVE_ACK_7 * aliveAck, IA_USER * iaUser, user_iter * user, uint32_t sip) +int AUTH_IA::Process_ALIVE_ACK_7(ALIVE_ACK_7 * aliveAck, IA_USER * iaUser, uint32_t sip) { -return Process_ALIVE_ACK_6(aliveAck, iaUser, user, sip); +return Process_ALIVE_ACK_6(aliveAck, iaUser, sip); } //----------------------------------------------------------------------------- -int AUTH_IA::Process_ALIVE_ACK_8(ALIVE_ACK_8 * aliveAck, IA_USER * iaUser, user_iter *, uint32_t) +int AUTH_IA::Process_ALIVE_ACK_8(ALIVE_ACK_8 * aliveAck, IA_USER * iaUser, uint32_t) { #ifdef ARCH_BE SwapBytes(aliveAck->len); @@ -1381,7 +1385,7 @@ if ((iaUser->phase.GetPhase() == 3) && (aliveAck->rnd == iaUser->rnd + 1)) return 0; } //----------------------------------------------------------------------------- -int AUTH_IA::Process_DISCONN_SYN_6(DISCONN_SYN_6 *, IA_USER * iaUser, user_iter *, uint32_t) +int AUTH_IA::Process_DISCONN_SYN_6(DISCONN_SYN_6 *, IA_USER * iaUser, uint32_t) { printfd(__FILE__, "DISCONN_SYN_6\n"); if (iaUser->phase.GetPhase() != 3) @@ -1397,12 +1401,12 @@ printfd(__FILE__, "Phase changed from 3 to 4. Reason: DISCONN_SYN_6\n"); return 0; } //----------------------------------------------------------------------------- -int AUTH_IA::Process_DISCONN_SYN_7(DISCONN_SYN_7 * disconnSyn, IA_USER * iaUser, user_iter * user, uint32_t sip) +int AUTH_IA::Process_DISCONN_SYN_7(DISCONN_SYN_7 * disconnSyn, IA_USER * iaUser, uint32_t sip) { -return Process_DISCONN_SYN_6(disconnSyn, iaUser, user, sip); +return Process_DISCONN_SYN_6(disconnSyn, iaUser, sip); } //----------------------------------------------------------------------------- -int AUTH_IA::Process_DISCONN_SYN_8(DISCONN_SYN_8 *, IA_USER * iaUser, user_iter *, uint32_t) +int AUTH_IA::Process_DISCONN_SYN_8(DISCONN_SYN_8 *, IA_USER * iaUser, uint32_t) { if (iaUser->phase.GetPhase() != 3) { @@ -1419,7 +1423,6 @@ return 0; //----------------------------------------------------------------------------- int AUTH_IA::Process_DISCONN_ACK_6(DISCONN_ACK_6 * disconnAck, IA_USER * iaUser, - user_iter *, uint32_t, map::iterator) { @@ -1437,12 +1440,12 @@ if (!((iaUser->phase.GetPhase() == 4) && (disconnAck->rnd == iaUser->rnd + 1))) return 0; } //----------------------------------------------------------------------------- -int AUTH_IA::Process_DISCONN_ACK_7(DISCONN_ACK_7 * disconnAck, IA_USER * iaUser, user_iter * user, uint32_t sip, map::iterator it) +int AUTH_IA::Process_DISCONN_ACK_7(DISCONN_ACK_7 * disconnAck, IA_USER * iaUser, uint32_t sip, map::iterator it) { -return Process_DISCONN_ACK_6(disconnAck, iaUser, user, sip, it); +return Process_DISCONN_ACK_6(disconnAck, iaUser, sip, it); } //----------------------------------------------------------------------------- -int AUTH_IA::Process_DISCONN_ACK_8(DISCONN_ACK_8 * disconnAck, IA_USER * iaUser, user_iter *, uint32_t, map::iterator) +int AUTH_IA::Process_DISCONN_ACK_8(DISCONN_ACK_8 * disconnAck, IA_USER * iaUser, uint32_t, map::iterator) { #ifdef ARCH_BE SwapBytes(disconnAck->len); @@ -1458,7 +1461,7 @@ if (!((iaUser->phase.GetPhase() == 4) && (disconnAck->rnd == iaUser->rnd + 1))) return 0; } //----------------------------------------------------------------------------- -int AUTH_IA::Send_CONN_SYN_ACK_6(IA_USER * iaUser, user_iter *, uint32_t sip) +int AUTH_IA::Send_CONN_SYN_ACK_6(IA_USER * iaUser, uint32_t sip) { //+++ Fill static data in connSynAck +++ // TODO Move this code. It must be executed only once @@ -1491,12 +1494,12 @@ Encrypt(&iaUser->ctx, (char*)&connSynAck6, (char*)&connSynAck6, Min8(sizeof(CONN return Send(sip, iaSettings.GetUserPort(), (char*)&connSynAck6, Min8(sizeof(CONN_SYN_ACK_6)));; } //----------------------------------------------------------------------------- -int AUTH_IA::Send_CONN_SYN_ACK_7(IA_USER * iaUser, user_iter * user, uint32_t sip) +int AUTH_IA::Send_CONN_SYN_ACK_7(IA_USER * iaUser, uint32_t sip) { -return Send_CONN_SYN_ACK_6(iaUser, user, sip); +return Send_CONN_SYN_ACK_6(iaUser, sip); } //----------------------------------------------------------------------------- -int AUTH_IA::Send_CONN_SYN_ACK_8(IA_USER * iaUser, user_iter *, uint32_t sip) +int AUTH_IA::Send_CONN_SYN_ACK_8(IA_USER * iaUser, uint32_t sip) { strcpy((char*)connSynAck8.hdr.magic, IA_ID); connSynAck8.hdr.protoVer[0] = 0; @@ -1543,8 +1546,8 @@ strcpy((char*)aliveSyn6.type, "ALIVE_SYN"); for (int i = 0; i < DIR_NUM; i++) { - aliveSyn6.md[i] = iaUser->user->property.down.Get()[i]; - aliveSyn6.mu[i] = iaUser->user->property.up.Get()[i]; + aliveSyn6.md[i] = iaUser->user->GetProperty().down.Get()[i]; + aliveSyn6.mu[i] = iaUser->user->GetProperty().up.Get()[i]; aliveSyn6.sd[i] = iaUser->user->GetSessionDownload()[i]; aliveSyn6.su[i] = iaUser->user->GetSessionUpload()[i]; @@ -1567,7 +1570,7 @@ if (dn < DIR_NUM) } else { - double fmb = iaUser->user->property.freeMb; + double fmb = iaUser->user->GetProperty().freeMb; fmb = fmb < 0 ? 0 : fmb; snprintf((char*)aliveSyn6.freeMb, IA_FREEMB_LEN, "%.3f", fmb / p); } @@ -1580,7 +1583,7 @@ else } else { - double fmb = iaUser->user->property.freeMb; + double fmb = iaUser->user->GetProperty().freeMb; fmb = fmb < 0 ? 0 : fmb; snprintf((char*)aliveSyn6.freeMb, IA_FREEMB_LEN, "C%.3f", fmb); } @@ -1594,7 +1597,7 @@ if (iaUser->aliveSent) iaUser->aliveSent = true; #endif -aliveSyn6.cash =(int64_t) (iaUser->user->property.cash.Get() * 1000.0); +aliveSyn6.cash =(int64_t) (iaUser->user->GetProperty().cash.Get() * 1000.0); if (!stgSettings->GetShowFeeInCash()) aliveSyn6.cash -= (int64_t)(tf->GetFee() * 1000.0); @@ -1633,8 +1636,8 @@ strcpy((char*)aliveSyn8.type, "ALIVE_SYN"); for (int i = 0; i < DIR_NUM; i++) { - aliveSyn8.md[i] = iaUser->user->property.down.Get()[i]; - aliveSyn8.mu[i] = iaUser->user->property.up.Get()[i]; + aliveSyn8.md[i] = iaUser->user->GetProperty().down.Get()[i]; + aliveSyn8.mu[i] = iaUser->user->GetProperty().up.Get()[i]; aliveSyn8.sd[i] = iaUser->user->GetSessionDownload()[i]; aliveSyn8.su[i] = iaUser->user->GetSessionUpload()[i]; @@ -1657,7 +1660,7 @@ if (dn < DIR_NUM) } else { - double fmb = iaUser->user->property.freeMb; + double fmb = iaUser->user->GetProperty().freeMb; fmb = fmb < 0 ? 0 : fmb; snprintf((char*)aliveSyn8.freeMb, IA_FREEMB_LEN, "%.3f", fmb / p); } @@ -1670,7 +1673,7 @@ else } else { - double fmb = iaUser->user->property.freeMb; + double fmb = iaUser->user->GetProperty().freeMb; fmb = fmb < 0 ? 0 : fmb; snprintf((char*)aliveSyn8.freeMb, IA_FREEMB_LEN, "C%.3f", fmb); } @@ -1686,7 +1689,7 @@ iaUser->aliveSent = true; const TARIFF * tf = iaUser->user->GetTariff(); -aliveSyn8.cash =(int64_t) (iaUser->user->property.cash.Get() * 1000.0); +aliveSyn8.cash =(int64_t) (iaUser->user->GetProperty().cash.Get() * 1000.0); if (!stgSettings->GetShowFeeInCash()) aliveSyn8.cash -= (int64_t)(tf->GetFee() * 1000.0); diff --git a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h index 92cd29fe..1b2a0f8a 100644 --- a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h +++ b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h @@ -34,24 +34,23 @@ #include #include #include +#include #include #include #include "os_int.h" -#include "base_auth.h" -#include "base_store.h" +#include "auth.h" +#include "store.h" #include "notifer.h" #include "user_ips.h" -#include "../../../user.h" -#include "../../../users.h" +#include "user.h" +#include "users.h" #include "ia_packets.h" #include "blowfish.h" #include "stg_logger.h" #include "utime.h" -using namespace std; - -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); #define IA_PROTO_VER (6) @@ -60,8 +59,7 @@ extern "C" BASE_PLUGIN * GetPlugin(); class AUTH_IA; //----------------------------------------------------------------------------- -enum FREEMB -{ +enum FREEMB { freeMb0 = 0, freeMb1, freeMb2, @@ -86,8 +84,7 @@ enum FREEMB freeMbNone = 101 }; //----------------------------------------------------------------------------- -class IA_PHASE -{ +class IA_PHASE { public: IA_PHASE(); ~IA_PHASE(); @@ -103,8 +100,8 @@ public: const UTIME & GetTime() const; #ifdef IA_PHASE_DEBUG - void SetUserLogin(const string & login); - void SetLogFileName(const string & logFileName); + void SetUserLogin(const std::string & login); + void SetLogFileName(const std::string & logFileName); #endif private: @@ -113,14 +110,13 @@ private: #ifdef IA_PHASE_DEBUG void WritePhaseChange(int newPhase); - string log; - string login; + std::string log; + std::string login; FILE * flog; #endif }; //----------------------------------------------------------------------------- -struct IA_USER -{ +struct IA_USER { IA_USER() : lastSendAlive(0), rnd(random()), @@ -155,28 +151,25 @@ struct IA_USER memcpy(&ctx, &u.ctx, sizeof(BLOWFISH_CTX)); }; - user_iter user; - //int phase; - //UTIME phaseTime; + USER_PTR user; IA_PHASE phase; UTIME lastSendAlive; uint32_t rnd; uint16_t port; BLOWFISH_CTX ctx; - list messagesToSend; + std::list messagesToSend; int protoVer; - string password; + std::string password; #ifdef IA_DEBUG bool aliveSent; #endif }; //----------------------------------------------------------------------------- -class AUTH_IA_SETTINGS -{ +class AUTH_IA_SETTINGS { public: AUTH_IA_SETTINGS(); virtual ~AUTH_IA_SETTINGS() {}; - const string& GetStrError() const { return errorStr; }; + const std::string & GetStrError() const { return errorStr; }; int ParseSettings(const MODULE_SETTINGS & s); int GetUserDelay() const { return userDelay; }; int GetUserTimeout() const { return userTimeout; }; @@ -184,38 +177,37 @@ public: FREEMB GetFreeMbShowType() const { return freeMbShowType; }; private: - int ParseIntInRange(const string & str, int min, int max, int * val); + int ParseIntInRange(const std::string & str, int min, int max, int * val); int userDelay; int userTimeout; uint16_t port; - string errorStr; + std::string errorStr; FREEMB freeMbShowType; }; //----------------------------------------------------------------------------- -class AUTH_IA :public BASE_AUTH -{ +class AUTH_IA :public BASE_AUTH { public: AUTH_IA(); virtual ~AUTH_IA(); - void SetUsers(USERS * u) { users = u; }; - void SetTariffs(TARIFFS *) {}; - void SetAdmins(ADMINS *) {}; - void SetTraffcounter(TRAFFCOUNTER *) {}; - void SetStore(BASE_STORE *) {}; - void SetStgSettings(const SETTINGS * s) { stgSettings = s; }; - void SetSettings(const MODULE_SETTINGS & s) { settings = s; }; + void SetUsers(USERS * u) { users = u; } + void SetTariffs(TARIFFS *) {} + void SetAdmins(ADMINS *) {} + void SetTraffcounter(TRAFFCOUNTER *) {} + void SetStore(STORE *) {} + void SetStgSettings(const SETTINGS * s) { stgSettings = s; } + void SetSettings(const MODULE_SETTINGS & s) { settings = s; } int ParseSettings(); int Start(); int Stop(); - int Reload() { return 0; }; - bool IsRunning() { return isRunningRunTimeouter || isRunningRun; }; + int Reload() { return 0; } + bool IsRunning() { return isRunningRunTimeouter || isRunningRun; } - const string & GetStrError() const { return errorStr; }; - const string GetVersion() const { return "InetAccess authorization plugin v.1.4"; }; - uint16_t GetStartPosition() const { return 50; }; - uint16_t GetStopPosition() const { return 50; }; + const std::string & GetStrError() const { return errorStr; } + const std::string GetVersion() const { return "InetAccess authorization plugin v.1.4"; } + uint16_t GetStartPosition() const { return 50; } + uint16_t GetStopPosition() const { return 50; } int SendMessage(const STG_MSG & msg, uint32_t ip) const; @@ -224,46 +216,43 @@ private: static void * RunTimeouter(void * d); int PrepareNet(); int FinalizeNet(); - void DelUser(user_iter u); + void DelUser(USER_PTR u); int RecvData(char * buffer, int bufferSize); int CheckHeader(const char * buffer, int * protoVer); - int PacketProcessor(char * buff, int dataLen, uint32_t sip, uint16_t sport, int protoVer, user_iter * user); + int PacketProcessor(char * buff, int dataLen, uint32_t sip, uint16_t sport, int protoVer, USER_PTR * user); - int Process_CONN_SYN_6(CONN_SYN_6 * connSyn, IA_USER * iaUser, user_iter * user, uint32_t sip); - int Process_CONN_SYN_7(CONN_SYN_7 * connSyn, IA_USER * iaUser, user_iter * user, uint32_t sip); - int Process_CONN_SYN_8(CONN_SYN_8 * connSyn, IA_USER * iaUser, user_iter * user, uint32_t sip); + int Process_CONN_SYN_6(CONN_SYN_6 * connSyn, IA_USER * iaUser, uint32_t sip); + int Process_CONN_SYN_7(CONN_SYN_7 * connSyn, IA_USER * iaUser, uint32_t sip); + int Process_CONN_SYN_8(CONN_SYN_8 * connSyn, IA_USER * iaUser, uint32_t sip); - int Process_CONN_ACK_6(CONN_ACK_6 * connAck, IA_USER * iaUser, user_iter * user, uint32_t sip); - int Process_CONN_ACK_7(CONN_ACK_7 * connAck, IA_USER * iaUser, user_iter * user, uint32_t sip); - int Process_CONN_ACK_8(CONN_ACK_8 * connAck, IA_USER * iaUser, user_iter * user, uint32_t sip); + int Process_CONN_ACK_6(CONN_ACK_6 * connAck, IA_USER * iaUser, uint32_t sip); + int Process_CONN_ACK_7(CONN_ACK_7 * connAck, IA_USER * iaUser, uint32_t sip); + int Process_CONN_ACK_8(CONN_ACK_8 * connAck, IA_USER * iaUser, uint32_t sip); - int Process_ALIVE_ACK_6(ALIVE_ACK_6 * aliveAck, IA_USER * iaUser, user_iter * user, uint32_t sip); - int Process_ALIVE_ACK_7(ALIVE_ACK_7 * aliveAck, IA_USER * iaUser, user_iter * user, uint32_t sip); - int Process_ALIVE_ACK_8(ALIVE_ACK_8 * aliveAck, IA_USER * iaUser, user_iter * user, uint32_t sip); + int Process_ALIVE_ACK_6(ALIVE_ACK_6 * aliveAck, IA_USER * iaUser, uint32_t sip); + int Process_ALIVE_ACK_7(ALIVE_ACK_7 * aliveAck, IA_USER * iaUser, uint32_t sip); + int Process_ALIVE_ACK_8(ALIVE_ACK_8 * aliveAck, IA_USER * iaUser, uint32_t sip); - int Process_DISCONN_SYN_6(DISCONN_SYN_6 * disconnSyn, IA_USER * iaUser, user_iter * user, uint32_t sip); - int Process_DISCONN_SYN_7(DISCONN_SYN_7 * disconnSyn, IA_USER * iaUser, user_iter * user, uint32_t sip); - int Process_DISCONN_SYN_8(DISCONN_SYN_8 * disconnSyn, IA_USER * iaUser, user_iter * user, uint32_t sip); + int Process_DISCONN_SYN_6(DISCONN_SYN_6 * disconnSyn, IA_USER * iaUser, uint32_t sip); + int Process_DISCONN_SYN_7(DISCONN_SYN_7 * disconnSyn, IA_USER * iaUser, uint32_t sip); + int Process_DISCONN_SYN_8(DISCONN_SYN_8 * disconnSyn, IA_USER * iaUser, uint32_t sip); int Process_DISCONN_ACK_6(DISCONN_ACK_6 * disconnSyn, IA_USER * iaUser, - user_iter * user, uint32_t sip, map::iterator it); int Process_DISCONN_ACK_7(DISCONN_ACK_7 * disconnSyn, IA_USER * iaUser, - user_iter * user, uint32_t sip, map::iterator it); int Process_DISCONN_ACK_8(DISCONN_ACK_8 * disconnSyn, IA_USER * iaUser, - user_iter * user, uint32_t sip, map::iterator it); - int Send_CONN_SYN_ACK_6(IA_USER * iaUser, user_iter * user, uint32_t sip); - int Send_CONN_SYN_ACK_7(IA_USER * iaUser, user_iter * user, uint32_t sip); - int Send_CONN_SYN_ACK_8(IA_USER * iaUser, user_iter * user, uint32_t sip); + int Send_CONN_SYN_ACK_6(IA_USER * iaUser, uint32_t sip); + int Send_CONN_SYN_ACK_7(IA_USER * iaUser, uint32_t sip); + int Send_CONN_SYN_ACK_8(IA_USER * iaUser, uint32_t sip); int Send_ALIVE_SYN_6(IA_USER * iaUser, uint32_t sip); int Send_ALIVE_SYN_7(IA_USER * iaUser, uint32_t sip); @@ -279,7 +268,7 @@ private: int Timeouter(); - int SendError(uint32_t ip, uint16_t port, int protoVer, const string & text); + 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, int len); int RealSendMessage6(const STG_MSG & msg, uint32_t ip, IA_USER & user); int RealSendMessage7(const STG_MSG & msg, uint32_t ip, IA_USER & user); @@ -289,7 +278,7 @@ private: BLOWFISH_CTX ctxS; //for loginS - mutable string errorStr; + mutable std::string errorStr; AUTH_IA_SETTINGS iaSettings; MODULE_SETTINGS settings; @@ -301,7 +290,7 @@ private: USERS * users; const SETTINGS * stgSettings; - mutable map ip2user; + mutable std::map ip2user; pthread_t recvThread; pthread_t timeouterThread; @@ -320,19 +309,18 @@ private: FIN_6 fin6; FIN_8 fin8; - map packetTypes; + std::map packetTypes; STG_LOGGER & WriteServLog; uint32_t enabledDirs; - class DEL_USER_NONIFIER: public NOTIFIER_BASE - { + class DEL_USER_NONIFIER: public NOTIFIER_BASE { public: - DEL_USER_NONIFIER(AUTH_IA & a) : auth(a) {}; - virtual ~DEL_USER_NONIFIER(){}; + DEL_USER_NONIFIER(AUTH_IA & a) : auth(a) {} + virtual ~DEL_USER_NONIFIER() {} - void Notify(const user_iter & user) + void Notify(const USER_PTR & user) { auth.DelUser(user); } @@ -343,7 +331,7 @@ private: class UnauthorizeUser : std::unary_function &, void> { public: - UnauthorizeUser(AUTH_IA * a) : auth(a) {}; + UnauthorizeUser(AUTH_IA * a) : auth(a) {} void operator()(const std::pair & p) { p.second.user->Unauthorize(auth); @@ -356,5 +344,3 @@ private: //----------------------------------------------------------------------------- #endif - - diff --git a/projects/stargazer/plugins/authorization/stress/stress.h b/projects/stargazer/plugins/authorization/stress/stress.h index 1caf3a47..500835a4 100644 --- a/projects/stargazer/plugins/authorization/stress/stress.h +++ b/projects/stargazer/plugins/authorization/stress/stress.h @@ -28,22 +28,22 @@ #ifndef STRESS_H #define STRESS_H -#include #include -#include "base_auth.h" + +#include +#include + +#include "auth.h" #include "notifer.h" #include "user_ips.h" -#include "../../../users.h" +#include "users.h" -using namespace std; - -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); class AUTH_STRESS; //----------------------------------------------------------------------------- template -class CHG_BEFORE_NOTIFIER: public PROPERTY_NOTIFIER_BASE -{ +class CHG_BEFORE_NOTIFIER: public PROPERTY_NOTIFIER_BASE { public: void Notify(const varParamType & oldValue, const varParamType & newValue); void SetUser(user_iter u) { user = u; } @@ -56,8 +56,7 @@ private: }; //----------------------------------------------------------------------------- template -class CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE -{ +class CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE { public: void Notify(const varParamType & oldValue, const varParamType & newValue); void SetUser(user_iter u) { user = u; } @@ -69,39 +68,37 @@ private: const AUTH_STRESS * auth; }; //----------------------------------------------------------------------------- -class AUTH_STRESS_SETTINGS -{ +class AUTH_STRESS_SETTINGS { public: AUTH_STRESS_SETTINGS(); - const string& GetStrError() const { return errorStr; } + const std::string & GetStrError() const { return errorStr; } int ParseSettings(const MODULE_SETTINGS & s); int GetAverageOnlineTime() const; private: - int ParseIntInRange(const string & str, int min, int max, int * val); + int ParseIntInRange(const std::string & str, int min, int max, int * val); int averageOnlineTime; - string errorStr; + std::string errorStr; }; //----------------------------------------------------------------------------- -class AUTH_STRESS :public BASE_AUTH -{ +class AUTH_STRESS :public AUTH { public: AUTH_STRESS(); - virtual ~AUTH_STRESS(){}; + virtual ~AUTH_STRESS() {} void SetUsers(USERS * u); - void SetTariffs(TARIFFS * t){}; - void SetAdmins(ADMINS * a){}; - void SetTraffcounter(TRAFFCOUNTER * tc){}; - void SetStore(BASE_STORE * ){}; - void SetStgSettings(const SETTINGS *){}; + void SetTariffs(TARIFFS * t) {} + void SetAdmins(ADMINS * a) {} + void SetTraffcounter(TRAFFCOUNTER * tc) {} + void SetStore(STORE * ) {} + void SetStgSettings(const SETTINGS *) {} int Start(); int Stop(); bool IsRunning(); void SetSettings(const MODULE_SETTINGS & s); int ParseSettings(); - const string & GetStrError() const; - const string GetVersion() const; + const std::string & GetStrError() const; + const std::string GetVersion() const; uint16_t GetStartPosition() const; uint16_t GetStopPosition() const; @@ -122,24 +119,23 @@ private: static void * Run(void *); - mutable string errorStr; + mutable std::string errorStr; AUTH_STRESS_SETTINGS stressSettings; USERS * users; - list usersList; + std::list usersList; bool isRunning; MODULE_SETTINGS settings; pthread_t thread; pthread_mutex_t mutex; - list > BeforeChgIPNotifierList; - list > AfterChgIPNotifierList; + std::list > BeforeChgIPNotifierList; + std::list > AfterChgIPNotifierList; - class ADD_USER_NONIFIER: public NOTIFIER_BASE - { + class ADD_USER_NONIFIER: public NOTIFIER_BASE { public: - ADD_USER_NONIFIER(){}; - virtual ~ADD_USER_NONIFIER(){}; + ADD_USER_NONIFIER() {} + virtual ~ADD_USER_NONIFIER() {} void SetAuthorizator(AUTH_STRESS * a) { auth = a; } void Notify(const user_iter & user) @@ -151,11 +147,10 @@ private: AUTH_STRESS * auth; } onAddUserNotifier; - class DEL_USER_NONIFIER: public NOTIFIER_BASE - { + class DEL_USER_NONIFIER: public NOTIFIER_BASE { public: - DEL_USER_NONIFIER(){}; - virtual ~DEL_USER_NONIFIER(){}; + DEL_USER_NONIFIER() {} + virtual ~DEL_USER_NONIFIER() {} void SetAuthorizator(AUTH_STRESS * a) { auth = a; } void Notify(const user_iter & user) @@ -171,5 +166,3 @@ private: //----------------------------------------------------------------------------- #endif - - diff --git a/projects/stargazer/plugins/capture/cap_debug/debug_cap.h b/projects/stargazer/plugins/capture/cap_debug/debug_cap.h index 35bcec47..207aa40e 100644 --- a/projects/stargazer/plugins/capture/cap_debug/debug_cap.h +++ b/projects/stargazer/plugins/capture/cap_debug/debug_cap.h @@ -28,19 +28,19 @@ $Date: 2009/06/23 11:32:27 $ $Author: faust $ */ -#include #include +#include + #include "os_int.h" -#include "base_plugin.h" -#include "base_settings.h" +#include "plugin.h" +#include "module_settings.h" using namespace std; -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); //----------------------------------------------------------------------------- -struct iphdr_eth -{ +struct iphdr_eth { uint8_t ihl:4, version:4; uint8_t tos; @@ -56,31 +56,30 @@ struct iphdr_eth char iface[10]; }; //----------------------------------------------------------------------------- -class CAP_SETTINGS//: public BASE_SETTINGS -{ +class CAP_SETTINGS { public: - const string& GetStrError() const { static string s; return s; } - int ParseSettings(const MODULE_SETTINGS & s) { return 0; }; + const string & GetStrError() const { static string s; return s; } + int ParseSettings(const MODULE_SETTINGS & s) { return 0; } }; //----------------------------------------------------------------------------- -class DEBUG_CAP :public BASE_PLUGIN +class DEBUG_CAP :public PLUGIN { public: DEBUG_CAP(); - virtual ~DEBUG_CAP(){}; + virtual ~DEBUG_CAP() {} - void SetUsers(USERS * u){}; - void SetTariffs(TARIFFS * t){}; - void SetAdmins(ADMINS * a){}; + void SetUsers(USERS * u) {} + void SetTariffs(TARIFFS * t) {} + void SetAdmins(ADMINS * a) {} void SetTraffcounter(TRAFFCOUNTER * tc); - void SetStore(BASE_STORE *){}; - void SetStgSettings(const SETTINGS *){}; + void SetStore(STORE *) {} + void SetStgSettings(const SETTINGS *) {} int Start(); int Stop(); - int Reload() { return 0; }; - int ParseSettings() { return 0; }; - void SetSettings(const MODULE_SETTINGS & s){}; + int Reload() { return 0; } + int ParseSettings() { return 0; } + void SetSettings(const MODULE_SETTINGS & s) {} bool IsRunning(); const string & GetStrError() const; const string GetVersion() const; @@ -99,4 +98,3 @@ private: TRAFFCOUNTER * traffCnt; }; //----------------------------------------------------------------------------- - diff --git a/projects/stargazer/plugins/capture/cap_nf/cap_nf.cpp b/projects/stargazer/plugins/capture/cap_nf/cap_nf.cpp index 4ef1ee8e..ddbe935a 100644 --- a/projects/stargazer/plugins/capture/cap_nf/cap_nf.cpp +++ b/projects/stargazer/plugins/capture/cap_nf/cap_nf.cpp @@ -61,7 +61,7 @@ private: NF_CAP * nf; } cnc; -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return cnc.GetCapturer(); } diff --git a/projects/stargazer/plugins/capture/cap_nf/cap_nf.h b/projects/stargazer/plugins/capture/cap_nf/cap_nf.h index 6844fe2a..c778a663 100644 --- a/projects/stargazer/plugins/capture/cap_nf/cap_nf.h +++ b/projects/stargazer/plugins/capture/cap_nf/cap_nf.h @@ -30,18 +30,27 @@ $Author: faust $ #ifndef __CAP_NF_H__ #define __CAP_NF_H__ -#include #include +#include + #include "os_int.h" -#include "base_plugin.h" +#include "plugin.h" +#include "module_settings.h" #define VERSION "CAP_NF v. 0.4" #define START_POS 0 #define STOP_POS 0 -struct NF_HEADER -{ +class USERS; +class USER; +class TARIFFS; +class ADMINS; +class TRAFFCOUNTER; +class STORE; +class SETTINGS; + +struct NF_HEADER { uint16_t version; // Protocol version uint16_t count; // Flows count uint32_t uptime; // System uptime @@ -53,8 +62,7 @@ struct NF_HEADER uint16_t sInterval; // Sampling mode and interval } __attribute__ ((packed)); -struct NF_DATA -{ +struct NF_DATA { uint32_t srcAddr; // Flow source address uint32_t dstAddr; // Flow destination address uint32_t nextHop; // IP addres on next hop router @@ -79,29 +87,28 @@ struct NF_DATA #define BUF_SIZE (sizeof(NF_HEADER) + 30 * sizeof(NF_DATA)) -class NF_CAP : public BASE_PLUGIN -{ +class NF_CAP : public PLUGIN { public: NF_CAP(); ~NF_CAP(); - void SetUsers(USERS *) {}; - void SetTariffs(TARIFFS *) {}; - void SetAdmins(ADMINS *) {}; - void SetTraffcounter(TRAFFCOUNTER * tc) { traffCnt = tc; }; - void SetStore(BASE_STORE *) {}; - void SetStgSettings(const SETTINGS *) {}; - void SetSettings(const MODULE_SETTINGS & s) { settings = s; }; + void SetUsers(USERS *) {} + void SetTariffs(TARIFFS *) {} + void SetAdmins(ADMINS *) {} + void SetTraffcounter(TRAFFCOUNTER * tc) { traffCnt = tc; } + void SetStore(STORE *) {} + void SetStgSettings(const SETTINGS *) {} + void SetSettings(const MODULE_SETTINGS & s) { settings = s; } int ParseSettings(); int Start(); int Stop(); - int Reload() { return 0; }; - bool IsRunning() { return runningTCP || runningUDP; }; - const string & GetStrError() const { return errorStr; }; - const string GetVersion() const { return VERSION; }; - uint16_t GetStartPosition() const { return START_POS; }; - uint16_t GetStopPosition() const { return STOP_POS; }; + int Reload() { return 0; } + bool IsRunning() { return runningTCP || runningUDP; } + const string & GetStrError() const { return errorStr; } + const string GetVersion() const { return VERSION; } + uint16_t GetStartPosition() const { return START_POS; } + uint16_t GetStopPosition() const { return STOP_POS; } private: TRAFFCOUNTER * traffCnt; @@ -124,12 +131,12 @@ private: bool OpenTCP(); bool OpenUDP(); - void CloseTCP() { close(sockTCP); }; - void CloseUDP() { close(sockUDP); }; + void CloseTCP() { close(sockTCP); } + void CloseUDP() { close(sockUDP); } bool WaitPackets(int sd) const; }; -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); #endif diff --git a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp index 59fc06a9..2bc83cad 100644 --- a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp +++ b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp @@ -45,8 +45,7 @@ $Date: 2010/09/10 06:43:03 $ #define BUFF_LEN (16384) /* max mtu -> lo=16436 TODO why?*/ //----------------------------------------------------------------------------- -struct DIVERT_DATA -{ +struct DIVERT_DATA { int sock; short int port; unsigned char buffer[BUFF_LEN]; @@ -56,8 +55,7 @@ char iface[10]; pollfd pollddiv; DIVERT_DATA cddiv; //capture data //----------------------------------------------------------------------------- -class DIVERT_CAP_CREATOR -{ +class DIVERT_CAP_CREATOR { private: DIVERT_CAP * divc; @@ -83,14 +81,14 @@ DIVERT_CAP_CREATOR dcc; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return dcc.GetCapturer(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -const string DIVERT_CAP::GetVersion() const +const std::string DIVERT_CAP::GetVersion() const { return "Divert_cap v.1.0"; } @@ -108,7 +106,7 @@ void DIVERT_CAP::SetTraffcounter(TRAFFCOUNTER * tc) traffCnt = tc; } //----------------------------------------------------------------------------- -const string & DIVERT_CAP::GetStrError() const +const std::string & DIVERT_CAP::GetStrError() const { return errorStr; } @@ -352,7 +350,7 @@ port = p; return 0; } //----------------------------------------------------------------------------- -int DIVERT_CAP::ParseIntInRange(const string & str, int min, int max, int * val) +int DIVERT_CAP::ParseIntInRange(const std::string & str, int min, int max, int * val) { if (str2x(str.c_str(), *val)) { diff --git a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h index 84234219..e34fcf32 100644 --- a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h +++ b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h @@ -27,40 +27,44 @@ $Date: 2009/06/23 11:32:27 $ #ifndef DIVERT_CAP_H #define DIVERT_CAP_H -#include #include -#include "base_plugin.h" -#include "base_settings.h" +#include + +#include "plugin.h" +#include "module_settings.h" #include "../../../traffcounter.h" -using namespace std; +class USERS; +class TARIFFS; +class ADMINS; +class TRAFFCOUNTER; +class SETTINGS; -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); //----------------------------------------------------------------------------- -class DIVERT_CAP :public BASE_PLUGIN -{ +class DIVERT_CAP : public PLUGIN { public: DIVERT_CAP(); - virtual ~DIVERT_CAP(){}; + virtual ~DIVERT_CAP() {} - void SetUsers(USERS *){}; - void SetTariffs(TARIFFS *){}; - void SetAdmins(ADMINS *){}; + void SetUsers(USERS *) {} + void SetTariffs(TARIFFS *) {} + void SetAdmins(ADMINS *) {} void SetTraffcounter(TRAFFCOUNTER * tc); - void SetStore(BASE_STORE *){}; - void SetStgSettings(const SETTINGS *){}; + void SetStore(STORE *) {} + void SetStgSettings(const SETTINGS *) {} int Start(); int Stop(); - int Reload() { return 0; }; + int Reload() { return 0; } bool IsRunning(); void SetSettings(const MODULE_SETTINGS & s); int ParseSettings(); - const string & GetStrError() const; - const string GetVersion() const; + const std::string & GetStrError() const; + const std::string GetVersion() const; uint16_t GetStartPosition() const; uint16_t GetStopPosition() const; @@ -73,24 +77,21 @@ private: int DivertCapRead(char * buffer, int blen, char ** iface, int n); int DivertCapClose(); - int ParseIntInRange(const string & str, int min, int max, int * val); + int ParseIntInRange(const std::string & str, int min, int max, int * val); MODULE_SETTINGS settings; int port; - mutable string errorStr; + mutable std::string errorStr; pthread_t thread; bool nonstop; bool isRunning; - //int capSock; - TRAFFCOUNTER * traffCnt; }; //----------------------------------------------------------------------------- - #endif diff --git a/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp b/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp index 27141b91..0f6cb98c 100644 --- a/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp +++ b/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.cpp @@ -48,21 +48,15 @@ $Author: faust $ #include #include -#include -#include - #include "ether_cap.h" #include "common.h" #include "raw_ip_packet.h" -using namespace std; - //#define CAP_DEBUG 1 //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -class BPF_CAP_CREATOR -{ +class BPF_CAP_CREATOR { private: BPF_CAP * bpfc; @@ -88,7 +82,7 @@ BPF_CAP_CREATOR bcc; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return bcc.GetCapturer(); } @@ -99,7 +93,7 @@ int BPF_CAP_SETTINGS::ParseSettings(const MODULE_SETTINGS & s) { //char sep[]= ", \t\n\r"; //char *s; -string ifaces; +std::string ifaces; //char * str; //char *p; @@ -159,7 +153,7 @@ if (!ifaces.size()) return 0; } //----------------------------------------------------------------------------- -string BPF_CAP_SETTINGS::GetIface(unsigned int num) +std::string BPF_CAP_SETTINGS::GetIface(unsigned int num) { if (num >= iface.size()) { @@ -170,7 +164,7 @@ return iface[num]; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -const string BPF_CAP::GetVersion() const +const std::string BPF_CAP::GetVersion() const { return "bpf_cap v.1.0"; } @@ -204,7 +198,7 @@ void BPF_CAP::SetTraffcounter(TRAFFCOUNTER * tc) traffCnt = tc; } //----------------------------------------------------------------------------- -const string & BPF_CAP::GetStrError() const +const std::string & BPF_CAP::GetStrError() const { return errorStr; } @@ -365,7 +359,7 @@ strncpy(ifr.ifr_name, bd->iface.c_str(), sizeof(ifr.ifr_name)); //if (ioctl(cd[n].fd, BIOCSBLEN, (caddr_t)&l) < 0) if (ioctl(bd->fd, BIOCSBLEN, (caddr_t)&l) < 0) { - errorStr = bd->iface + " BIOCSBLEN " + string(strerror(errno)); + errorStr = bd->iface + " BIOCSBLEN " + std::string(strerror(errno)); printfd(__FILE__, "ioctl failed: '%s'\n", errorStr.c_str()); return -1; } @@ -373,7 +367,7 @@ if (ioctl(bd->fd, BIOCSBLEN, (caddr_t)&l) < 0) //if (ioctl(cd[n].fd, BIOCSETIF, (caddr_t)&ifr) < 0 ) if (ioctl(bd->fd, BIOCSETIF, (caddr_t)&ifr) < 0) { - errorStr = bd->iface + " BIOCSETIF " + string(strerror(errno)); + errorStr = bd->iface + " BIOCSETIF " + std::string(strerror(errno)); printfd(__FILE__, "ioctl failed: '%s'\n", errorStr.c_str()); return -1; } @@ -381,7 +375,7 @@ if (ioctl(bd->fd, BIOCSETIF, (caddr_t)&ifr) < 0) //if (ioctl(cd[n].fd, BIOCIMMEDIATE, &im) < 0 ) if (ioctl(bd->fd, BIOCIMMEDIATE, &im) < 0) { - errorStr = bd->iface + " BIOCIMMEDIATE " + string(strerror(errno)); + errorStr = bd->iface + " BIOCIMMEDIATE " + std::string(strerror(errno)); printfd(__FILE__, "ioctl failed: '%s'\n", errorStr.c_str()); return -1; } diff --git a/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.h b/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.h index 6e651d35..7097c280 100644 --- a/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.h +++ b/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.h @@ -27,9 +27,10 @@ #ifndef ETHER_CAP_H #define ETHER_CAP_H +#include + #include #include -#include #ifdef FREE_BSD5 #include @@ -39,19 +40,16 @@ #include #endif -#include "base_plugin.h" -#include "base_settings.h" +#include "plugin.h" +#include "module_settings.h" #include "../../../traffcounter.h" -using namespace std; +extern "C" PLUGIN * GetPlugin(); -extern "C" BASE_PLUGIN * GetPlugin(); - -#define BUFF_LEN (128) +#define BUFF_LEN (128) //----------------------------------------------------------------------------- -struct BPF_DATA -{ +struct BPF_DATA { BPF_DATA() { fd = 0; @@ -62,7 +60,6 @@ struct BPF_DATA bh = NULL; canRead = 1; iface = ""; - //memset(&polld, 0, sizeof(pollfd)); }; BPF_DATA(const BPF_DATA & bd) @@ -75,7 +72,6 @@ struct BPF_DATA bh = bd.bh; canRead = bd.canRead; iface = bd.iface; - //memcpy(&polld, &bd.polld, sizeof(pollfd)); }; int fd; @@ -85,74 +81,69 @@ int sum; uint8_t buffer[BUFF_LEN]; struct bpf_hdr * bh; int canRead; -string iface; -//pollfd polld; +std::string iface; }; //----------------------------------------------------------------------------- -class BPF_CAP_SETTINGS -{ +class BPF_CAP_SETTINGS { public: - virtual ~BPF_CAP_SETTINGS(){}; - const string& GetStrError() const { return errorStr; } + virtual ~BPF_CAP_SETTINGS() {} + const std::string & GetStrError() const { return errorStr; } int ParseSettings(const MODULE_SETTINGS & s); - string GetIface(unsigned int num); + std::string GetIface(unsigned int num); private: - vector iface; - mutable string errorStr; + std::vector iface; + mutable std::string errorStr; }; //----------------------------------------------------------------------------- -class BPF_CAP :public BASE_PLUGIN -{ +class BPF_CAP : public PLUGIN { public: BPF_CAP(); - virtual ~BPF_CAP(){}; + virtual ~BPF_CAP() {} - void SetUsers(USERS *){}; - void SetTariffs(TARIFFS *){}; - void SetAdmins(ADMINS *){}; + void SetUsers(USERS *) {} + void SetTariffs(TARIFFS *) {} + void SetAdmins(ADMINS *) {} void SetTraffcounter(TRAFFCOUNTER * tc); - void SetStore(BASE_STORE *){}; - void SetStgSettings(const SETTINGS *){}; + void SetStore(STORE *) {} + void SetStgSettings(const SETTINGS *) {} int Start(); int Stop(); - int Reload() { return 0; }; + int Reload() { return 0; } bool IsRunning(); void SetSettings(const MODULE_SETTINGS & s); int ParseSettings(); - const string & GetStrError() const; - const string GetVersion() const; + const std::string & GetStrError() const; + const std::string GetVersion() const; uint16_t GetStartPosition() const; uint16_t GetStopPosition() const; private: static void * Run(void *); int BPFCapOpen(); - //int BPFCapOpen(int n); int BPFCapOpen(BPF_DATA * bd); int BPFCapClose(); int BPFCapRead(char * buffer, int blen, char ** iface); int BPFCapRead(char * buffer, int blen, char ** iface, BPF_DATA * bd); - BPF_CAP_SETTINGS capSettings; + BPF_CAP_SETTINGS capSettings; - mutable string errorStr; + mutable std::string errorStr; - vector bpfData; - vector polld; + std::vector bpfData; + std::vector polld; - pthread_t thread; - bool nonstop; - bool isRunning; - int capSock; - MODULE_SETTINGS settings; + pthread_t thread; + bool nonstop; + bool isRunning; + int capSock; + MODULE_SETTINGS settings; - TRAFFCOUNTER * traffCnt; + TRAFFCOUNTER * traffCnt; }; //----------------------------------------------------------------------------- -#endif //ETHER_CAP_H - +#endif diff --git a/projects/stargazer/plugins/capture/ether_linux/ether_cap.cpp b/projects/stargazer/plugins/capture/ether_linux/ether_cap.cpp index 11aa475a..ba9dce06 100644 --- a/projects/stargazer/plugins/capture/ether_linux/ether_cap.cpp +++ b/projects/stargazer/plugins/capture/ether_linux/ether_cap.cpp @@ -50,7 +50,6 @@ $Date: 2009/12/13 13:45:13 $ //#define CAP_DEBUG 1 - //----------------------------------------------------------------------------- class ETHER_CAP_CREATOR { @@ -79,14 +78,14 @@ ETHER_CAP_CREATOR ecc; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return ecc.GetCapturer(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -const string ETHER_CAP::GetVersion() const +const std::string ETHER_CAP::GetVersion() const { return "Ether_cap v.1.2"; } @@ -104,7 +103,7 @@ void ETHER_CAP::SetTraffcounter(TRAFFCOUNTER * tc) traffCnt = tc; } //----------------------------------------------------------------------------- -const string & ETHER_CAP::GetStrError() const +const std::string & ETHER_CAP::GetStrError() const { return errorStr; } diff --git a/projects/stargazer/plugins/capture/ether_linux/ether_cap.h b/projects/stargazer/plugins/capture/ether_linux/ether_cap.h index fde7d3a0..09888200 100644 --- a/projects/stargazer/plugins/capture/ether_linux/ether_cap.h +++ b/projects/stargazer/plugins/capture/ether_linux/ether_cap.h @@ -30,37 +30,40 @@ #include -#include "base_plugin.h" -#include "base_settings.h" +#include "plugin.h" +#include "module_settings.h" #include "../../../traffcounter.h" -using namespace std; +class USERS; +class TARIFFS; +class ADMINS; +class TRAFFCOUNTER; +class SETTINGS; -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); //----------------------------------------------------------------------------- -class ETHER_CAP :public BASE_PLUGIN -{ +class ETHER_CAP :public PLUGIN { public: ETHER_CAP(); - virtual ~ETHER_CAP(){}; + virtual ~ETHER_CAP() {} - void SetUsers(USERS *){}; - void SetTariffs(TARIFFS *){}; - void SetAdmins(ADMINS *){}; + void SetUsers(USERS *) {} + void SetTariffs(TARIFFS *) {} + void SetAdmins(ADMINS *) {} void SetTraffcounter(TRAFFCOUNTER * tc); - void SetStore(BASE_STORE *){}; - void SetStgSettings(const SETTINGS *){}; + void SetStore(STORE *) {} + void SetStgSettings(const SETTINGS *) {} int Start(); int Stop(); - int Reload() { return 0; }; + int Reload() { return 0; } bool IsRunning(); - void SetSettings(const MODULE_SETTINGS &){}; - int ParseSettings(){ return 0; }; - const string & GetStrError() const; - const string GetVersion() const; + void SetSettings(const MODULE_SETTINGS &) {} + int ParseSettings() { return 0; } + const std::string & GetStrError() const; + const std::string GetVersion() const; uint16_t GetStartPosition() const; uint16_t GetStopPosition() const; @@ -71,7 +74,7 @@ private: int EthCapRead(void * buffer, int blen, char ** iface); bool WaitPackets(int sd) const; - mutable string errorStr; + mutable std::string errorStr; pthread_t thread; bool nonstop; @@ -82,5 +85,4 @@ private: }; //----------------------------------------------------------------------------- -#endif //ETHER_CAP_H - +#endif diff --git a/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp b/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp index 2bf345de..fbf35894 100644 --- a/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp +++ b/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.cpp @@ -7,12 +7,11 @@ #include "raw_ip_packet.h" extern "C" - { - #include "libipq.h" - } - -class IPQ_CAP_CREATOR { +#include "libipq.h" +} + +class IPQ_CAP_CREATOR { private: IPQ_CAP * ic; @@ -38,14 +37,14 @@ IPQ_CAP_CREATOR icc; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return icc.GetCapturer(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -const string IPQ_CAP::GetVersion() const +const std::string IPQ_CAP::GetVersion() const { return "ipq_cap v.1.2"; } @@ -65,7 +64,7 @@ void IPQ_CAP::SetTraffcounter(TRAFFCOUNTER * tc) traffCnt = tc; } //----------------------------------------------------------------------------- -const string & IPQ_CAP::GetStrError() const +const std::string & IPQ_CAP::GetStrError() const { return errorStr; } diff --git a/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.h b/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.h index 3b088ada..f9fee71e 100644 --- a/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.h +++ b/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.h @@ -1,37 +1,43 @@ +#ifndef IPQ_CAP_H +#define IPQ_CAP_H + #include -#include "base_plugin.h" -#include "base_settings.h" +#include "plugin.h" +#include "module_settings.h" #include "../../../traffcounter.h" #define BUFSIZE (256) #define PAYLOAD_LEN (96) -using namespace std; +class USERS; +class TARIFFS; +class ADMINS; +class TRAFFCOUNTER; +class SETTINGS; -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); //----------------------------------------------------------------------------- -class IPQ_CAP :public BASE_PLUGIN -{ +class IPQ_CAP :public PLUGIN { public: IPQ_CAP(); - virtual ~IPQ_CAP(){}; + virtual ~IPQ_CAP() {} - void SetUsers(USERS *){}; - void SetTariffs(TARIFFS *){}; - void SetAdmins(ADMINS *){}; + void SetUsers(USERS *) {} + void SetTariffs(TARIFFS *) {} + void SetAdmins(ADMINS *) {} void SetTraffcounter(TRAFFCOUNTER * tc); - void SetStore(BASE_STORE *){}; - void SetStgSettings(const SETTINGS *){}; + void SetStore(STORE *) {} + void SetStgSettings(const SETTINGS *) {} int Start(); int Stop(); - int Reload() { return 0; }; + int Reload() { return 0; } bool IsRunning(); - void SetSettings(const MODULE_SETTINGS &){}; - int ParseSettings(){ return 0; }; + void SetSettings(const MODULE_SETTINGS &) {} + int ParseSettings() { return 0; } const string & GetStrError() const; const string GetVersion() const; uint16_t GetStartPosition() const; @@ -43,7 +49,7 @@ private: int IPQCapClose(); int IPQCapRead(void * buffer, int blen); - struct ipq_handle *ipq_h; + struct ipq_handle * ipq_h; mutable string errorStr; pthread_t thread; @@ -54,3 +60,5 @@ private: TRAFFCOUNTER * traffCnt; unsigned char buf[BUFSIZE]; }; + +#endif diff --git a/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp b/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp index cfaec555..7304f280 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.cpp @@ -3,14 +3,8 @@ #include "rpcconfig.h" -#include "../../../admin.h" -#include "../../../admins.h" -#include "../../../users.h" -#include "../../../tariffs.h" -#include "../../../traffcounter.h" -#include "../../../settings.h" -#include "base_store.h" -#include "base_settings.h" +#include "admin.h" +#include "module_settings.h" #include "info_methods.h" #include "users_methods.h" @@ -18,8 +12,7 @@ #include "admins_methods.h" #include "messages_methods.h" -class RPC_CONFIG_CREATOR -{ +class RPC_CONFIG_CREATOR { private: RPC_CONFIG * rpcconfig; @@ -27,16 +20,16 @@ public: RPC_CONFIG_CREATOR() : rpcconfig(new RPC_CONFIG()) { - }; + } ~RPC_CONFIG_CREATOR() { delete rpcconfig; - }; + } RPC_CONFIG * GetPlugin() { return rpcconfig; - }; + } }; RPC_CONFIG_CREATOR rpcc; diff --git a/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h b/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h index 15ff1291..58e8973a 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h +++ b/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h @@ -12,17 +12,17 @@ #include #include "os_int.h" -#include "base_plugin.h" +#include "plugin.h" #include "admin_conf.h" #define RPC_CONFIG_VERSION "Stargazer RPC v. 0.2" -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); class ADMINS; class TARIFFS; class USERS; -class BASE_STORE; +class STORE; class RPC_CONFIG_SETTINGS { @@ -50,7 +50,7 @@ struct ADMIN_INFO PRIV priviledges; }; -class RPC_CONFIG :public BASE_PLUGIN +class RPC_CONFIG :public PLUGIN { public: RPC_CONFIG(); @@ -59,7 +59,7 @@ public: void SetUsers(USERS * u) { users = u; } void SetTariffs(TARIFFS * t) { tariffs = t; } void SetAdmins(ADMINS * a) { admins = a; } - void SetStore(BASE_STORE * s) { store = s; } + void SetStore(STORE * s) { store = s; } void SetTraffcounter(TRAFFCOUNTER *) {} void SetStgSettings(const SETTINGS * s) { stgSettings = s; } void SetSettings(const MODULE_SETTINGS & s) { settings = s; } @@ -92,7 +92,7 @@ private: USERS * users; ADMINS * admins; TARIFFS * tariffs; - BASE_STORE * store; + STORE * store; MODULE_SETTINGS settings; const SETTINGS * stgSettings; xmlrpc_c::registry rpcRegistry; diff --git a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp index 07cd312f..3c91d65a 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.cpp @@ -1,8 +1,8 @@ #include "user_helper.h" -#include "../../../tariffs.h" -#include "../../../admin.h" -#include "base_store.h" +#include "tariffs.h" +#include "admin.h" +#include "store.h" #include "user_ips.h" #include "utils.h" #include "common.h" @@ -129,7 +129,7 @@ structVal["creditexpire"] = xmlrpc_c::value_int(iter->property.creditExpire.Get( bool USER_HELPER::SetUserInfo(const xmlrpc_c::value & info, const ADMIN & admin, const std::string & login, - const BASE_STORE & store, + const STORE & store, TARIFFS * tariffs) { std::map structVal( diff --git a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.h b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.h index ab5fd32f..63d1da07 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/user_helper.h +++ b/projects/stargazer/plugins/configuration/rpcconfig/user_helper.h @@ -5,10 +5,10 @@ #include -#include "../../../users.h" +#include "users.h" class ADMIN; -class BASE_STORE; +class STORE; class TARIFFS; class USER_HELPER @@ -24,7 +24,7 @@ public: bool SetUserInfo(const xmlrpc_c::value & info, const ADMIN & admin, const std::string & login, - const BASE_STORE & store, + const STORE & store, TARIFFS * tariffs); private: user_iter & iter; diff --git a/projects/stargazer/plugins/configuration/rpcconfig/users_methods.h b/projects/stargazer/plugins/configuration/rpcconfig/users_methods.h index 956a2f19..c9e5ace6 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/users_methods.h +++ b/projects/stargazer/plugins/configuration/rpcconfig/users_methods.h @@ -4,12 +4,11 @@ #include #include - class RPC_CONFIG; class ADMINS; class TARIFFS; class USERS; -class BASE_STORE; +class STORE; class IP_MASK; class METHOD_USER_GET : public xmlrpc_c::method { @@ -87,7 +86,7 @@ public: METHOD_USER_CHG(RPC_CONFIG * c, ADMINS * a, TARIFFS * t, - BASE_STORE * s, + STORE * s, USERS * u) : config(c), admins(a), @@ -103,7 +102,7 @@ private: RPC_CONFIG * config; ADMINS * admins; TARIFFS * tariffs; - BASE_STORE * store; + STORE * store; USERS * users; }; @@ -111,7 +110,7 @@ class METHOD_USER_CASH_ADD : public xmlrpc_c::method { public: METHOD_USER_CASH_ADD(RPC_CONFIG * c, ADMINS * a, - BASE_STORE * s, + STORE * s, USERS * u) : config(c), admins(a), @@ -125,7 +124,7 @@ public: private: RPC_CONFIG * config; ADMINS * admins; - BASE_STORE * store; + STORE * store; USERS * users; }; @@ -133,7 +132,7 @@ class METHOD_USER_CASH_SET : public xmlrpc_c::method { public: METHOD_USER_CASH_SET(RPC_CONFIG * c, ADMINS * a, - BASE_STORE * s, + STORE * s, USERS * u) : config(c), admins(a), @@ -147,7 +146,7 @@ public: private: RPC_CONFIG * config; ADMINS * admins; - BASE_STORE * store; + STORE * store; USERS * users; }; @@ -156,7 +155,7 @@ public: METHOD_USER_TARIFF_CHANGE(RPC_CONFIG * c, ADMINS * a, TARIFFS * t, - BASE_STORE * s, + STORE * s, USERS * u) : config(c), admins(a), @@ -172,7 +171,7 @@ private: RPC_CONFIG * config; ADMINS * admins; TARIFFS * tariffs; - BASE_STORE * store; + STORE * store; USERS * users; }; diff --git a/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.cpp b/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.cpp index 1b51bbcb..7f45255d 100644 --- a/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.cpp @@ -1,13 +1,13 @@ #include -#include "base_store.h" -#include "base_settings.h" +#include "store.h" +#include "module_settings.h" #include "common.h" +#include "users.h" +#include "tariffs.h" +#include "admins.h" // TODO: Fix this shit!!! -#include "../../../users.h" -#include "../../../tariffs.h" -#include "../../../admins.h" #include "../../../settings.h" #include "stgconfig.h" diff --git a/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.h b/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.h index 28e52d1c..329a114c 100644 --- a/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.h +++ b/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.h @@ -3,7 +3,7 @@ #include -#include "base_plugin.h" +#include "plugin.h" #include "os_int.h" #include "main_thread.h" @@ -16,40 +16,39 @@ namespace boost { class USERS; class TARIFFS; class ADMINS; -class BASE_STORE; +class STORE; class TRAFFCOUNTER; class SETTINGS; -class STGCONFIG2 : public BASE_PLUGIN -{ +class STGCONFIG2 : public PLUGIN { public: STGCONFIG2(); virtual ~STGCONFIG2(); - void SetUsers(USERS * u) { users = u; }; - void SetTariffs(TARIFFS * t) { tariffs = t; }; - void SetAdmins(ADMINS * a) { admins = a; }; - void SetStore(BASE_STORE * s) { store = s; }; - void SetTraffcounter(TRAFFCOUNTER *) {}; - void SetStgSettings(const SETTINGS * s) { stgSettings = s; }; - void SetSettings(const MODULE_SETTINGS & s) { modSettings = s; }; + void SetUsers(USERS * u) { users = u; } + void SetTariffs(TARIFFS * t) { tariffs = t; } + void SetAdmins(ADMINS * a) { admins = a; } + void SetStore(STORE * s) { store = s; } + void SetTraffcounter(TRAFFCOUNTER *) {} + void SetStgSettings(const SETTINGS * s) { stgSettings = s; } + void SetSettings(const MODULE_SETTINGS & s) { modSettings = s; } int ParseSettings(); int Start(); int Stop(); - int Reload() { return 0; }; + int Reload() { return 0; } bool IsRunning(); - const std::string & GetStrError() const { return errorStr; }; - const std::string GetVersion() const { return PLUGIN_VERSION; }; - uint16_t GetStartPosition() const { return 220; }; - uint16_t GetStopPosition() const { return 220; }; + const std::string & GetStrError() const { return errorStr; } + const std::string GetVersion() const { return PLUGIN_VERSION; } + uint16_t GetStartPosition() const { return 220; } + uint16_t GetStopPosition() const { return 220; } private: USERS * users; TARIFFS * tariffs; ADMINS * admins; - BASE_STORE * store; + STORE * store; const SETTINGS * stgSettings; MODULE_SETTINGS modSettings; @@ -61,6 +60,6 @@ private: }; -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); #endif diff --git a/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp b/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp index 5b94444f..dee6dbb9 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/configproto.cpp @@ -41,7 +41,7 @@ CONFIGPROTO * cp = static_cast(data); if (cp->currParser) { cp->currParser->SetAnswerList(&cp->answerList); - cp->currParser->SetCurrAdmin(cp->currAdmin); + cp->currParser->SetCurrAdmin(*cp->currAdmin); cp->currParser->ParseStart(data, el, attr); } else @@ -49,7 +49,7 @@ else for (unsigned int i = 0; i < cp->dataParser.size(); i++) { cp->dataParser[i]->SetAnswerList(&cp->answerList); - cp->dataParser[i]->SetCurrAdmin(cp->currAdmin); + cp->dataParser[i]->SetCurrAdmin(*cp->currAdmin); cp->dataParser[i]->Reset(); if (cp->dataParser[i]->ParseStart(data, el, attr) == 0) { diff --git a/projects/stargazer/plugins/configuration/sgconfig/configproto.h b/projects/stargazer/plugins/configuration/sgconfig/configproto.h index 96e976c8..06748da8 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/configproto.h +++ b/projects/stargazer/plugins/configuration/sgconfig/configproto.h @@ -33,15 +33,14 @@ #include #include +#include #include "parser.h" -#include "../../../users.h" -#include "../../../admins.h" -#include "../../../tariffs.h" +#include "users.h" +#include "admins.h" +#include "tariffs.h" #include "stg_logger.h" -using namespace std; - #define STG_HEADER "SG04" #define OK_HEADER "OKHD" #define ERR_HEADER "ERHD" @@ -51,8 +50,7 @@ using namespace std; #define ERR_LOGINS "ERLS" //----------------------------------------------------------------------------- -class CONFIGPROTO -{ +class CONFIGPROTO { public: CONFIGPROTO(); ~CONFIGPROTO(); @@ -61,12 +59,12 @@ public: void SetAdmins(ADMINS * a); void SetUsers(USERS * u); void SetTariffs(TARIFFS * t); - void SetStore(BASE_STORE * s); + void SetStore(STORE * s); void SetStgSettings(const SETTINGS * s); uint32_t GetAdminIP() const; int Prepare(); int Stop(); - const string & GetStrError() const; + const std::string & GetStrError() const; static void * Run(void * a); private: @@ -83,18 +81,18 @@ private: int ParseCommand(); - list answerList; - list requestList; - uint32_t adminIP; - string adminLogin; - uint16_t port; - pthread_t thrReciveSendConf; - bool nonstop; - int state; - ADMIN currAdmin; - STG_LOGGER & WriteServLog; + std::list answerList; + std::list requestList; + uint32_t adminIP; + std::string adminLogin; + uint16_t port; + pthread_t thrReciveSendConf; + bool nonstop; + int state; + ADMIN * currAdmin; + STG_LOGGER & WriteServLog; - int listenSocket; + int listenSocket; PARSER_GET_SERVER_INFO parserGetServInfo; @@ -119,15 +117,14 @@ private: ADMINS * admins; BASE_PARSER * currParser; - vector dataParser; + vector dataParser; XML_Parser xmlParser; - string errorStr; + std::string errorStr; friend void ParseXMLStart(void *data, const char *el, const char **attr); friend void ParseXMLEnd(void *data, const char *el); }; //----------------------------------------------------------------------------- #endif //CONFIGPROTO_H - diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser.cpp index 4658d56f..05c16b10 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser.cpp @@ -1,15 +1,19 @@ -#include -#include #include #include #include #include #include #include + +#include +#include #include #include "parser.h" #include "version.h" +#include "tariffs.h" +#include "../../../settings.h" +#include "../../../user_property.h" #define UNAME_LEN (256) //----------------------------------------------------------------------------- @@ -127,7 +131,7 @@ void PARSER_GET_USER::CreateAnswer() string s; string enc; -user_iter u; +USER_PTR u; answerList->erase(answerList->begin(), answerList->end()); @@ -144,63 +148,63 @@ answerList->push_back(s); s = "GetLogin() + "\"/>"; answerList->push_back(s); -if (currAdmin.GetPriv()->userConf || currAdmin.GetPriv()->userPasswd) - s = "property.password.Get() + "\" />"; +if (currAdmin->GetPriv()->userConf || currAdmin->GetPriv()->userPasswd) + s = "GetProperty().password.Get() + "\" />"; else s = ""; answerList->push_back(s); -strprintf(&s, "", u->property.cash.Get()); +strprintf(&s, "", u->GetProperty().cash.Get()); answerList->push_back(s); -strprintf(&s, "", u->property.freeMb.Get()); +strprintf(&s, "", u->GetProperty().freeMb.Get()); answerList->push_back(s); -strprintf(&s, "", u->property.credit.Get()); +strprintf(&s, "", u->GetProperty().credit.Get()); answerList->push_back(s); -if (u->property.nextTariff.Get() != "") +if (u->GetProperty().nextTariff.Get() != "") { strprintf(&s, "", - u->property.tariffName.Get().c_str(), - u->property.nextTariff.Get().c_str()); + u->GetProperty().tariffName.Get().c_str(), + u->GetProperty().nextTariff.Get().c_str()); } else { strprintf(&s, "", - u->property.tariffName.Get().c_str()); + u->GetProperty().tariffName.Get().c_str()); } answerList->push_back(s); -Encode12str(enc, u->property.note); +Encode12str(enc, u->GetProperty().note); s = ""; answerList->push_back(s); -Encode12str(enc, u->property.phone); +Encode12str(enc, u->GetProperty().phone); s = ""; answerList->push_back(s); -Encode12str(enc, u->property.address); +Encode12str(enc, u->GetProperty().address); s = "
"; answerList->push_back(s); -Encode12str(enc, u->property.email); +Encode12str(enc, u->GetProperty().email); s = ""; answerList->push_back(s); vector *> userdata; -userdata.push_back(u->property.userdata0.GetPointer()); -userdata.push_back(u->property.userdata1.GetPointer()); -userdata.push_back(u->property.userdata2.GetPointer()); -userdata.push_back(u->property.userdata3.GetPointer()); -userdata.push_back(u->property.userdata4.GetPointer()); -userdata.push_back(u->property.userdata5.GetPointer()); -userdata.push_back(u->property.userdata6.GetPointer()); -userdata.push_back(u->property.userdata7.GetPointer()); -userdata.push_back(u->property.userdata8.GetPointer()); -userdata.push_back(u->property.userdata9.GetPointer()); +userdata.push_back(u->GetProperty().userdata0.GetPointer()); +userdata.push_back(u->GetProperty().userdata1.GetPointer()); +userdata.push_back(u->GetProperty().userdata2.GetPointer()); +userdata.push_back(u->GetProperty().userdata3.GetPointer()); +userdata.push_back(u->GetProperty().userdata4.GetPointer()); +userdata.push_back(u->GetProperty().userdata5.GetPointer()); +userdata.push_back(u->GetProperty().userdata6.GetPointer()); +userdata.push_back(u->GetProperty().userdata7.GetPointer()); +userdata.push_back(u->GetProperty().userdata8.GetPointer()); +userdata.push_back(u->GetProperty().userdata9.GetPointer()); string tmpI; for (unsigned i = 0; i < userdata.size(); i++) @@ -210,18 +214,18 @@ for (unsigned i = 0; i < userdata.size(); i++) answerList->push_back(s); } -Encode12str(enc, u->property.realName); +Encode12str(enc, u->GetProperty().realName); s = ""; answerList->push_back(s); -Encode12str(enc, u->property.group); +Encode12str(enc, u->GetProperty().group); s = ""; answerList->push_back(s); strprintf(&s, "", u->GetConnected()); answerList->push_back(s); -strprintf(&s, "", u->property.alwaysOnline.Get()); +strprintf(&s, "", u->GetProperty().alwaysOnline.Get()); answerList->push_back(s); strprintf(&s, "", inet_ntostring(u->GetCurrIP()).c_str()); @@ -231,7 +235,7 @@ strprintf(&s, "", u->GetPingTime()); answerList->push_back(s); stringstream sstr; -sstr << u->property.ips.Get(); +sstr << u->GetProperty().ips.Get(); strprintf(&s, "", sstr.str().c_str()); answerList->push_back(s); @@ -241,8 +245,8 @@ char st[50]; sprintf(ss, "property.down.Get(); -upload = u->property.up.Get(); +download = u->GetProperty().down.Get(); +upload = u->GetProperty().up.Get(); for (int j = 0; j < DIR_NUM; j++) { @@ -265,25 +269,25 @@ strcat(ss, " />"); answerList->push_back(ss); delete[] ss; -strprintf(&s, "", u->property.disabled.Get()); +strprintf(&s, "", u->GetProperty().disabled.Get()); answerList->push_back(s); -strprintf(&s, "", u->property.disabledDetailStat.Get()); +strprintf(&s, "", u->GetProperty().disabledDetailStat.Get()); answerList->push_back(s); -strprintf(&s, "", u->property.passive.Get()); +strprintf(&s, "", u->GetProperty().passive.Get()); answerList->push_back(s); -strprintf(&s, "", u->property.lastCashAdd.Get()); +strprintf(&s, "", u->GetProperty().lastCashAdd.Get()); answerList->push_back(s); -strprintf(&s, "", u->property.lastCashAddTime.Get()); +strprintf(&s, "", u->GetProperty().lastCashAddTime.Get()); answerList->push_back(s); -strprintf(&s, "", u->property.lastActivityTime.Get()); +strprintf(&s, "", u->GetProperty().lastActivityTime.Get()); answerList->push_back(s); -strprintf(&s, "", u->property.creditExpire.Get()); +strprintf(&s, "", u->GetProperty().creditExpire.Get()); answerList->push_back(s); strprintf(&s, ""); @@ -359,7 +363,7 @@ string userFinish; string enc; -user_iter u; +USER_PTR u; int h = users->OpenSearch(); if (!h) @@ -385,96 +389,96 @@ while (1) userStart = "GetLogin() + "\">"; middle = ""; - if (u->property.password.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().password.ModificationTime() > lastUserUpdateTime) { - if (currAdmin.GetPriv()->userConf || currAdmin.GetPriv()->userPasswd) - s = "property.password.Get() + "\" />"; + if (currAdmin->GetPriv()->userConf || currAdmin->GetPriv()->userPasswd) + s = "GetProperty().password.Get() + "\" />"; else s = ""; middle += s; } - if (u->property.cash.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().cash.ModificationTime() > lastUserUpdateTime) { - strprintf(&s, "", u->property.cash.Get()); + strprintf(&s, "", u->GetProperty().cash.Get()); middle += s; - //printfd(__FILE__, "cash value=\"%f\"\n", u->property.cash.Get()); + //printfd(__FILE__, "cash value=\"%f\"\n", u->GetProperty().cash.Get()); } - if (u->property.freeMb.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().freeMb.ModificationTime() > lastUserUpdateTime) { - strprintf(&s, "", u->property.freeMb.Get()); + strprintf(&s, "", u->GetProperty().freeMb.Get()); middle += s; } - if (u->property.credit.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().credit.ModificationTime() > lastUserUpdateTime) { - strprintf(&s, "", u->property.credit.Get()); + strprintf(&s, "", u->GetProperty().credit.Get()); middle += s; } - if (u->property.nextTariff.Get() != "") + if (u->GetProperty().nextTariff.Get() != "") { - if (u->property.tariffName.ModificationTime() > lastUserUpdateTime - || u->property.nextTariff.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().tariffName.ModificationTime() > lastUserUpdateTime + || u->GetProperty().nextTariff.ModificationTime() > lastUserUpdateTime) { strprintf(&s, "", - u->property.tariffName.Get().c_str(), - u->property.nextTariff.Get().c_str()); + u->GetProperty().tariffName.Get().c_str(), + u->GetProperty().nextTariff.Get().c_str()); middle += s; } } else { - if (u->property.tariffName.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().tariffName.ModificationTime() > lastUserUpdateTime) { strprintf(&s, "", - u->property.tariffName.Get().c_str()); + u->GetProperty().tariffName.Get().c_str()); middle += s; } } - if (u->property.note.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().note.ModificationTime() > lastUserUpdateTime) { - Encode12str(enc, u->property.note); + Encode12str(enc, u->GetProperty().note); strprintf(&s, "", enc.c_str()); middle += s; } - if (u->property.phone.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().phone.ModificationTime() > lastUserUpdateTime) { - Encode12str(enc, u->property.phone); + Encode12str(enc, u->GetProperty().phone); strprintf(&s, "", enc.c_str()); middle += s; } - if (u->property.address.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().address.ModificationTime() > lastUserUpdateTime) { - Encode12str(enc, u->property.address); + Encode12str(enc, u->GetProperty().address); strprintf(&s, "
", enc.c_str()); middle += s; } - if (u->property.email.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().email.ModificationTime() > lastUserUpdateTime) { - Encode12str(enc, u->property.email); + Encode12str(enc, u->GetProperty().email); strprintf(&s, "", enc.c_str()); middle += s; } vector *> userdata; - userdata.push_back(u->property.userdata0.GetPointer()); - userdata.push_back(u->property.userdata1.GetPointer()); - userdata.push_back(u->property.userdata2.GetPointer()); - userdata.push_back(u->property.userdata3.GetPointer()); - userdata.push_back(u->property.userdata4.GetPointer()); - userdata.push_back(u->property.userdata5.GetPointer()); - userdata.push_back(u->property.userdata6.GetPointer()); - userdata.push_back(u->property.userdata7.GetPointer()); - userdata.push_back(u->property.userdata8.GetPointer()); - userdata.push_back(u->property.userdata9.GetPointer()); + userdata.push_back(u->GetProperty().userdata0.GetPointer()); + userdata.push_back(u->GetProperty().userdata1.GetPointer()); + userdata.push_back(u->GetProperty().userdata2.GetPointer()); + userdata.push_back(u->GetProperty().userdata3.GetPointer()); + userdata.push_back(u->GetProperty().userdata4.GetPointer()); + userdata.push_back(u->GetProperty().userdata5.GetPointer()); + userdata.push_back(u->GetProperty().userdata6.GetPointer()); + userdata.push_back(u->GetProperty().userdata7.GetPointer()); + userdata.push_back(u->GetProperty().userdata8.GetPointer()); + userdata.push_back(u->GetProperty().userdata9.GetPointer()); string tmpI; for (unsigned i = 0; i < userdata.size(); i++) @@ -487,23 +491,23 @@ while (1) } } - if (u->property.realName.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().realName.ModificationTime() > lastUserUpdateTime) { - Encode12str(enc, u->property.realName); + Encode12str(enc, u->GetProperty().realName); strprintf(&s, "", enc.c_str()); middle += s; } - if (u->property.group.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().group.ModificationTime() > lastUserUpdateTime) { - Encode12str(enc, u->property.group); + Encode12str(enc, u->GetProperty().group); strprintf(&s, "", enc.c_str()); middle += s; } - if (u->property.alwaysOnline.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().alwaysOnline.ModificationTime() > lastUserUpdateTime) { - strprintf(&s, "", u->property.alwaysOnline.Get()); + strprintf(&s, "", u->GetProperty().alwaysOnline.Get()); middle += s; } @@ -526,10 +530,10 @@ while (1) middle += s; } - if (u->property.ips.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().ips.ModificationTime() > lastUserUpdateTime) { stringstream sstr; - sstr << u->property.ips.Get(); + sstr << u->GetProperty().ips.Get(); strprintf(&s, "", sstr.str().c_str()); middle += s; } @@ -538,11 +542,11 @@ while (1) traffStart = "property.down.Get(); - upload = u->property.up.Get(); + download = u->GetProperty().down.Get(); + upload = u->GetProperty().up.Get(); traffMiddle = ""; - if (u->property.up.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().up.ModificationTime() > lastUserUpdateTime) { for (int j = 0; j < DIR_NUM; j++) { @@ -553,7 +557,7 @@ while (1) } } - if (u->property.down.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().down.ModificationTime() > lastUserUpdateTime) { for (int j = 0; j < DIR_NUM; j++) { @@ -571,48 +575,48 @@ while (1) middle += traffFinish; } - if (u->property.disabled.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().disabled.ModificationTime() > lastUserUpdateTime) { - strprintf(&s, "", u->property.disabled.Get()); + strprintf(&s, "", u->GetProperty().disabled.Get()); middle += s; } - if (u->property.disabledDetailStat.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().disabledDetailStat.ModificationTime() > lastUserUpdateTime) { - strprintf(&s, "", u->property.disabledDetailStat.Get()); + strprintf(&s, "", u->GetProperty().disabledDetailStat.Get()); middle += s; } //printfd(__FILE__, ">>>>> %s\n", s.c_str()); - if (u->property.passive.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().passive.ModificationTime() > lastUserUpdateTime) { - strprintf(&s, "", u->property.passive.Get()); + strprintf(&s, "", u->GetProperty().passive.Get()); middle += s; } - if (u->property.lastCashAdd.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().lastCashAdd.ModificationTime() > lastUserUpdateTime) { - strprintf(&s, "", u->property.lastCashAdd.Get()); + strprintf(&s, "", u->GetProperty().lastCashAdd.Get()); middle += s; } - if (u->property.lastCashAddTime.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().lastCashAddTime.ModificationTime() > lastUserUpdateTime) { - strprintf(&s, "", u->property.lastCashAddTime.Get()); + strprintf(&s, "", u->GetProperty().lastCashAddTime.Get()); middle += s; } - if (u->property.lastActivityTime.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().lastActivityTime.ModificationTime() > lastUserUpdateTime) { - strprintf(&s, "", u->property.lastActivityTime.Get()); + strprintf(&s, "", u->GetProperty().lastActivityTime.Get()); middle += s; } - if (u->property.creditExpire.ModificationTime() > lastUserUpdateTime) + if (u->GetProperty().creditExpire.ModificationTime() > lastUserUpdateTime) { - strprintf(&s, "", u->property.creditExpire.Get()); + strprintf(&s, "", u->GetProperty().creditExpire.Get()); middle += s; } @@ -705,10 +709,10 @@ else //----------------------------------------------------------------------------- int PARSER_ADD_USER::CheckUserData() { -user_iter u; +USER_PTR u; if (users->FindByName(login, &u)) { - return users->Add(login, currAdmin); + return users->Add(login, *currAdmin); } return -1; } @@ -1005,7 +1009,7 @@ switch (res) //----------------------------------------------------------------------------- int PARSER_CHG_USER::AplayChanges() { -user_iter u; +USER_PTR u; res = 0; if (users->FindByName(login, &u)) @@ -1015,97 +1019,97 @@ if (users->FindByName(login, &u)) } if (!ucr->ips.res_empty()) - if (!u->property.ips.Set(ucr->ips.const_data(), currAdmin, login, store)) + if (!u->GetProperty().ips.Set(ucr->ips.const_data(), *currAdmin, login, store)) res = -1; if (!ucr->address.res_empty()) - if (!u->property.address.Set(ucr->address.const_data(), currAdmin, login, store)) + if (!u->GetProperty().address.Set(ucr->address.const_data(), *currAdmin, login, store)) res = -1; if (!ucr->alwaysOnline.res_empty()) - if (!u->property.alwaysOnline.Set(ucr->alwaysOnline.const_data(), - currAdmin, login, store)) + if (!u->GetProperty().alwaysOnline.Set(ucr->alwaysOnline.const_data(), + *currAdmin, login, store)) res = -1; if (!ucr->creditExpire.res_empty()) - if (!u->property.creditExpire.Set(ucr->creditExpire.const_data(), - currAdmin, login, store)) + if (!u->GetProperty().creditExpire.Set(ucr->creditExpire.const_data(), + *currAdmin, login, store)) res = -1; if (!ucr->credit.res_empty()) - if (!u->property.credit.Set(ucr->credit.const_data(), currAdmin, login, store)) + if (!u->GetProperty().credit.Set(ucr->credit.const_data(), *currAdmin, login, store)) res = -1; if (!usr->freeMb.res_empty()) - if (!u->property.freeMb.Set(usr->freeMb.const_data(), currAdmin, login, store)) + if (!u->GetProperty().freeMb.Set(usr->freeMb.const_data(), *currAdmin, login, store)) res = -1; if (!ucr->disabled.res_empty()) - if (!u->property.disabled.Set(ucr->disabled.const_data(), currAdmin, login, store)) + if (!u->GetProperty().disabled.Set(ucr->disabled.const_data(), *currAdmin, login, store)) res = -1; if (!ucr->disabledDetailStat.res_empty()) - if (!u->property.disabledDetailStat.Set(ucr->disabledDetailStat.const_data(), currAdmin, login, store)) + if (!u->GetProperty().disabledDetailStat.Set(ucr->disabledDetailStat.const_data(), *currAdmin, login, store)) res = -1; if (!ucr->email.res_empty()) - if (!u->property.email.Set(ucr->email.const_data(), currAdmin, login, store)) + if (!u->GetProperty().email.Set(ucr->email.const_data(), *currAdmin, login, store)) res = -1; if (!ucr->group.res_empty()) - if (!u->property.group.Set(ucr->group.const_data(), currAdmin, login, store)) + if (!u->GetProperty().group.Set(ucr->group.const_data(), *currAdmin, login, store)) res = -1; if (!ucr->note.res_empty()) - if (!u->property.note.Set(ucr->note.const_data(), currAdmin, login, store)) + if (!u->GetProperty().note.Set(ucr->note.const_data(), *currAdmin, login, store)) res = -1; vector *> userdata; -userdata.push_back(u->property.userdata0.GetPointer()); -userdata.push_back(u->property.userdata1.GetPointer()); -userdata.push_back(u->property.userdata2.GetPointer()); -userdata.push_back(u->property.userdata3.GetPointer()); -userdata.push_back(u->property.userdata4.GetPointer()); -userdata.push_back(u->property.userdata5.GetPointer()); -userdata.push_back(u->property.userdata6.GetPointer()); -userdata.push_back(u->property.userdata7.GetPointer()); -userdata.push_back(u->property.userdata8.GetPointer()); -userdata.push_back(u->property.userdata9.GetPointer()); +userdata.push_back(u->GetProperty().userdata0.GetPointer()); +userdata.push_back(u->GetProperty().userdata1.GetPointer()); +userdata.push_back(u->GetProperty().userdata2.GetPointer()); +userdata.push_back(u->GetProperty().userdata3.GetPointer()); +userdata.push_back(u->GetProperty().userdata4.GetPointer()); +userdata.push_back(u->GetProperty().userdata5.GetPointer()); +userdata.push_back(u->GetProperty().userdata6.GetPointer()); +userdata.push_back(u->GetProperty().userdata7.GetPointer()); +userdata.push_back(u->GetProperty().userdata8.GetPointer()); +userdata.push_back(u->GetProperty().userdata9.GetPointer()); for (int i = 0; i < (int)userdata.size(); i++) { if (!ucr->userdata[i].res_empty()) { - if(!userdata[i]->Set(ucr->userdata[i].const_data(), currAdmin, login, store)) + if(!userdata[i]->Set(ucr->userdata[i].const_data(), *currAdmin, login, store)) res = -1; } } if (!ucr->passive.res_empty()) - if (!u->property.passive.Set(ucr->passive.const_data(), currAdmin, login, store)) + if (!u->GetProperty().passive.Set(ucr->passive.const_data(), *currAdmin, login, store)) res = -1; if (!ucr->password.res_empty()) - if (!u->property.password.Set(ucr->password.const_data(), currAdmin, login, store)) + if (!u->GetProperty().password.Set(ucr->password.const_data(), *currAdmin, login, store)) res = -1; if (!ucr->phone.res_empty()) - if (!u->property.phone.Set(ucr->phone.const_data(), currAdmin, login, store)) + if (!u->GetProperty().phone.Set(ucr->phone.const_data(), *currAdmin, login, store)) res = -1; if (!ucr->realName.res_empty()) - if (!u->property.realName.Set(ucr->realName.const_data(), currAdmin, login, store)) + if (!u->GetProperty().realName.Set(ucr->realName.const_data(), *currAdmin, login, store)) res = -1; if (!usr->cash.res_empty()) { - //if (currAdmin->GetPriv()->userCash) + //if (*currAdmin->GetPriv()->userCash) { if (cashMustBeAdded) { - if (!u->property.cash.Set(usr->cash.const_data() + u->property.cash, - currAdmin, + if (!u->GetProperty().cash.Set(usr->cash.const_data() + u->GetProperty().cash, + *currAdmin, login, store, cashMsg)) @@ -1113,7 +1117,7 @@ if (!usr->cash.res_empty()) } else { - if (!u->property.cash.Set(usr->cash.const_data(), currAdmin, login, store, cashMsg)) + if (!u->GetProperty().cash.Set(usr->cash.const_data(), *currAdmin, login, store, cashMsg)) res = -1; } } @@ -1124,7 +1128,7 @@ if (!ucr->tariffName.res_empty()) { if (tariffs->FindByName(ucr->tariffName.const_data())) { - if (!u->property.tariffName.Set(ucr->tariffName.const_data(), currAdmin, login, store)) + if (!u->GetProperty().tariffName.Set(ucr->tariffName.const_data(), *currAdmin, login, store)) res = -1; u->ResetNextTariff(); } @@ -1139,7 +1143,7 @@ if (!ucr->nextTariff.res_empty()) { if (tariffs->FindByName(ucr->nextTariff.const_data())) { - if (!u->property.nextTariff.Set(ucr->nextTariff.const_data(), currAdmin, login, store)) + if (!u->GetProperty().nextTariff.Set(ucr->nextTariff.const_data(), *currAdmin, login, store)) res = -1; } else @@ -1149,8 +1153,8 @@ if (!ucr->nextTariff.res_empty()) } } -DIR_TRAFF up = u->property.up; -DIR_TRAFF down = u->property.down; +DIR_TRAFF up = u->GetProperty().up; +DIR_TRAFF down = u->GetProperty().down; int upCount = 0; int downCount = 0; for (int i = 0; i < DIR_NUM; i++) @@ -1168,20 +1172,20 @@ for (int i = 0; i < DIR_NUM; i++) } if (upCount) - if (!u->property.up.Set(up, currAdmin, login, store)) + if (!u->GetProperty().up.Set(up, *currAdmin, login, store)) res = -1; if (downCount) - if (!u->property.down.Set(down, currAdmin, login, store)) + if (!u->GetProperty().down.Set(down, *currAdmin, login, store)) res = -1; /*if (!usr->down.res_empty()) { - u->property.down.Set(usr->down.const_data(), currAdmin, login, store); + u->GetProperty().down.Set(usr->down.const_data(), *currAdmin, login, store); } if (!usr->up.res_empty()) { - u->property.up.Set(usr->up.const_data(), currAdmin, login, store); + u->GetProperty().up.Set(usr->up.const_data(), *currAdmin, login, store); }*/ u->WriteConf(); @@ -1371,7 +1375,7 @@ int PARSER_DEL_USER::ParseEnd(void *, const char *el) if (strcasecmp(el, "DelUser") == 0) { if (!res) - users->Del(u->GetLogin(), currAdmin); + users->Del(u->GetLogin(), *currAdmin); return 0; } @@ -1414,7 +1418,7 @@ if (strcasecmp(el, "CheckUser") == 0) return 0; } - user_iter user; + USER_PTR user; if (users->FindByName(attr[1], &user)) { result = false; @@ -1423,7 +1427,7 @@ if (strcasecmp(el, "CheckUser") == 0) return 0; } - if (strcmp(user->property.password.Get().c_str(), attr[3])) + if (strcmp(user->GetProperty().password.Get().c_str(), attr[3])) { result = false; CreateAnswer(); diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser.h b/projects/stargazer/plugins/configuration/sgconfig/parser.h index b48d31cc..60e618cb 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser.h +++ b/projects/stargazer/plugins/configuration/sgconfig/parser.h @@ -9,19 +9,21 @@ #include #include +#include #include "resetable.h" #include "stg_const.h" -#include "base_store.h" -#include "../../../admins.h" -#include "../../../users.h" +#include "store.h" +#include "admins.h" +#include "admin.h" +#include "users.h" #include "stg_message.h" -using namespace std; +class TARIFFS; +class SETTINGS; //----------------------------------------------------------------------------- -class BASE_PARSER -{ +class BASE_PARSER { public: BASE_PARSER() : admins(NULL), @@ -31,55 +33,52 @@ public: settings(NULL), currAdmin(), depth(0) - { }; - virtual ~BASE_PARSER() {}; + { } + virtual ~BASE_PARSER() {} virtual int ParseStart(void *data, const char *el, const char **attr) = 0; virtual int ParseEnd(void *data, const char *el) = 0; virtual void CreateAnswer() = 0; - virtual void SetAnswerList(list * ansList) { answerList = ansList; }; + virtual void SetAnswerList(std::list * ansList) { answerList = ansList; } - virtual void SetUsers(USERS * u) { users = u; }; - virtual void SetAdmins(ADMINS * a) { admins = a; }; - virtual void SetTariffs(TARIFFS * t) { tariffs = t; }; - virtual void SetStore(BASE_STORE * s) { store = s; }; - virtual void SetStgSettings(const SETTINGS * s) { settings = s; }; + virtual void SetUsers(USERS * u) { users = u; } + virtual void SetAdmins(ADMINS * a) { admins = a; } + virtual void SetTariffs(TARIFFS * t) { tariffs = t; } + virtual void SetStore(STORE * s) { store = s; } + virtual void SetStgSettings(const SETTINGS * s) { settings = s; } - virtual void SetCurrAdmin(const ADMIN & cua) { currAdmin = cua; }; - virtual string & GetStrError(){return strError;}; - virtual void Reset(){ answerList->clear(); depth = 0; }; + virtual void SetCurrAdmin(ADMIN & cua) { currAdmin = &cua; } + virtual std::string & GetStrError() { return strError; } + virtual void Reset() { answerList->clear(); depth = 0; } protected: - string strError; + std::string strError; ADMINS * admins; USERS * users; TARIFFS * tariffs; - BASE_STORE * store; + STORE * store; const SETTINGS * settings; - ADMIN currAdmin; + ADMIN * currAdmin; int depth; - list * answerList; + std::list * answerList; }; //----------------------------------------------------------------------------- -class PARSER_GET_ADMINS: public BASE_PARSER -{ +class PARSER_GET_ADMINS: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); }; //----------------------------------------------------------------------------- -class PARSER_ADD_ADMIN: public BASE_PARSER -{ +class PARSER_ADD_ADMIN: public BASE_PARSER { public: PARSER_ADD_ADMIN() : BASE_PARSER() {} int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); private: - string adminToAdd; + std::string adminToAdd; }; //----------------------------------------------------------------------------- -class PARSER_DEL_ADMIN: public BASE_PARSER -{ +class PARSER_DEL_ADMIN: public BASE_PARSER { public: PARSER_DEL_ADMIN() : BASE_PARSER() {} int ParseStart(void *data, const char *el, const char **attr); @@ -87,33 +86,29 @@ public: void CreateAnswer(); private: int CheckAttr(const char **attr); - string adminToDel; + std::string adminToDel; }; //----------------------------------------------------------------------------- -class PARSER_CHG_ADMIN: public BASE_PARSER -{ +class PARSER_CHG_ADMIN: public BASE_PARSER { public: PARSER_CHG_ADMIN() : BASE_PARSER() {} int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); private: - RESETABLE login; - RESETABLE password; - RESETABLE privAsString; + RESETABLE login; + RESETABLE password; + RESETABLE privAsString; }; //----------------------------------------------------------------------------- -class PARSER_GET_SERVER_INFO: public BASE_PARSER -{ +class PARSER_GET_SERVER_INFO: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); }; - //----------------------------------------------------------------------------- -class PARSER_GET_USER: public BASE_PARSER -{ +class PARSER_GET_USER: public BASE_PARSER { public: PARSER_GET_USER(); ~PARSER_GET_USER(){}; @@ -121,11 +116,10 @@ public: int ParseEnd(void *data, const char *el); void CreateAnswer(); private: - string login; + std::string login; }; //----------------------------------------------------------------------------- -class PARSER_GET_USERS: public BASE_PARSER -{ +class PARSER_GET_USERS: public BASE_PARSER { public: PARSER_GET_USERS(); int ParseStart(void *data, const char *el, const char **attr); @@ -136,68 +130,62 @@ private: bool lastUpdateFound; }; //----------------------------------------------------------------------------- -class PARSER_GET_TARIFFS: public BASE_PARSER -{ +class PARSER_GET_TARIFFS: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); }; //----------------------------------------------------------------------------- -class PARSER_ADD_TARIFF: public BASE_PARSER -{ +class PARSER_ADD_TARIFF: public BASE_PARSER { public: PARSER_ADD_TARIFF() : BASE_PARSER() {} int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); private: - string tariffToAdd; + std::string tariffToAdd; }; //----------------------------------------------------------------------------- -class PARSER_DEL_TARIFF: public BASE_PARSER -{ +class PARSER_DEL_TARIFF: public BASE_PARSER { public: PARSER_DEL_TARIFF() : BASE_PARSER() {} int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); private: - string tariffToDel; + std::string tariffToDel; }; //----------------------------------------------------------------------------- -class PARSER_CHG_TARIFF: public BASE_PARSER -{ +class PARSER_CHG_TARIFF: public BASE_PARSER { public: PARSER_CHG_TARIFF() : BASE_PARSER() {} int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); private: - int ParseSlashedIntParams(int paramsNum, const string & s, int * params); - int ParseSlashedDoubleParams(int paramsNum, const string & s, double * params); + int ParseSlashedIntParams(int paramsNum, const std::string & s, int * params); + int ParseSlashedDoubleParams(int paramsNum, const std::string & s, double * params); int CheckTariffData(); int AplayChanges(); TARIFF_DATA_RES td; }; //-----------------------------------------------------------------------------/ -class PARSER_ADD_USER: public BASE_PARSER -{ +class PARSER_ADD_USER: public BASE_PARSER { public: PARSER_ADD_USER(); - ~PARSER_ADD_USER(){}; + ~PARSER_ADD_USER() {} int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); void Reset(); private: int CheckUserData(); - string login; + std::string login; }; //----------------------------------------------------------------------------- -class PARSER_CHG_USER: public BASE_PARSER -{ +class PARSER_CHG_USER: public BASE_PARSER { public: PARSER_CHG_USER(); ~PARSER_CHG_USER(); @@ -206,21 +194,20 @@ public: void CreateAnswer(); void Reset(); private: - string EncChar2String(const char *); + std::string EncChar2String(const char *); int AplayChanges(); USER_STAT_RES * usr; USER_CONF_RES * ucr; RESETABLE * upr; RESETABLE * downr; - string cashMsg; - string login; + std::string cashMsg; + std::string login; bool cashMustBeAdded; int res; }; //----------------------------------------------------------------------------- -class PARSER_DEL_USER: public BASE_PARSER -{ +class PARSER_DEL_USER: public BASE_PARSER { public: PARSER_DEL_USER() : BASE_PARSER(), res(0) {} int ParseStart(void *data, const char *el, const char **attr); @@ -229,11 +216,10 @@ public: private: int res; - user_iter u; + USER * u; }; //----------------------------------------------------------------------------- -class PARSER_CHECK_USER: public BASE_PARSER -{ +class PARSER_CHECK_USER: public BASE_PARSER { public: PARSER_CHECK_USER() : BASE_PARSER(), result(false) {} int ParseStart(void *data, const char *el, const char **attr); @@ -243,8 +229,7 @@ private: bool result; }; //----------------------------------------------------------------------------- -class PARSER_SEND_MESSAGE: public BASE_PARSER -{ +class PARSER_SEND_MESSAGE: public BASE_PARSER { public: PARSER_SEND_MESSAGE() : BASE_PARSER(), result(0) {} int ParseStart(void *data, const char *el, const char **attr); @@ -254,10 +239,10 @@ private: int ParseLogins(const char * logins); enum {res_ok, res_params_error, res_unknown}; - vector logins; + std::vector logins; int result; STG_MSG msg; - user_iter u; + USER * u; }; //----------------------------------------------------------------------------- #endif //PARSER_H diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp index 160acc83..f232fb23 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp @@ -27,7 +27,7 @@ return -1; //----------------------------------------------------------------------------- void PARSER_GET_ADMINS::CreateAnswer() { -const PRIV * priv = currAdmin.GetPriv(); +const PRIV * priv = currAdmin->GetPriv(); if (!priv->adminChg) { //answerList->clear(); @@ -93,7 +93,7 @@ void PARSER_DEL_ADMIN::CreateAnswer() //answerList->clear(); answerList->erase(answerList->begin(), answerList->end()); -if (admins->Del(adminToDel, currAdmin) == 0) +if (admins->Del(adminToDel, *currAdmin) == 0) { answerList->push_back(""); } @@ -149,7 +149,7 @@ void PARSER_ADD_ADMIN::CreateAnswer() //answerList->clear(); answerList->erase(answerList->begin(), answerList->end()); -if (admins->Add(adminToAdd, currAdmin) == 0) +if (admins->Add(adminToAdd, *currAdmin) == 0) { answerList->push_back(""); } @@ -241,7 +241,7 @@ if (!login.res_empty()) conf.priv.tariffChg = (p & 0x3000) >> 0x0C; // 1000+2000 } - if (admins->Change(conf, currAdmin) != 0) + if (admins->Change(conf, *currAdmin) != 0) { strprintf(&s, "", admins->GetStrError().c_str()); answerList->push_back(s); diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp index e3b26520..e2daa336 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp @@ -2,6 +2,7 @@ #include #include "parser.h" +#include "tariffs.h" const int pt_mega = 1024 * 1024; //----------------------------------------------------------------------------- @@ -179,7 +180,7 @@ void PARSER_ADD_TARIFF::CreateAnswer() //answerList->clear(); answerList->erase(answerList->begin(), answerList->end()); -if (tariffs->Add(tariffToAdd, currAdmin) == 0) +if (tariffs->Add(tariffToAdd, *currAdmin) == 0) { answerList->push_back(""); } @@ -227,7 +228,7 @@ if (users->TariffInUse(tariffToDel)) return; } -if (tariffs->Del(tariffToDel, currAdmin) == 0) +if (tariffs->Del(tariffToDel, *currAdmin) == 0) { answerList->push_back(""); } @@ -474,7 +475,7 @@ answerList->erase(answerList->begin(), answerList->end()); if (!td.tariffConf.name.data().empty()) { TARIFF_DATA tariffData = td.GetData(); - if (tariffs->Chg(tariffData, currAdmin) == 0) + if (tariffs->Chg(tariffData, *currAdmin) == 0) { answerList->push_back(""); return; diff --git a/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp b/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp index a3957f36..bc586d2d 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp @@ -338,7 +338,7 @@ if (admins->FindAdmin(login, &currAdmin)) state = confHdr; return ENODATA; } -currAdmin.SetAdminIP(adminIP); +currAdmin->SetIP(adminIP); adminLogin = login; state = confLoginCipher; return 0; @@ -383,13 +383,13 @@ while (total < ADM_LOGIN_LEN) total += ret; } -if (currAdmin.GetLogin() == "") +if (currAdmin->GetLogin() == "") { state = confHdr; return ENODATA; } -EnDecodeInit(currAdmin.GetPassword().c_str(), ADM_PASSWD_LEN, &ctx); +EnDecodeInit(currAdmin->GetPassword().c_str(), ADM_PASSWD_LEN, &ctx); for (int i = 0; i < ADM_LOGIN_LEN/8; i++) { @@ -403,7 +403,7 @@ if (currAdmin == admins->GetNoAdmin()) return 0; } -if (strncmp(currAdmin.GetLogin().c_str(), login, ADM_LOGIN_LEN) != 0) +if (strncmp(currAdmin->GetLogin().c_str(), login, ADM_LOGIN_LEN) != 0) { state = confHdr; return ENODATA; @@ -449,7 +449,7 @@ buffer[8] = 0; requestList.clear(); BLOWFISH_CTX ctx; -EnDecodeInit(currAdmin.GetPassword().c_str(), ADM_PASSWD_LEN, &ctx); +EnDecodeInit(currAdmin->GetPassword().c_str(), ADM_PASSWD_LEN, &ctx); while (1) { @@ -506,7 +506,7 @@ int n = 0; int k = 0; int ret = 0; -EnDecodeInit(currAdmin.GetPassword().c_str(), ADM_PASSWD_LEN, &ctx); +EnDecodeInit(currAdmin->GetPassword().c_str(), ADM_PASSWD_LEN, &ctx); while (li != answerList.end()) { diff --git a/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp b/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp index d2ad12b7..65c666f2 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp @@ -2,10 +2,12 @@ #include #include +#include + #include "stgconfig.h" -#include "../../../tariffs.h" -#include "../../../admins.h" -#include "../../../users.h" +#include "tariffs.h" +#include "admins.h" +#include "users.h" class STGCONFIG_CREATOR { @@ -39,12 +41,12 @@ STG_CONFIG_SETTINGS::STG_CONFIG_SETTINGS() { } //----------------------------------------------------------------------------- -const string& STG_CONFIG_SETTINGS::GetStrError() const +const std::string & STG_CONFIG_SETTINGS::GetStrError() const { return errorStr; } //----------------------------------------------------------------------------- -int STG_CONFIG_SETTINGS::ParseIntInRange(const string & str, int min, int max, int * val) +int STG_CONFIG_SETTINGS::ParseIntInRange(const std::string & str, int min, int max, int * val) { if (str2x(str.c_str(), *val)) { @@ -66,7 +68,7 @@ PARAM_VALUE pv; vector::const_iterator pvi; /////////////////////////// pv.param = "Port"; -pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv); +pvi = std::find(s.moduleParams.begin(), s.moduleParams.end(), pv); if (pvi == s.moduleParams.end()) { errorStr = "Parameter \'Port\' not found."; @@ -91,14 +93,14 @@ return port; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return stgc.GetPlugin(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -const string STG_CONFIG::GetVersion() const +const std::string STG_CONFIG::GetVersion() const { return "Stg configurator v.0.08"; } @@ -152,7 +154,7 @@ if (ret) return ret; } //----------------------------------------------------------------------------- -const string & STG_CONFIG::GetStrError() const +const std::string & STG_CONFIG::GetStrError() const { return errorStr; } diff --git a/projects/stargazer/plugins/configuration/sgconfig/stgconfig.h b/projects/stargazer/plugins/configuration/sgconfig/stgconfig.h index 80cc16a7..83ffa59b 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/stgconfig.h +++ b/projects/stargazer/plugins/configuration/sgconfig/stgconfig.h @@ -1,66 +1,32 @@ -#include -#include -#include "base_plugin.h" -#include "base_store.h" -#include "configproto.h" -//#include "user_ips.h" -//#include "../../../users.h" +#ifndef STGCONFIG_H +#define STGCONFIG_H -using namespace std; +#include -extern "C" BASE_PLUGIN * GetPlugin(); +#include -class STG_CONFIG; +#include "plugin.h" +#include "store.h" +#include "configproto.h" -//----------------------------------------------------------------------------- -/*template -class CHG_BEFORE_NOTIFIER: public PROPERTY_NOTIFIER_BASE -{ -public: - void Notify(const varParamType & oldValue, const varParamType & newValue) - { - auth->Unauthorize(user); - } - void SetUser(USER * u) { user = u; } - void SetAuthorizaror(const AUTH_AO * a) { auth = a; } +extern "C" PLUGIN * GetPlugin(); -private: - USER * user; - const AUTH_AO * auth; -}; -//----------------------------------------------------------------------------- -template -class CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE -{ -public: - void Notify(const varParamType & oldValue, const varParamType & newValue) - { - auth->UpdateUserAuthorization(user); - } - void SetUser(USER * u) { user = u; } - void SetAuthorizaror(const AUTH_AO * a) { auth = a; } +class STG_CONFIG; -private: - USER * user; - const AUTH_AO * auth; -};*/ -//----------------------------------------------------------------------------- -class STG_CONFIG_SETTINGS -{ +class STG_CONFIG_SETTINGS { public: STG_CONFIG_SETTINGS(); - virtual ~STG_CONFIG_SETTINGS(){}; - const string & GetStrError() const; + virtual ~STG_CONFIG_SETTINGS() {} + const std::string & GetStrError() const; int ParseSettings(const MODULE_SETTINGS & s); uint16_t GetPort() const; private: - int ParseIntInRange(const string & str, int min, int max, int * val); - string errorStr; + int ParseIntInRange(const std::string & str, int min, int max, int * val); + std::string errorStr; int port; }; //----------------------------------------------------------------------------- -class STG_CONFIG :public BASE_PLUGIN -{ +class STG_CONFIG :public PLUGIN { public: STG_CONFIG(); virtual ~STG_CONFIG(){}; @@ -68,25 +34,25 @@ public: void SetUsers(USERS * u); void SetTariffs(TARIFFS * t); void SetAdmins(ADMINS * a); - void SetStore(BASE_STORE * s); - void SetTraffcounter(TRAFFCOUNTER *){}; + void SetStore(STORE * s); + void SetTraffcounter(TRAFFCOUNTER *) {} void SetStgSettings(const SETTINGS * s); void SetSettings(const MODULE_SETTINGS & s); int ParseSettings(); int Start(); int Stop(); - int Reload() { return 0; }; + int Reload() { return 0; } bool IsRunning(); - const string & GetStrError() const; - const string GetVersion() const; + const std::string & GetStrError() const; + const std::string GetVersion() const; uint16_t GetStartPosition() const; uint16_t GetStopPosition() const; private: static void * Run(void *); - mutable string errorStr; + mutable std::string errorStr; STG_CONFIG_SETTINGS stgConfigSettings; pthread_t thread; bool nonstop; @@ -95,10 +61,10 @@ private: USERS * users; ADMINS * admins; TARIFFS * tariffs; - BASE_STORE * store; + STORE * store; MODULE_SETTINGS settings; const SETTINGS * stgSettings; }; //----------------------------------------------------------------------------- - +#endif diff --git a/projects/stargazer/plugins/configuration/sgconfig2/configproto.h b/projects/stargazer/plugins/configuration/sgconfig2/configproto.h index 71e546b4..7bdfb21f 100644 --- a/projects/stargazer/plugins/configuration/sgconfig2/configproto.h +++ b/projects/stargazer/plugins/configuration/sgconfig2/configproto.h @@ -36,9 +36,9 @@ #include #include "parser.h" -#include "../../../users.h" -#include "../../../admins.h" -#include "../../../tariffs.h" +#include "users.h" +#include "admins.h" +#include "tariffs.h" #include "stg_logger.h" using namespace std; @@ -63,7 +63,7 @@ public: void SetAdmins(ADMINS * a); void SetUsers(USERS * u); void SetTariffs(TARIFFS * t); - void SetStore(BASE_STORE * s); + void SetStore(STORE * s); void SetStgSettings(const SETTINGS * s); const string & GetAdminLogin(); uint32_t GetAdminIP(); @@ -126,7 +126,7 @@ private: ADMINS * admins; USERS * users; TARIFFS * tariffs; - BASE_STORE * store; + STORE * store; const SETTINGS * settings; BASE_PARSER * currParser; @@ -141,4 +141,3 @@ private: }; //----------------------------------------------------------------------------- #endif //CONFIGPROTO_H - diff --git a/projects/stargazer/plugins/configuration/sgconfig2/parser.h b/projects/stargazer/plugins/configuration/sgconfig2/parser.h index a7b87db6..9e8a8bd9 100644 --- a/projects/stargazer/plugins/configuration/sgconfig2/parser.h +++ b/projects/stargazer/plugins/configuration/sgconfig2/parser.h @@ -14,14 +14,13 @@ using namespace std; #include "resetable.h" #include "stg_const.h" -#include "base_store.h" -#include "../../../admins.h" -#include "../../../users.h" +#include "store.h" +#include "admins.h" +#include "users.h" #include "stg_message.h" //----------------------------------------------------------------------------- -class BASE_PARSER -{ +class BASE_PARSER { public: BASE_PARSER() : admins(NULL), @@ -31,44 +30,42 @@ public: settings(NULL), currAdmin(NULL), depth(0) - { }; - virtual ~BASE_PARSER(){}; + { } + virtual ~BASE_PARSER() {} virtual int ParseStart(void *data, const char *el, const char **attr) = 0; virtual int ParseEnd(void *data, const char *el) = 0; virtual void CreateAnswer() = 0; - virtual void SetAnswerList(list * ansList){answerList = ansList;}; + virtual void SetAnswerList(list * ansList) { answerList = ansList; } - virtual void SetUsers(USERS * u){users = u;}; - virtual void SetAdmins(ADMINS * a){admins = a;}; - virtual void SetTariffs(TARIFFS * t){tariffs = t;}; - virtual void SetStore(BASE_STORE * s){store = s;}; - virtual void SetStgSettings(const SETTINGS * s){settings = s;}; + virtual void SetUsers(USERS * u) { users = u; } + virtual void SetAdmins(ADMINS * a) { admins = a; } + virtual void SetTariffs(TARIFFS * t) { tariffs = t; } + virtual void SetStore(STORE * s) { store = s; } + virtual void SetStgSettings(const SETTINGS * s) { settings = s; } - virtual void SetCurrAdmin(const ADMIN * cua){currAdmin = cua;}; - virtual string & GetStrError(){return strError;}; - virtual void Reset(){ answerList->clear(); depth = 0; }; + virtual void SetCurrAdmin(const ADMIN * cua) { currAdmin = cua; } + virtual string & GetStrError() { return strError; } + virtual void Reset(){ answerList->clear(); depth = 0; } protected: string strError; ADMINS * admins; USERS * users; TARIFFS * tariffs; - BASE_STORE * store; + STORE * store; const SETTINGS * settings; const ADMIN * currAdmin; int depth; list * answerList; }; //----------------------------------------------------------------------------- -class PARSER_GET_ADMINS: public BASE_PARSER -{ +class PARSER_GET_ADMINS: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); }; //----------------------------------------------------------------------------- -class PARSER_ADD_ADMIN: public BASE_PARSER -{ +class PARSER_ADD_ADMIN: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); @@ -77,8 +74,7 @@ private: string adminToAdd; }; //----------------------------------------------------------------------------- -class PARSER_DEL_ADMIN: public BASE_PARSER -{ +class PARSER_DEL_ADMIN: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); @@ -88,8 +84,7 @@ private: string adminToDel; }; //----------------------------------------------------------------------------- -class PARSER_CHG_ADMIN: public BASE_PARSER -{ +class PARSER_CHG_ADMIN: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); @@ -100,8 +95,7 @@ private: RESETABLE privAsString; }; //----------------------------------------------------------------------------- -class PARSER_GET_SERVER_INFO: public BASE_PARSER -{ +class PARSER_GET_SERVER_INFO: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); @@ -109,11 +103,10 @@ public: }; //----------------------------------------------------------------------------- -class PARSER_GET_USER: public BASE_PARSER -{ +class PARSER_GET_USER: public BASE_PARSER { public: PARSER_GET_USER(); - ~PARSER_GET_USER(){}; + ~PARSER_GET_USER() {} int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); @@ -121,8 +114,7 @@ private: string login; }; //----------------------------------------------------------------------------- -class PARSER_GET_USERS: public BASE_PARSER -{ +class PARSER_GET_USERS: public BASE_PARSER { public: PARSER_GET_USERS(); int ParseStart(void *data, const char *el, const char **attr); @@ -133,16 +125,14 @@ private: bool lastUpdateFound; }; //----------------------------------------------------------------------------- -class PARSER_GET_TARIFFS: public BASE_PARSER -{ +class PARSER_GET_TARIFFS: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); }; //----------------------------------------------------------------------------- -class PARSER_ADD_TARIFF: public BASE_PARSER -{ +class PARSER_ADD_TARIFF: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); @@ -151,8 +141,7 @@ private: string tariffToAdd; }; //----------------------------------------------------------------------------- -class PARSER_DEL_TARIFF: public BASE_PARSER -{ +class PARSER_DEL_TARIFF: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); @@ -161,8 +150,7 @@ private: string tariffToDel; }; //----------------------------------------------------------------------------- -class PARSER_CHG_TARIFF: public BASE_PARSER -{ +class PARSER_CHG_TARIFF: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); @@ -176,11 +164,10 @@ private: TARIFF_DATA_RES td; }; //-----------------------------------------------------------------------------/ -class PARSER_ADD_USER: public BASE_PARSER -{ +class PARSER_ADD_USER: public BASE_PARSER { public: PARSER_ADD_USER(); - virtual ~PARSER_ADD_USER(){}; + virtual ~PARSER_ADD_USER() {} int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); void CreateAnswer(); @@ -190,8 +177,7 @@ private: string login; }; //----------------------------------------------------------------------------- -class PARSER_CHG_USER: public BASE_PARSER -{ +class PARSER_CHG_USER: public BASE_PARSER { public: PARSER_CHG_USER(); ~PARSER_CHG_USER(); @@ -215,8 +201,7 @@ private: int res; }; //----------------------------------------------------------------------------- -class PARSER_DEL_USER: public BASE_PARSER -{ +class PARSER_DEL_USER: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); @@ -227,8 +212,7 @@ private: user_iter u; }; //----------------------------------------------------------------------------- -class PARSER_CHECK_USER: public BASE_PARSER -{ +class PARSER_CHECK_USER: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); @@ -237,8 +221,7 @@ private: bool result; }; //----------------------------------------------------------------------------- -class PARSER_SEND_MESSAGE: public BASE_PARSER -{ +class PARSER_SEND_MESSAGE: public BASE_PARSER { public: int ParseStart(void *data, const char *el, const char **attr); int ParseEnd(void *data, const char *el); @@ -252,6 +235,4 @@ private: user_iter u; }; //----------------------------------------------------------------------------- -#endif //PARSER_H - - +#endif diff --git a/projects/stargazer/plugins/configuration/sgconfig2/stgconfig.h b/projects/stargazer/plugins/configuration/sgconfig2/stgconfig.h index a4449531..cf9d72b0 100644 --- a/projects/stargazer/plugins/configuration/sgconfig2/stgconfig.h +++ b/projects/stargazer/plugins/configuration/sgconfig2/stgconfig.h @@ -3,22 +3,21 @@ #include #include -#include "base_plugin.h" -#include "base_store.h" +#include "plugin.h" +#include "store.h" #include "configproto.h" using namespace std; -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); class STG_CONFIG; //----------------------------------------------------------------------------- -class STG_CONFIG_SETTINGS -{ +class STG_CONFIG_SETTINGS { public: STG_CONFIG_SETTINGS(); - virtual ~STG_CONFIG_SETTINGS(){}; + virtual ~STG_CONFIG_SETTINGS() {} const string & GetStrError() const; int ParseSettings(const MODULE_SETTINGS & s); uint16_t GetPort(); @@ -28,27 +27,26 @@ private: int port; }; //----------------------------------------------------------------------------- -class STG_CONFIG: public BASE_PLUGIN -{ +class STG_CONFIG: public PLUGIN { public: STG_CONFIG(); - virtual ~STG_CONFIG(){}; + virtual ~STG_CONFIG() {} - void SetUsers(USERS * u) { users = u; }; - void SetTariffs(TARIFFS * t) { tariffs = t; }; - void SetAdmins(ADMINS * a) { admins = a; }; - void SetStore(BASE_STORE * s) { store = s; }; - void SetTraffcounter(TRAFFCOUNTER *) {}; - void SetStgSettings(const SETTINGS * s) { stgConfigSettings = s; }; - void SetSettings(const MODULE_SETTINGS & s) { settings = s; }; + void SetUsers(USERS * u) { users = u; } + void SetTariffs(TARIFFS * t) { tariffs = t; } + void SetAdmins(ADMINS * a) { admins = a; } + void SetStore(STORE * s) { store = s; } + void SetTraffcounter(TRAFFCOUNTER *) {} + void SetStgSettings(const SETTINGS * s) { stgConfigSettings = s; } + void SetSettings(const MODULE_SETTINGS & s) { settings = s; } int ParseSettings(); int Start(); int Stop(); - int Reload() { return 0; }; - bool IsRunning() { return running; }; + int Reload() { return 0; } + bool IsRunning() { return running; } - const string & GetStrError() const { return errorStr; }; + const string & GetStrError() const { return errorStr; } string GetVersion() const; uint16_t GetStartPosition() const; uint16_t GetStopPosition() const; @@ -69,7 +67,7 @@ private: USERS * users; ADMINS * admins; TARIFFS * tariffs; - BASE_STORE * store; + STORE * store; MODULE_SETTINGS settings; const SETTINGS * stgSettings; diff --git a/projects/stargazer/plugins/other/ping/ping.cpp b/projects/stargazer/plugins/other/ping/ping.cpp index 79d1f4f7..3067e87e 100644 --- a/projects/stargazer/plugins/other/ping/ping.cpp +++ b/projects/stargazer/plugins/other/ping/ping.cpp @@ -2,8 +2,13 @@ #include #include +#include + #include "ping.h" -#include "../../../user.h" +#include "user.h" +#include "stg_locker.h" +#include "../../../settings.h" +#include "../../../user_property.h" class PING_CREATOR { @@ -34,21 +39,21 @@ PING_CREATOR pc; //----------------------------------------------------------------------------- // ëÌÁÓÓ ÄÌÑ ÐÏÉÓËÁ ÀÚÅÒÁ × ÓÐÉÓËÅ ÎÏÔÉÆÉËÁÔÏÒÏ× template -class IS_CONTAINS_USER: public binary_function +class IS_CONTAINS_USER: public binary_function { public: - IS_CONTAINS_USER(const user_iter & u) : user(u) {} + IS_CONTAINS_USER(const USER_PTR & u) : user(u) {} bool operator()(varType notifier) const { return notifier.GetUser() == user; }; private: - const user_iter & user; + const USER_PTR & user; }; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return pc.GetPlugin(); } @@ -66,7 +71,7 @@ PARAM_VALUE pv; vector::const_iterator pvi; pv.param = "PingDelay"; -pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv); +pvi = std::find(s.moduleParams.begin(), s.moduleParams.end(), pv); if (pvi == s.moduleParams.end()) { errorStr = "Parameter \'PingDelay\' not found."; @@ -83,7 +88,7 @@ if (ParseIntInRange(pvi->value[0], 5, 3600, &pingDelay)) return 0; } //----------------------------------------------------------------------------- -int PING_SETTINGS::ParseIntInRange(const string & str, int min, int max, int * val) +int PING_SETTINGS::ParseIntInRange(const std::string & str, int min, int max, int * val) { if (str2x(str.c_str(), *val)) { @@ -113,7 +118,7 @@ PING::~PING() pthread_mutex_destroy(&mutex); } //----------------------------------------------------------------------------- -const string PING::GetVersion() const +const std::string PING::GetVersion() const { return "Pinger v.1.01"; } @@ -136,7 +141,7 @@ void PING::SetUsers(USERS * u) users = u; } //----------------------------------------------------------------------------- -const string & PING::GetStrError() const +const std::string & PING::GetStrError() const { return errorStr; } @@ -197,7 +202,7 @@ if (isRunning) users->DelNotifierUserAdd(&onAddUserNotifier); users->DelNotifierUserDel(&onDelUserNotifier); -list::iterator users_iter; +list::iterator users_iter; users_iter = usersList.begin(); while (users_iter != usersList.end()) { @@ -217,7 +222,7 @@ void * PING::Run(void * d) { PING * ping = (PING*)d; ping->isRunning = true; -list::iterator iter; +list::iterator iter; uint32_t ip; time_t t; @@ -228,9 +233,9 @@ while (ping->nonstop) STG_LOCKER lock(&ping->mutex, __FILE__, __LINE__); while (iter != ping->usersList.end()) { - if ((*iter)->property.ips.ConstData().OnlyOneIP()) + if ((*iter)->GetProperty().ips.ConstData().OnlyOneIP()) { - ip = (*iter)->property.ips.ConstData()[0].ip; + ip = (*iter)->GetProperty().ips.ConstData()[0].ip; if (ping->pinger.GetIPTime(ip, &t) == 0) { if (t) @@ -274,7 +279,7 @@ uint16_t PING::GetStopPosition() const return 100; } //----------------------------------------------------------------------------- -void PING::SetUserNotifiers(user_iter u) +void PING::SetUserNotifiers(USER_PTR u) { CHG_CURRIP_NOTIFIER_PING ChgCurrIPNotifier(*this, u); CHG_IPS_NOTIFIER_PING ChgIPNotifier(*this, u); @@ -283,10 +288,10 @@ ChgCurrIPNotifierList.push_front(ChgCurrIPNotifier); ChgIPNotifierList.push_front(ChgIPNotifier); u->AddCurrIPAfterNotifier(&(*ChgCurrIPNotifierList.begin())); -u->property.ips.AddAfterNotifier(&(*ChgIPNotifierList.begin())); +u->GetProperty().ips.AddAfterNotifier(&(*ChgIPNotifierList.begin())); } //----------------------------------------------------------------------------- -void PING::UnSetUserNotifiers(user_iter u) +void PING::UnSetUserNotifiers(USER_PTR u) { // --- CurrIP --- IS_CONTAINS_USER IsContainsUserCurrIP(u); @@ -313,7 +318,7 @@ IPIter = find_if(ChgIPNotifierList.begin(), if (IPIter != ChgIPNotifierList.end()) { - IPIter->GetUser()->property.ips.DelAfterNotifier(&(*IPIter)); + IPIter->GetUser()->GetProperty().ips.DelAfterNotifier(&(*IPIter)); ChgIPNotifierList.erase(IPIter); } // --- IP end --- @@ -323,7 +328,7 @@ void PING::GetUsers() { STG_LOCKER lock(&mutex, __FILE__, __LINE__); -user_iter u; +USER_PTR u; int h = users->OpenSearch(); if (!h) { @@ -335,9 +340,9 @@ while (users->SearchNext(h, &u) == 0) { usersList.push_back(u); SetUserNotifiers(u); - if (u->property.ips.ConstData().OnlyOneIP()) + if (u->GetProperty().ips.ConstData().OnlyOneIP()) { - pinger.AddIP(u->property.ips.ConstData()[0].ip); + pinger.AddIP(u->GetProperty().ips.ConstData()[0].ip); } else { @@ -352,7 +357,7 @@ while (users->SearchNext(h, &u) == 0) users->CloseSearch(h); } //----------------------------------------------------------------------------- -void PING::AddUser(user_iter u) +void PING::AddUser(USER_PTR u) { STG_LOCKER lock(&mutex, __FILE__, __LINE__); @@ -360,13 +365,13 @@ SetUserNotifiers(u); usersList.push_back(u); } //----------------------------------------------------------------------------- -void PING::DelUser(user_iter u) +void PING::DelUser(USER_PTR u) { STG_LOCKER lock(&mutex, __FILE__, __LINE__); UnSetUserNotifiers(u); -list::iterator users_iter; +list::iterator users_iter; users_iter = usersList.begin(); while (users_iter != usersList.end()) @@ -402,12 +407,12 @@ if (newIPS.OnlyOneIP()) } } //----------------------------------------------------------------------------- -void ADD_USER_NONIFIER_PING::Notify(const user_iter & user) +void ADD_USER_NONIFIER_PING::Notify(const USER_PTR & user) { ping.AddUser(user); } //----------------------------------------------------------------------------- -void DEL_USER_NONIFIER_PING::Notify(const user_iter & user) +void DEL_USER_NONIFIER_PING::Notify(const USER_PTR & user) { ping.DelUser(user); } diff --git a/projects/stargazer/plugins/other/ping/ping.h b/projects/stargazer/plugins/other/ping/ping.h index ea18703f..8db5efc6 100644 --- a/projects/stargazer/plugins/other/ping/ping.h +++ b/projects/stargazer/plugins/other/ping/ping.h @@ -10,83 +10,79 @@ #include #include +#include #include "os_int.h" -#include "base_plugin.h" +#include "plugin.h" +#include "module_settings.h" #include "notifer.h" #include "user_ips.h" #include "pinger.h" -#include "../../../users.h" +#include "users.h" -using namespace std; - -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); class PING; +class USER; +class SETTINGS; //-----------------------------------------------------------------------------*/ -class CHG_CURRIP_NOTIFIER_PING: public PROPERTY_NOTIFIER_BASE -{ +class CHG_CURRIP_NOTIFIER_PING: public PROPERTY_NOTIFIER_BASE { public: - CHG_CURRIP_NOTIFIER_PING(const PING & p, user_iter u) : user(u), ping(p) {} + CHG_CURRIP_NOTIFIER_PING(const PING & p, USER_PTR u) : user(u), ping(p) {} void Notify(const uint32_t & oldIP, const uint32_t & newIP); - user_iter GetUser() const { return user; } + USER_PTR GetUser() const { return user; } private: - user_iter user; + USER_PTR user; const PING & ping; }; //----------------------------------------------------------------------------- -class CHG_IPS_NOTIFIER_PING: public PROPERTY_NOTIFIER_BASE -{ +class CHG_IPS_NOTIFIER_PING: public PROPERTY_NOTIFIER_BASE { public: - CHG_IPS_NOTIFIER_PING(const PING & p, user_iter u) : user(u), ping(p) {} + CHG_IPS_NOTIFIER_PING(const PING & p, USER_PTR u) : user(u), ping(p) {} void Notify(const USER_IPS & oldIPS, const USER_IPS & newIPS); - user_iter GetUser() const { return user; } + USER_PTR GetUser() const { return user; } private: - user_iter user; + USER_PTR user; const PING & ping; }; //----------------------------------------------------------------------------- -class ADD_USER_NONIFIER_PING: public NOTIFIER_BASE -{ +class ADD_USER_NONIFIER_PING: public NOTIFIER_BASE { public: ADD_USER_NONIFIER_PING(PING & p) : ping(p) {} virtual ~ADD_USER_NONIFIER_PING() {} - void Notify(const user_iter & user); + void Notify(const USER_PTR & user); private: PING & ping; }; //----------------------------------------------------------------------------- -class DEL_USER_NONIFIER_PING: public NOTIFIER_BASE -{ +class DEL_USER_NONIFIER_PING: public NOTIFIER_BASE { public: DEL_USER_NONIFIER_PING(PING & p) : ping(p) {} virtual ~DEL_USER_NONIFIER_PING() {} - void Notify(const user_iter & user); + void Notify(const USER_PTR & user); private: PING & ping; }; //----------------------------------------------------------------------------- -class PING_SETTINGS -{ +class PING_SETTINGS { public: PING_SETTINGS(); virtual ~PING_SETTINGS() {} - const string& GetStrError() const { return errorStr; } + const std::string & GetStrError() const { return errorStr; } int ParseSettings(const MODULE_SETTINGS & s); int GetPingDelay() const { return pingDelay; } private: - int ParseIntInRange(const string & str, int min, int max, int * val); + int ParseIntInRange(const std::string & str, int min, int max, int * val); int pingDelay; - mutable string errorStr; + mutable std::string errorStr; }; //----------------------------------------------------------------------------- -class PING: public BASE_PLUGIN -{ +class PING : public PLUGIN { friend class CHG_CURRIP_NOTIFIER_PING; friend class CHG_IPS_NOTIFIER_PING; public: @@ -97,7 +93,7 @@ public: void SetTariffs(TARIFFS *) {} void SetAdmins(ADMINS *) {} void SetTraffcounter(TRAFFCOUNTER *) {} - void SetStore(BASE_STORE *) {} + void SetStore(STORE *) {} void SetStgSettings(const SETTINGS *) {} void SetSettings(const MODULE_SETTINGS & s); int ParseSettings(); @@ -107,25 +103,25 @@ public: int Reload() { return 0; } bool IsRunning(); - const string & GetStrError() const; - const string GetVersion() const; + const std::string & GetStrError() const; + const std::string GetVersion() const; uint16_t GetStartPosition() const; uint16_t GetStopPosition() const; - void AddUser(user_iter u); - void DelUser(user_iter u); + void AddUser(USER_PTR u); + void DelUser(USER_PTR u); private: void GetUsers(); - void SetUserNotifiers(user_iter u); - void UnSetUserNotifiers(user_iter u); + void SetUserNotifiers(USER_PTR u); + void UnSetUserNotifiers(USER_PTR u); static void * Run(void * d); - mutable string errorStr; + mutable std::string errorStr; PING_SETTINGS pingSettings; MODULE_SETTINGS settings; USERS * users; - list usersList; + std::list usersList; /* ÍÙ ÄÏÌÖÎÙ ÐÅÒÅÐÒÏ×ÅÒÉÔØ ×ÏÚÍÏÖÎÏÓÔØ ÐÉÎÇÏ×ÁÎÉÑ ÀÚÅÒÁ ÐÒÉ ÉÚÍÅÎÅÎÉÉ @@ -139,8 +135,8 @@ private: bool isRunning; mutable STG_PINGER pinger; - list ChgCurrIPNotifierList; - list ChgIPNotifierList; + std::list ChgCurrIPNotifierList; + std::list ChgIPNotifierList; ADD_USER_NONIFIER_PING onAddUserNotifier; DEL_USER_NONIFIER_PING onDelUserNotifier; diff --git a/projects/stargazer/plugins/other/radius/radius.cpp b/projects/stargazer/plugins/other/radius/radius.cpp index 9c5ab1db..c1ecab16 100644 --- a/projects/stargazer/plugins/other/radius/radius.cpp +++ b/projects/stargazer/plugins/other/radius/radius.cpp @@ -31,19 +31,21 @@ #include #include "radius.h" +#include "store.h" #include "common.h" +#include "user_conf.h" +#include "../../../user_property.h" extern volatile const time_t stgTime; -void InitEncrypt(BLOWFISH_CTX * ctx, const string & password); +void InitEncrypt(BLOWFISH_CTX * ctx, const std::string & password); void Decrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8); void Encrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8); //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -class RAD_CREATOR -{ +class RAD_CREATOR { private: RADIUS * rad; @@ -51,16 +53,16 @@ public: RAD_CREATOR() : rad(new RADIUS()) { - }; + } ~RAD_CREATOR() { delete rad; - }; + } RADIUS * GetPlugin() { return rad; - }; + } }; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -69,14 +71,14 @@ RAD_CREATOR radc; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return radc.GetPlugin(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int RAD_SETTINGS::ParseIntInRange(const string & str, int min, int max, int * val) +int RAD_SETTINGS::ParseIntInRange(const std::string & str, int min, int max, int * val) { if (str2x(str.c_str(), *val)) { @@ -91,26 +93,26 @@ if (*val < min || *val > max) return 0; } //----------------------------------------------------------------------------- -int RAD_SETTINGS::ParseServices(const vector & str, list * lst) +int RAD_SETTINGS::ParseServices(const std::vector & str, std::list * lst) { - copy(str.begin(), str.end(), back_inserter(*lst)); - list::iterator it(find(lst->begin(), - lst->end(), - "empty")); - if (it != lst->end()) - *it = ""; +std::copy(str.begin(), str.end(), std::back_inserter(*lst)); +std::list::iterator it(std::find(lst->begin(), + lst->end(), + "empty")); +if (it != lst->end()) + *it = ""; - return 0; +return 0; } //----------------------------------------------------------------------------- int RAD_SETTINGS::ParseSettings(const MODULE_SETTINGS & s) { int p; PARAM_VALUE pv; -vector::const_iterator pvi; +std::vector::const_iterator pvi; /////////////////////////// pv.param = "Port"; -pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv); +pvi = std::find(s.moduleParams.begin(), s.moduleParams.end(), pv); if (pvi == s.moduleParams.end()) { errorStr = "Parameter \'Port\' not found."; @@ -126,7 +128,7 @@ if (ParseIntInRange(pvi->value[0], 2, 65535, &p)) port = p; /////////////////////////// pv.param = "Password"; -pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv); +pvi = std::find(s.moduleParams.begin(), s.moduleParams.end(), pv); if (pvi == s.moduleParams.end()) { errorStr = "Parameter \'Password\' not found."; @@ -136,14 +138,14 @@ if (pvi == s.moduleParams.end()) password = pvi->value[0]; /////////////////////////// pv.param = "AuthServices"; -pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv); +pvi = std::find(s.moduleParams.begin(), s.moduleParams.end(), pv); if (pvi != s.moduleParams.end()) { ParseServices(pvi->value, &authServices); } /////////////////////////// pv.param = "AcctServices"; -pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv); +pvi = std::find(s.moduleParams.begin(), s.moduleParams.end(), pv); if (pvi != s.moduleParams.end()) { ParseServices(pvi->value, &acctServices); @@ -180,7 +182,7 @@ void RADIUS::SetSettings(const MODULE_SETTINGS & s) settings = s; } //----------------------------------------------------------------------------- -void RADIUS::SetStore(BASE_STORE * s) +void RADIUS::SetStore(STORE * s) { store = s; } @@ -198,7 +200,7 @@ bool RADIUS::IsRunning() return isRunning; } //----------------------------------------------------------------------------- -const string RADIUS::GetVersion() const +const std::string RADIUS::GetVersion() const { return "RADIUS data access plugin v 0.6"; } @@ -248,7 +250,7 @@ return 0; //----------------------------------------------------------------------------- int RADIUS::Start() { -string password(radSettings.GetPassword()); +std::string password(radSettings.GetPassword()); authServices = radSettings.GetAuthServices(); acctServices = radSettings.GetAcctServices(); @@ -283,10 +285,10 @@ if (!IsRunning()) nonstop = false; -map::iterator it; +std::map::iterator it; for (it = sessions.begin(); it != sessions.end(); ++it) { - user_iter ui; + USER_PTR ui; if (users->FindByName(it->second.userName, &ui)) { ui->Unauthorize(this); @@ -437,7 +439,7 @@ return 0; //----------------------------------------------------------------------------- int RADIUS::ProcessAuthPacket(RAD_PACKET * packet) { -user_iter ui; +USER_PTR ui; if (!CanAcctService((char *)packet->service)) { @@ -475,7 +477,7 @@ return 0; //----------------------------------------------------------------------------- int RADIUS::ProcessPostAuthPacket(RAD_PACKET * packet) { -user_iter ui; +USER_PTR ui; if (!CanAcctService((char *)packet->service)) { @@ -497,7 +499,7 @@ if (!FindUser(&ui, (char *)packet->login)) // I think that only Framed-User services has sense to be accountable // So we have to supply a Framed-IP -USER_IPS ips = ui->property.ips; +USER_IPS ips = ui->GetProperty().ips; packet->packetType = RAD_ACCEPT_PACKET; // Additional checking for Framed-User service @@ -512,7 +514,7 @@ return 0; //----------------------------------------------------------------------------- int RADIUS::ProcessAcctStartPacket(RAD_PACKET * packet) { -user_iter ui; +USER_PTR ui; if (!FindUser(&ui, (char *)packet->login)) { @@ -531,7 +533,7 @@ if (CanAcctService((char *)packet->service)) packet->packetType = RAD_REJECT_PACKET; return -1; } - USER_IPS ips = ui->property.ips; + USER_IPS ips = ui->GetProperty().ips; if (ui->Authorize(ips[0].ip, "", 0xffFFffFF, this)) { printfd(__FILE__, "RADIUS::ProcessAcctStartPacket cannot authorize user '%s'\n", packet->login); @@ -553,7 +555,7 @@ return 0; //----------------------------------------------------------------------------- int RADIUS::ProcessAcctStopPacket(RAD_PACKET * packet) { -map::iterator sid; +std::map::iterator sid; if ((sid = sessions.find((const char *)packet->sessid)) == sessions.end()) { @@ -562,7 +564,7 @@ if ((sid = sessions.find((const char *)packet->sessid)) == sessions.end()) return -1; } -user_iter ui; +USER_PTR ui; if (!FindUser(&ui, sid->second.userName)) { @@ -593,12 +595,12 @@ packet->packetType = RAD_ACCEPT_PACKET; return 0; } //----------------------------------------------------------------------------- -void RADIUS::PrintServices(const list & svcs) +void RADIUS::PrintServices(const std::list & svcs) { - for_each(svcs.begin(), svcs.end(), Printer()); +for_each(svcs.begin(), svcs.end(), Printer()); } //----------------------------------------------------------------------------- -bool RADIUS::FindUser(user_iter * ui, const std::string & login) const +bool RADIUS::FindUser(USER_PTR * ui, const std::string & login) const { if (users->FindByName(login, ui)) { @@ -609,17 +611,17 @@ return true; //----------------------------------------------------------------------------- bool RADIUS::CanAuthService(const std::string & svc) const { - return find(authServices.begin(), authServices.end(), svc) != authServices.end(); +return find(authServices.begin(), authServices.end(), svc) != authServices.end(); } //----------------------------------------------------------------------------- bool RADIUS::CanAcctService(const std::string & svc) const { - return find(acctServices.begin(), acctServices.end(), svc) != acctServices.end(); +return find(acctServices.begin(), acctServices.end(), svc) != acctServices.end(); } //----------------------------------------------------------------------------- bool RADIUS::IsAllowedService(const std::string & svc) const { - return CanAuthService(svc) || CanAcctService(svc); +return CanAuthService(svc) || CanAcctService(svc); } //----------------------------------------------------------------------------- bool RADIUS::WaitPackets(int sd) const @@ -651,7 +653,7 @@ return true; } //----------------------------------------------------------------------------- inline -void InitEncrypt(BLOWFISH_CTX * ctx, const string & password) +void InitEncrypt(BLOWFISH_CTX * ctx, const std::string & password) { unsigned char keyL[RAD_PASSWORD_LEN]; // Пароль для шифровки memset(keyL, 0, RAD_PASSWORD_LEN); diff --git a/projects/stargazer/plugins/other/radius/radius.h b/projects/stargazer/plugins/other/radius/radius.h index 69d3b9d9..26f70aa4 100644 --- a/projects/stargazer/plugins/other/radius/radius.h +++ b/projects/stargazer/plugins/other/radius/radius.h @@ -35,26 +35,26 @@ #include #include #include +#include +#include #include "os_int.h" -#include "base_auth.h" +#include "auth.h" +#include "module_settings.h" #include "notifer.h" #include "user_ips.h" -#include "../../../user.h" -#include "../../../users.h" +#include "user.h" +#include "users.h" #include "blowfish.h" #include "rad_packets.h" -using namespace std; - -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); #define RAD_DEBUG (1) class RADIUS; //----------------------------------------------------------------------------- -class RAD_SETTINGS -{ +class RAD_SETTINGS { public: RAD_SETTINGS() : port(0) {} virtual ~RAD_SETTINGS() {} @@ -62,18 +62,18 @@ public: int ParseSettings(const MODULE_SETTINGS & s); uint16_t GetPort() const { return port; } const std::string & GetPassword() const { return password; } - const list & GetAuthServices() const { return authServices; } - const list & GetAcctServices() const { return acctServices; } + const std::list & GetAuthServices() const { return authServices; } + const std::list & GetAcctServices() const { return acctServices; } private: - int ParseIntInRange(const string & str, int min, int max, int * val); - int ParseServices(const vector & str, list * lst); + int ParseIntInRange(const std::string & str, int min, int max, int * val); + int ParseServices(const std::vector & str, std::list * lst); uint16_t port; - string errorStr; - string password; - list authServices; - list acctServices; + std::string errorStr; + std::string password; + std::list authServices; + std::list acctServices; }; //----------------------------------------------------------------------------- struct RAD_SESSION { @@ -81,32 +81,31 @@ struct RAD_SESSION { std::string serviceType; }; //----------------------------------------------------------------------------- -class RADIUS :public BASE_AUTH -{ +class RADIUS :public AUTH { public: RADIUS(); - virtual ~RADIUS(){}; + virtual ~RADIUS() {}; void SetUsers(USERS * u); - void SetTariffs(TARIFFS *){}; - void SetAdmins(ADMINS *){}; - void SetTraffcounter(TRAFFCOUNTER *){}; - void SetStore(BASE_STORE * ); + void SetTariffs(TARIFFS *) {} + void SetAdmins(ADMINS *) {} + void SetTraffcounter(TRAFFCOUNTER *) {} + void SetStore(STORE * ); void SetStgSettings(const SETTINGS * s); void SetSettings(const MODULE_SETTINGS & s); int ParseSettings(); int Start(); int Stop(); - int Reload() { return 0; }; + int Reload() { return 0; } bool IsRunning(); - const string & GetStrError() const { return errorStr; }; - const string GetVersion() const; + const std::string & GetStrError() const { return errorStr; } + const std::string GetVersion() const; uint16_t GetStartPosition() const; uint16_t GetStopPosition() const; - int SendMessage(const STG_MSG &, uint32_t) const { return 0; }; + int SendMessage(const STG_MSG &, uint32_t) const { return 0; } private: static void * Run(void *); @@ -125,7 +124,7 @@ private: int ProcessAcctUpdatePacket(RAD_PACKET * packet); int ProcessAcctOtherPacket(RAD_PACKET * packet); - bool FindUser(user_iter * ui, const std::string & login) const; + bool FindUser(USER_PTR * ui, const std::string & login) const; bool CanAuthService(const std::string & svc) const; bool CanAcctService(const std::string & svc) const; bool IsAllowedService(const std::string & svc) const; @@ -151,19 +150,19 @@ private: BLOWFISH_CTX ctx; - mutable string errorStr; + mutable std::string errorStr; RAD_SETTINGS radSettings; MODULE_SETTINGS settings; - list authServices; - list acctServices; - map sessions; + std::list authServices; + std::list acctServices; + std::map sessions; bool nonstop; bool isRunning; USERS * users; const SETTINGS * stgSettings; - const BASE_STORE * store; + const STORE * store; pthread_t thread; pthread_mutex_t mutex; diff --git a/projects/stargazer/plugins/other/rscript/rscript.cpp b/projects/stargazer/plugins/other/rscript/rscript.cpp index ed9702f7..1cc7883b 100644 --- a/projects/stargazer/plugins/other/rscript/rscript.cpp +++ b/projects/stargazer/plugins/other/rscript/rscript.cpp @@ -35,6 +35,8 @@ #include "common.h" #include "ur_functor.h" #include "send_functor.h" +#include "stg_locker.h" +#include "../../../user_property.h" extern volatile const time_t stgTime; @@ -70,7 +72,7 @@ RS_CREATOR rsc; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return rsc.GetPlugin(); } @@ -83,7 +85,7 @@ RS_USER::RS_USER() { } //----------------------------------------------------------------------------- -RS_USER::RS_USER(const std::vector & r, user_iter it) +RS_USER::RS_USER(const std::vector & r, USER_PTR it) : lastSentTime(0), user(it), routers(r), @@ -499,7 +501,7 @@ return (res != sizeof(buffer)); //----------------------------------------------------------------------------- bool REMOTE_SCRIPT::GetUsers() { -user_iter u; +USER_PTR u; int h = users->OpenSearch(); if (!h) @@ -518,7 +520,7 @@ users->CloseSearch(h); return false; } //----------------------------------------------------------------------------- -void REMOTE_SCRIPT::ChangedIP(user_iter u, uint32_t oldIP, uint32_t newIP) +void REMOTE_SCRIPT::ChangedIP(USER_PTR u, uint32_t oldIP, uint32_t newIP) { /* * When ip changes process looks like: @@ -560,78 +562,78 @@ for (size_t i = 0; i < netRouters.size(); ++i) return std::vector(); } //----------------------------------------------------------------------------- -string REMOTE_SCRIPT::GetUserParam(user_iter u, const string & paramName) const +string REMOTE_SCRIPT::GetUserParam(USER_PTR u, const string & paramName) const { string value = ""; if (strcasecmp(paramName.c_str(), "cash") == 0) - strprintf(&value, "%f", u->property.cash.Get()); + strprintf(&value, "%f", u->GetProperty().cash.Get()); else if (strcasecmp(paramName.c_str(), "freeMb") == 0) - strprintf(&value, "%f", u->property.freeMb.Get()); + strprintf(&value, "%f", u->GetProperty().freeMb.Get()); else if (strcasecmp(paramName.c_str(), "passive") == 0) - strprintf(&value, "%d", u->property.passive.Get()); + strprintf(&value, "%d", u->GetProperty().passive.Get()); else if (strcasecmp(paramName.c_str(), "disabled") == 0) - strprintf(&value, "%d", u->property.disabled.Get()); + strprintf(&value, "%d", u->GetProperty().disabled.Get()); else if (strcasecmp(paramName.c_str(), "alwaysOnline") == 0) - strprintf(&value, "%d", u->property.alwaysOnline.Get()); + strprintf(&value, "%d", u->GetProperty().alwaysOnline.Get()); else if (strcasecmp(paramName.c_str(), "tariffName") == 0 || strcasecmp(paramName.c_str(), "tariff") == 0) - value = "\"" + u->property.tariffName.Get() + "\""; + value = "\"" + u->GetProperty().tariffName.Get() + "\""; else if (strcasecmp(paramName.c_str(), "nextTariff") == 0) - value = "\"" + u->property.nextTariff.Get() + "\""; + value = "\"" + u->GetProperty().nextTariff.Get() + "\""; else if (strcasecmp(paramName.c_str(), "address") == 0) - value = "\"" + u->property.address.Get() + "\""; + value = "\"" + u->GetProperty().address.Get() + "\""; else if (strcasecmp(paramName.c_str(), "note") == 0) - value = "\"" + u->property.note.Get() + "\""; + value = "\"" + u->GetProperty().note.Get() + "\""; else if (strcasecmp(paramName.c_str(), "group") == 0) - value = "\"" + u->property.group.Get() + "\""; + value = "\"" + u->GetProperty().group.Get() + "\""; else if (strcasecmp(paramName.c_str(), "email") == 0) - value = "\"" + u->property.email.Get() + "\""; + value = "\"" + u->GetProperty().email.Get() + "\""; else if (strcasecmp(paramName.c_str(), "realName") == 0) - value = "\"" + u->property.realName.Get() + "\""; + value = "\"" + u->GetProperty().realName.Get() + "\""; else if (strcasecmp(paramName.c_str(), "credit") == 0) - strprintf(&value, "%f", u->property.credit.Get()); + strprintf(&value, "%f", u->GetProperty().credit.Get()); else if (strcasecmp(paramName.c_str(), "userdata0") == 0) - value = "\"" + u->property.userdata0.Get() + "\""; + value = "\"" + u->GetProperty().userdata0.Get() + "\""; else if (strcasecmp(paramName.c_str(), "userdata1") == 0) - value = "\"" + u->property.userdata1.Get() + "\""; + value = "\"" + u->GetProperty().userdata1.Get() + "\""; else if (strcasecmp(paramName.c_str(), "userdata2") == 0) - value = "\"" + u->property.userdata2.Get() + "\""; + value = "\"" + u->GetProperty().userdata2.Get() + "\""; else if (strcasecmp(paramName.c_str(), "userdata3") == 0) - value = "\"" + u->property.userdata3.Get() + "\""; + value = "\"" + u->GetProperty().userdata3.Get() + "\""; else if (strcasecmp(paramName.c_str(), "userdata4") == 0) - value = "\"" + u->property.userdata4.Get() + "\""; + value = "\"" + u->GetProperty().userdata4.Get() + "\""; else if (strcasecmp(paramName.c_str(), "userdata5") == 0) - value = "\"" + u->property.userdata5.Get() + "\""; + value = "\"" + u->GetProperty().userdata5.Get() + "\""; else if (strcasecmp(paramName.c_str(), "userdata6") == 0) - value = "\"" + u->property.userdata6.Get() + "\""; + value = "\"" + u->GetProperty().userdata6.Get() + "\""; else if (strcasecmp(paramName.c_str(), "userdata7") == 0) - value = "\"" + u->property.userdata7.Get() + "\""; + value = "\"" + u->GetProperty().userdata7.Get() + "\""; else if (strcasecmp(paramName.c_str(), "userdata8") == 0) - value = "\"" + u->property.userdata8.Get() + "\""; + value = "\"" + u->GetProperty().userdata8.Get() + "\""; else if (strcasecmp(paramName.c_str(), "userdata9") == 0) - value = "\"" + u->property.userdata9.Get() + "\""; + value = "\"" + u->GetProperty().userdata9.Get() + "\""; else if (strcasecmp(paramName.c_str(), "enabledDirs") == 0) value = u->GetEnabledDirs(); @@ -640,7 +642,7 @@ else return value; } //----------------------------------------------------------------------------- -void REMOTE_SCRIPT::SetUserNotifier(user_iter u) +void REMOTE_SCRIPT::SetUserNotifier(USER_PTR u) { RS_CHG_AFTER_NOTIFIER afterChgIPNotifier(*this, u); @@ -649,7 +651,7 @@ afterChgIPNotifierList.push_front(afterChgIPNotifier); u->AddCurrIPAfterNotifier(&(*afterChgIPNotifierList.begin())); } //----------------------------------------------------------------------------- -void REMOTE_SCRIPT::UnSetUserNotifier(user_iter u) +void REMOTE_SCRIPT::UnSetUserNotifier(USER_PTR u) { list >::iterator ipAIter; std::list >::iterator> toErase; diff --git a/projects/stargazer/plugins/other/rscript/rscript.h b/projects/stargazer/plugins/other/rscript/rscript.h index ece1d8c5..7748144e 100644 --- a/projects/stargazer/plugins/other/rscript/rscript.h +++ b/projects/stargazer/plugins/other/rscript/rscript.h @@ -32,87 +32,86 @@ #include #include +#include #include #include #include -#include "base_store.h" +#include "plugin.h" +#include "store.h" +#include "module_settings.h" #include "os_int.h" #include "notifer.h" #include "user_ips.h" -#include "../../../user.h" -#include "../../../users.h" +#include "user.h" +#include "users.h" #include "blowfish.h" #include "rs_packets.h" #include "nrmap_parser.h" -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); #define RS_DEBUG (1) #define MAX_SHORT_PCKT (3) class REMOTE_SCRIPT; +class SETTINGS; //----------------------------------------------------------------------------- -class RS_ADD_USER_NONIFIER: public NOTIFIER_BASE -{ +class RS_ADD_USER_NONIFIER: public NOTIFIER_BASE { public: RS_ADD_USER_NONIFIER(REMOTE_SCRIPT & r) : rs(r) {} virtual ~RS_ADD_USER_NONIFIER() {} - void Notify(const user_iter & user); + void Notify(const USER_PTR & user); private: REMOTE_SCRIPT & rs; }; //----------------------------------------------------------------------------- -class RS_DEL_USER_NONIFIER: public NOTIFIER_BASE -{ +class RS_DEL_USER_NONIFIER: public NOTIFIER_BASE { public: RS_DEL_USER_NONIFIER(REMOTE_SCRIPT & r) : rs(r) {} virtual ~RS_DEL_USER_NONIFIER() {} - void Notify(const user_iter & user); + void Notify(const USER_PTR & user); private: REMOTE_SCRIPT & rs; }; //----------------------------------------------------------------------------- template -class RS_CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE -{ +class RS_CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE { public: - RS_CHG_AFTER_NOTIFIER(REMOTE_SCRIPT & r, user_iter u) : user(u), rs(r) {} + RS_CHG_AFTER_NOTIFIER(REMOTE_SCRIPT & r, USER_PTR u) : user(u), rs(r) {} void Notify(const varParamType & oldValue, const varParamType & newValue); - user_iter GetUser() {return user; } + USER_PTR GetUser() {return user; } private: - user_iter user; + USER_PTR user; REMOTE_SCRIPT & rs; }; //----------------------------------------------------------------------------- -struct RS_USER -{ +struct RS_USER { RS_USER(); -RS_USER(const std::vector & r, user_iter it); +RS_USER(const std::vector & r, USER_PTR it); time_t lastSentTime; -user_iter user; +USER_PTR user; std::vector routers; int shortPacketsCount; }; //----------------------------------------------------------------------------- -class RS_SETTINGS -{ +class RS_SETTINGS { public: RS_SETTINGS(); - virtual ~RS_SETTINGS() {}; - const std::string & GetStrError() const { return errorStr; }; - int ParseSettings(const MODULE_SETTINGS & s); - int GetSendPeriod() const { return sendPeriod; }; - int GetPort() const { return port; }; - const std::vector & GetSubnetsMap() const { return netRouters; }; - const std::vector & GetUserParams() const { return userParams; }; - const std::string & GetPassword() const { return password; }; - const std::string & GetMapFileName() const { return subnetFile; }; + virtual ~RS_SETTINGS() {} + const std::string & GetStrError() const { return errorStr; } + int ParseSettings(const MODULE_SETTINGS & s) + int GetSendPeriod() const { return sendPeriod; } + int GetPort() const { return port; } + const std::vector & GetSubnetsMap() const { return netRouters; } + const std::vector & GetUserParams() const { return userParams; } + const std::string & GetPassword() const { return password; } + const std::string & GetMapFileName() const { return subnetFile; } private: int ParseIntInRange(const std::string & str, int min, int max, int * val); @@ -120,40 +119,39 @@ private: uint16_t port; string errorStr; std::vector netRouters; - std::vector userParams; + std::vector userParams; string password; string subnetFile; }; //----------------------------------------------------------------------------- -class REMOTE_SCRIPT : public BASE_PLUGIN -{ +class REMOTE_SCRIPT : public PLUGIN { public: REMOTE_SCRIPT(); virtual ~REMOTE_SCRIPT(); - void SetUsers(USERS * u) { users = u; }; - void SetTariffs(TARIFFS *) {}; - void SetAdmins(ADMINS *) {}; - void SetTraffcounter(TRAFFCOUNTER *) {}; - void SetStore(BASE_STORE *) {}; - void SetStgSettings(const SETTINGS *) {}; - void SetSettings(const MODULE_SETTINGS & s) { settings = s; }; + void SetUsers(USERS * u) { users = u; } + void SetTariffs(TARIFFS *) {} + void SetAdmins(ADMINS *) {} + void SetTraffcounter(TRAFFCOUNTER *) {} + void SetStore(STORE *) {} + void SetStgSettings(const SETTINGS *) {} + void SetSettings(const MODULE_SETTINGS & s) { settings = s; } int ParseSettings(); int Start(); int Stop(); int Reload(); - bool IsRunning() { return isRunning; }; + bool IsRunning() { return isRunning; } - const std::string & GetStrError() const { return errorStr; }; - const std::string GetVersion() const { return "Remote script v 0.3"; }; - uint16_t GetStartPosition() const { return 20; }; - uint16_t GetStopPosition() const { return 20; }; + const std::string & GetStrError() const { return errorStr; } + const std::string GetVersion() const { return "Remote script v 0.3"; } + uint16_t GetStartPosition() const { return 20; } + uint16_t GetStopPosition() const { return 20; } - void DelUser(user_iter u) { UnSetUserNotifier(u); }; - void AddUser(user_iter u) { SetUserNotifier(u); }; + void DelUser(USER_PTR u) { UnSetUserNotifier(u); } + void AddUser(USER_PTR u) { SetUserNotifier(u); } - void ChangedIP(user_iter u, uint32_t oldIP, uint32_t newIP); + void ChangedIP(USER_PTR u, uint32_t oldIP, uint32_t newIP); private: static void * Run(void *); @@ -167,10 +165,10 @@ private: std::vector IP2Routers(uint32_t ip); bool GetUsers(); - std::string GetUserParam(user_iter u, const std::string & paramName) const; + std::string GetUserParam(USER_PTR u, const std::string & paramName) const; - void SetUserNotifier(user_iter u); - void UnSetUserNotifier(user_iter u); + void SetUserNotifier(USER_PTR u); + void UnSetUserNotifier(USER_PTR u); void InitEncrypt(BLOWFISH_CTX * ctx, const string & password) const; void Encrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, size_t len8) const; @@ -205,10 +203,9 @@ private: friend class DisconnectUser; }; //----------------------------------------------------------------------------- -class DisconnectUser : public std::unary_function &, void> -{ +class DisconnectUser : public std::unary_function &, void> { public: - DisconnectUser(REMOTE_SCRIPT & rs) : rscript(rs) {}; + DisconnectUser(REMOTE_SCRIPT & rs) : rscript(rs) {} void operator()(std::pair & p) { rscript.Send(p.first, p.second, true); @@ -217,13 +214,13 @@ class DisconnectUser : public std::unary_function -#include "base_settings.h" -#include "base_store.h" +#include "module_settings.h" +#include "store.h" #include "conffiles.h" #include "user_traff.h" -using namespace std; //----------------------------------------------------------------------------- -extern "C" BASE_STORE * GetStore(); +extern "C" STORE * GetStore(); //----------------------------------------------------------------------------- -class FILES_STORE_SETTINGS//: public BASE_SETTINGS -{ +class FILES_STORE_SETTINGS { public: FILES_STORE_SETTINGS(); virtual ~FILES_STORE_SETTINGS(); virtual int ParseSettings(const MODULE_SETTINGS & s); - virtual const string & GetStrError() const; + virtual const std::string & GetStrError() const; - string GetWorkDir() const; - string GetUsersDir() const; - string GetAdminsDir() const; - string GetTariffsDir() const; + std::string GetWorkDir() const; + std::string GetUsersDir() const; + std::string GetAdminsDir() const; + std::string GetTariffsDir() const; mode_t GetStatMode() const; mode_t GetStatModeDir() const; @@ -78,17 +76,17 @@ private: int User2UID(const char * user, uid_t * uid); int Group2GID(const char * gr, gid_t * gid); int Str2Mode(const char * str, mode_t * mode); - int ParseOwner(const vector & moduleParams, const string & owner, uid_t * uid); - int ParseGroup(const vector & moduleParams, const string & group, uid_t * uid); - int ParseMode(const vector & moduleParams, const string & modeStr, mode_t * mode); - int ParseYesNo(const string & value, bool * val); + int ParseOwner(const std::vector & moduleParams, const std::string & owner, uid_t * uid); + int ParseGroup(const std::vector & moduleParams, const std::string & group, uid_t * uid); + int ParseMode(const std::vector & moduleParams, const std::string & modeStr, mode_t * mode); + int ParseYesNo(const std::string & value, bool * val); - string errorStr; + std::string errorStr; - string workDir; - string usersDir; - string adminsDir; - string tariffsDir; + std::string workDir; + std::string usersDir; + std::string adminsDir; + std::string tariffsDir; mode_t statMode; uid_t statUID; @@ -106,32 +104,31 @@ private: bool readBak; }; //----------------------------------------------------------------------------- -class FILES_STORE: public BASE_STORE -{ +class FILES_STORE: public STORE { public: FILES_STORE(); virtual ~FILES_STORE(); - virtual const string & GetStrError() const; + virtual const std::string & GetStrError() const; //User - virtual int GetUsersList(vector * usersList) const; - virtual int AddUser(const string & login) const; - virtual int DelUser(const string & login) const; - virtual int SaveUserStat(const USER_STAT & stat, const string & login) const; - virtual int SaveUserConf(const USER_CONF & conf, const string & login) const; - - virtual int RestoreUserStat(USER_STAT * stat, const string & login) const; - virtual int RestoreUserConf(USER_CONF * conf, const string & login) const; - - virtual int WriteUserChgLog(const string & login, - const string & admLogin, - uint32_t admIP, - const string & paramName, - const string & oldValue, - const string & newValue, - const string & message = "") const; - virtual int WriteUserConnect(const string & login, uint32_t ip) const; - virtual int WriteUserDisconnect(const string & login, + virtual int GetUsersList(std::vector * usersList) const; + virtual int AddUser(const std::string & login) const; + virtual int DelUser(const std::string & login) const; + virtual int SaveUserStat(const USER_STAT & stat, const std::string & login) const; + virtual int SaveUserConf(const USER_CONF & conf, const std::string & login) const; + + virtual int RestoreUserStat(USER_STAT * stat, const std::string & login) const; + virtual int RestoreUserConf(USER_CONF * conf, const std::string & login) const; + + virtual int WriteUserChgLog(const std::string & login, + const std::string & admLogin, + uint32_t admIP, + const std::string & paramName, + const std::string & oldValue, + const std::string & newValue, + const std::string & message = "") const; + virtual int WriteUserConnect(const std::string & login, uint32_t ip) const; + virtual int WriteUserDisconnect(const std::string & login, const DIR_TRAFF & up, const DIR_TRAFF & down, const DIR_TRAFF & sessionUp, @@ -140,69 +137,68 @@ public: double freeMb, const std::string & reason) const; - virtual int WriteDetailedStat(const map & statTree, + virtual int WriteDetailedStat(const TRAFF_STAT & statTree, time_t lastStat, - const string & login) const; - - virtual int AddMessage(STG_MSG * msg, const string & login) const; - virtual int EditMessage(const STG_MSG & msg, const string & login) const; - virtual int GetMessage(uint64_t id, STG_MSG * msg, const string & login) const; - virtual int DelMessage(uint64_t id, const string & login) const; - virtual int GetMessageHdrs(vector * hdrsList, const string & login) const; - virtual int ReadMessage(const string & fileName, + const std::string & login) const; + + virtual int AddMessage(STG_MSG * msg, const std::string & login) const; + virtual int EditMessage(const STG_MSG & msg, const std::string & login) const; + virtual int GetMessage(uint64_t id, STG_MSG * msg, const std::string & login) const; + virtual int DelMessage(uint64_t id, const std::string & login) const; + virtual int GetMessageHdrs(std::vector * hdrsList, const std::string & login) const; + virtual int ReadMessage(const std::string & fileName, STG_MSG_HDR * hdr, - string * text) const; + std::string * text) const; - virtual int SaveMonthStat(const USER_STAT & stat, int month, int year, const string & login) const; + virtual int SaveMonthStat(const USER_STAT & stat, int month, int year, const std::string & login) const; //Admin - virtual int GetAdminsList(vector * adminsList) const; - virtual int AddAdmin(const string & login) const; - virtual int DelAdmin(const string & login) const; - virtual int RestoreAdmin(ADMIN_CONF * ac, const string & login) const; + virtual int GetAdminsList(std::vector * adminsList) const; + virtual int AddAdmin(const std::string & login) const; + virtual int DelAdmin(const std::string & login) const; + virtual int RestoreAdmin(ADMIN_CONF * ac, const std::string & login) const; virtual int SaveAdmin(const ADMIN_CONF & ac) const; //Tariff - virtual int GetTariffsList(vector * tariffsList) const; - virtual int AddTariff(const string & name) const; - virtual int DelTariff(const string & name) const; - virtual int SaveTariff(const TARIFF_DATA & td, const string & tariffName) const; - virtual int RestoreTariff(TARIFF_DATA * td, const string & tariffName) const; + virtual int GetTariffsList(std::vector * tariffsList) const; + virtual int AddTariff(const std::string & name) const; + virtual int DelTariff(const std::string & name) const; + virtual int SaveTariff(const TARIFF_DATA & td, const std::string & tariffName) const; + virtual int RestoreTariff(TARIFF_DATA * td, const std::string & tariffName) const; //Corparation - virtual int GetCorpsList(vector *) const {return 0;}; - virtual int SaveCorp(const CORP_CONF &) const {return 0;}; - virtual int RestoreCorp(CORP_CONF *, const string &) const {return 0;}; - virtual int AddCorp(const string &) const {return 0;}; - virtual int DelCorp(const string &) const {return 0;}; + virtual int GetCorpsList(std::vector *) const { return 0; } + virtual int SaveCorp(const CORP_CONF &) const { return 0; } + virtual int RestoreCorp(CORP_CONF *, const std::string &) const { return 0; } + virtual int AddCorp(const std::string &) const { return 0; } + virtual int DelCorp(const std::string &) const { return 0; } // Services - virtual int GetServicesList(vector *) const {return 0;}; - virtual int SaveService(const SERVICE_CONF &) const {return 0;}; - virtual int RestoreService(SERVICE_CONF *, const string &) const {return 0;}; - virtual int AddService(const string &) const {return 0;}; - virtual int DelService(const string &) const {return 0;}; + virtual int GetServicesList(std::vector *) const { return 0; } + virtual int SaveService(const SERVICE_CONF &) const { return 0; } + virtual int RestoreService(SERVICE_CONF *, const std::string &) const { return 0; } + virtual int AddService(const std::string &) const { return 0; } + virtual int DelService(const std::string &) const { return 0; } - //virtual BASE_SETTINGS * GetStoreSettings(); virtual void SetSettings(const MODULE_SETTINGS & s); virtual int ParseSettings(); - virtual const string & GetVersion() const; + virtual const std::string & GetVersion() const; private: - virtual int RestoreUserStat(USER_STAT * stat, const string & login, const string & fileName) const; - virtual int RestoreUserConf(USER_CONF * conf, const string & login, const string & fileName) const; + virtual int RestoreUserStat(USER_STAT * stat, const std::string & login, const std::string & fileName) const; + virtual int RestoreUserConf(USER_CONF * conf, const std::string & login, const std::string & fileName) const; - virtual int WriteLogString(const string & str, const string & login) const; - virtual int WriteLog2String(const string & str, const string & login) const; + virtual int WriteLogString(const std::string & str, const std::string & login) const; + virtual int WriteLog2String(const std::string & str, const std::string & login) const; int RemoveDir(const char * path) const; int Touch(const std::string & path) const; mutable string errorStr; - string version; + std::string version; FILES_STORE_SETTINGS storeSettings; MODULE_SETTINGS settings; mutable pthread_mutex_t mutex; }; //----------------------------------------------------------------------------- -#endif //FILE_STORE_H +#endif diff --git a/projects/stargazer/plugins/store/firebird/firebird_store.h b/projects/stargazer/plugins/store/firebird/firebird_store.h index 55333888..45cf4f8d 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store.h +++ b/projects/stargazer/plugins/store/firebird/firebird_store.h @@ -29,23 +29,22 @@ #ifndef FIREBIRD_STORE_H #define FIREBIRD_STORE_H +#include #include #include #include -#include "base_store.h" +#include "store.h" #include "stg_locker.h" #include "ibpp.h" -//#include "firebird_database.h" -struct ToLower -{ -char operator() (char c) const { return std::tolower(c); } +struct ToLower { + char operator() (char c) const { return std::tolower(c); } }; -extern "C" BASE_STORE * GetStore(); +extern "C" STORE * GetStore(); -class FIREBIRD_STORE : public BASE_STORE { +class FIREBIRD_STORE : public STORE { public: FIREBIRD_STORE(); virtual ~FIREBIRD_STORE(); @@ -73,7 +72,7 @@ public: double cash, double freeMb, const std::string & reason) const; - int WriteDetailedStat(const std::map & statTree, + int WriteDetailedStat(const TRAFF_STAT & statTree, time_t lastStat, const std::string & login) const; @@ -126,11 +125,10 @@ private: mutable IBPP::TLR tlr; int SaveStat(const USER_STAT & stat, const std::string & login, int year = 0, int month = 0) const; - - time_t ts2time_t(const IBPP::Timestamp & ts) const; - void time_t2ts(time_t t, IBPP::Timestamp * ts) const; - void ym2date(int year, int month, IBPP::Date * date) const; }; -#endif //FIREBIRD_STORE_H +time_t ts2time_t(const IBPP::Timestamp & ts) const; +void time_t2ts(time_t t, IBPP::Timestamp * ts) const; +void ym2date(int year, int month, IBPP::Date * date) const; +#endif //FIREBIRD_STORE_H diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_utils.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_utils.cpp index 9f7fe6b8..17ab0d40 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_utils.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_utils.cpp @@ -32,7 +32,7 @@ #include "ibpp.h" //----------------------------------------------------------------------------- -time_t FIREBIRD_STORE::ts2time_t(const IBPP::Timestamp & ts) const +time_t ts2time_t(const IBPP::Timestamp & ts) const { char buf[32]; int year, month, day, hour, min, sec; @@ -47,7 +47,7 @@ time_t FIREBIRD_STORE::ts2time_t(const IBPP::Timestamp & ts) const return mktime(&time_tm); } //----------------------------------------------------------------------------- -void FIREBIRD_STORE::time_t2ts(time_t t, IBPP::Timestamp * ts) const +void time_t2ts(time_t t, IBPP::Timestamp * ts) const { struct tm res; @@ -56,10 +56,9 @@ void FIREBIRD_STORE::time_t2ts(time_t t, IBPP::Timestamp * ts) const *ts = IBPP::Timestamp(res.tm_year + 1900, res.tm_mon + 1, res.tm_mday, res.tm_hour, res.tm_min, res.tm_sec); } //----------------------------------------------------------------------------- -void FIREBIRD_STORE::ym2date(int year, int month, IBPP::Date * date) const +void ym2date(int year, int month, IBPP::Date * date) const { date->SetDate(year + 1900, month + 1, 1); date->EndOfMonth(); } //----------------------------------------------------------------------------- - diff --git a/projects/stargazer/plugins/store/mysql/mysql_store.h b/projects/stargazer/plugins/store/mysql/mysql_store.h index 7b48712f..cb801439 100644 --- a/projects/stargazer/plugins/store/mysql/mysql_store.h +++ b/projects/stargazer/plugins/store/mysql/mysql_store.h @@ -11,15 +11,15 @@ #include -#include "base_settings.h" -#include "base_store.h" +#include "module_settings.h" +#include "store.h" #include "user_traff.h" using namespace std; //----------------------------------------------------------------------------- -extern "C" BASE_STORE * GetStore(); +extern "C" STORE * GetStore(); //----------------------------------------------------------------------------- -class MYSQL_STORE_SETTINGS//: public BASE_SETTINGS +class MYSQL_STORE_SETTINGS { public: MYSQL_STORE_SETTINGS(); @@ -36,17 +36,17 @@ private: const MODULE_SETTINGS * settings; int ParseParam(const vector & moduleParams, - const string & name, string & result); + const string & name, string & result); - string errorStr; + string errorStr; string dbUser; string dbPass; - string dbName; + string dbName; string dbHost; }; //----------------------------------------------------------------------------- -class MYSQL_STORE: public BASE_STORE +class MYSQL_STORE: public STORE { public: MYSQL_STORE(); @@ -125,21 +125,21 @@ public: private: virtual int WriteLogString(const string & str, const string & login) const; - int GetAllParams(vector * ParamList, const string & table, const string & name) const; - int CheckAllTables(MYSQL * sock); - bool IsTablePresent(const string & str,MYSQL * sock); + int GetAllParams(vector * ParamList, const string & table, const string & name) const; + int CheckAllTables(MYSQL * sock); + bool IsTablePresent(const string & str,MYSQL * sock); mutable string errorStr; -// int Reconnect(); - int MysqlQuery(const char* sQuery,MYSQL * sock) const; +// int Reconnect(); + int MysqlQuery(const char* sQuery,MYSQL * sock) const; int MysqlGetQuery(const char * Query,MYSQL * & sock) const; int MysqlSetQuery(const char * Query) const; MYSQL * MysqlConnect() const ; string version; MYSQL_STORE_SETTINGS storeSettings; MODULE_SETTINGS settings; - //mutable MYSQL mysql; - //mutable MYSQL* sock; + //mutable MYSQL mysql; + //mutable MYSQL* sock; }; //----------------------------------------------------------------------------- -#endif //FILE_STORE_H +#endif diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store.h b/projects/stargazer/plugins/store/postgresql/postgresql_store.h index ea2ec4f3..ba738bc0 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store.h +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store.h @@ -35,15 +35,15 @@ #include #include -#include "base_store.h" +#include "store.h" // Minimal DB version is 5 // Recommended DB version is 6 (support FreeMb logging on disconnects) #define DB_MIN_VERSION 5 -extern "C" BASE_STORE * GetStore(); +extern "C" STORE * GetStore(); -class POSTGRESQL_STORE : public BASE_STORE { +class POSTGRESQL_STORE : public STORE { public: POSTGRESQL_STORE(); virtual ~POSTGRESQL_STORE(); diff --git a/projects/stargazer/store_loader.cpp b/projects/stargazer/store_loader.cpp index 56bd01ac..11fd804f 100644 --- a/projects/stargazer/store_loader.cpp +++ b/projects/stargazer/store_loader.cpp @@ -32,6 +32,8 @@ #include "store_loader.h" #include "common.h" +#include "store.h" +#include "settings.h" STORE_LOADER::STORE_LOADER(const SETTINGS & settings) : isLoaded(false), diff --git a/projects/stargazer/store_loader.h b/projects/stargazer/store_loader.h index a5066926..1f624e1a 100644 --- a/projects/stargazer/store_loader.h +++ b/projects/stargazer/store_loader.h @@ -33,13 +33,13 @@ #include -#include "base_store.h" -#include "base_settings.h" -#include "settings.h" +#include "module_settings.h" #include "noncopyable.h" -class STORE_LOADER : private NONCOPYABLE -{ +class STORE; +class SETTINGS; + +class STORE_LOADER : private NONCOPYABLE { public: STORE_LOADER(const SETTINGS & settings); ~STORE_LOADER(); @@ -47,13 +47,13 @@ public: bool Load(); bool Unload(); - BASE_STORE * GetStore() { return plugin; }; + STORE * GetStore() { return plugin; } - const std::string & GetStrError() const { return errorStr; }; + const std::string & GetStrError() const { return errorStr; } private: bool isLoaded; void * handle; - BASE_STORE * plugin; + STORE * plugin; std::string errorStr; MODULE_SETTINGS storeSettings; std::string pluginFileName; diff --git a/projects/stargazer/tariffs_impl.cpp b/projects/stargazer/tariffs_impl.cpp index 2caf17aa..32de4971 100644 --- a/projects/stargazer/tariffs_impl.cpp +++ b/projects/stargazer/tariffs_impl.cpp @@ -35,13 +35,13 @@ #include "tariffs_impl.h" #include "stg_locker.h" #include "stg_logger.h" -#include "base_store.h" +#include "store.h" #include "admin.h" using namespace std; //----------------------------------------------------------------------------- -TARIFFS_IMPL::TARIFFS_IMPL(BASE_STORE * st) +TARIFFS_IMPL::TARIFFS_IMPL(STORE * st) : tariffs(), store(st), WriteServLog(GetStgLogger()), diff --git a/projects/stargazer/tariffs_impl.h b/projects/stargazer/tariffs_impl.h index 8c2ae4d0..0b1c23b9 100644 --- a/projects/stargazer/tariffs_impl.h +++ b/projects/stargazer/tariffs_impl.h @@ -49,13 +49,13 @@ #define TARIFF_DAY 0 #define TARIFF_NIGHT 1 -class BASE_STORE; +class STORE; class STG_LOGGER; class ADMIN; class TARIFFS_IMPL : public TARIFFS { public: - TARIFFS_IMPL(BASE_STORE * store); + TARIFFS_IMPL(STORE * store); virtual ~TARIFFS_IMPL(); int ReadTariffs (); const TARIFF * FindByName(const std::string & name) const; @@ -67,14 +67,14 @@ public: void GetTariffsData(std::list * tdl); - const std::string & GetStrError() const { return strError; }; + const std::string & GetStrError() const { return strError; } private: - std::list tariffs; - BASE_STORE * store; - STG_LOGGER & WriteServLog; + std::list tariffs; + STORE * store; + STG_LOGGER & WriteServLog; mutable pthread_mutex_t mutex; - std::string strError; - TARIFF_IMPL noTariff; + std::string strError; + TARIFF_IMPL noTariff; }; #endif diff --git a/projects/stargazer/traffcounter.cpp b/projects/stargazer/traffcounter.cpp index 1d088f48..9697cde0 100644 --- a/projects/stargazer/traffcounter.cpp +++ b/projects/stargazer/traffcounter.cpp @@ -28,6 +28,11 @@ $Author: faust $ */ +/* inet_aton */ +#include +#include +#include + #include #include #include // Functions fopen and similar @@ -35,6 +40,7 @@ #include "traffcounter.h" #include "common.h" #include "stg_locker.h" +#include "stg_timer.h" #define FLUSH_TIME (10) #define REMOVE_TIME (31) @@ -48,7 +54,7 @@ enum protoNum }; //----------------------------------------------------------------------------- -TRAFFCOUNTER::TRAFFCOUNTER(USERS * u, const TARIFFS *, const string & fn) +TRAFFCOUNTER::TRAFFCOUNTER(USERS * u, const TARIFFS *, const std::string & fn) : WriteServLog(GetStgLogger()), rulesFileName(fn), monitoring(false), @@ -89,7 +95,7 @@ if (ReadRules()) printfd(__FILE__, "TRAFFCOUNTER::Start()\n"); int h = users->OpenSearch(); -user_iter u; +USER_PTR u; if (!h) { WriteServLog("TRAFFCOUNTER: Cannot get users."); @@ -125,7 +131,7 @@ if (!h) return -1; } -user_iter u; +USER_PTR u; while (users->SearchNext(h, &u) == 0) { UnSetUserNotifiers(u); @@ -172,7 +178,7 @@ while (tc->running) if (tc->monitoring && (touchTime + MONITOR_TIME_DELAY_SEC <= stgTime)) { - string monFile(tc->monitorDir + "/traffcounter_r"); + std::string monFile(tc->monitorDir + "/traffcounter_r"); printfd(__FILE__, "Monitor=%d file TRAFFCOUNTER %s\n", tc->monitoring, monFile.c_str()); touchTime = stgTime; TouchFile(monFile.c_str()); @@ -195,7 +201,7 @@ static time_t touchTime = stgTime - MONITOR_TIME_DELAY_SEC; if (monitoring && (touchTime + MONITOR_TIME_DELAY_SEC <= stgTime)) { - static string monFile = monitorDir + "/traffcounter_p"; + static std::string monFile = monitorDir + "/traffcounter_p"; printfd(__FILE__, "Monitor=%d file TRAFFCOUNTER %s\n", monitoring, monFile.c_str()); touchTime = stgTime; TouchFile(monFile.c_str()); @@ -268,13 +274,12 @@ if (ed.userUPresent || //TODO use result of lower_bound to inserting new record // Adding packet to a tree. - pair insertResult = packets.insert(pair(rawPacket, ed)); + std::pair insertResult = packets.insert(std::make_pair(rawPacket, ed)); pp_iter newPacket = insertResult.first; // Adding packet reference to an IP index. - ip2packets.insert(pair(ipU, newPacket)); - ip2packets.insert(pair(ipD, newPacket)); + ip2packets.insert(std::make_pair(ipU, newPacket)); + ip2packets.insert(std::make_pair(ipD, newPacket)); } } //----------------------------------------------------------------------------- @@ -386,11 +391,11 @@ while (pi != packets.end()) }*/ if (stgTime - pi->second.updateTime < REMOVE_TIME) { - pair res = newPackets.insert(*pi); + std::pair res = newPackets.insert(*pi); if (res.second) { - ip2packets.insert(make_pair(pi->first.GetSrcIP(), res.first)); - ip2packets.insert(make_pair(pi->first.GetDstIP(), res.first)); + ip2packets.insert(std::make_pair(pi->first.GetSrcIP(), res.first)); + ip2packets.insert(std::make_pair(pi->first.GetDstIP(), res.first)); } } ++pi; @@ -404,11 +409,11 @@ printfd(__FILE__, "FlushAndRemove() packets: %d(rem %d) ip2packets: %d(rem %d)\n } //----------------------------------------------------------------------------- -void TRAFFCOUNTER::AddUser(user_iter user) +void TRAFFCOUNTER::AddUser(USER_PTR user) { printfd(__FILE__, "AddUser: %s\n", user->GetLogin().c_str()); uint32_t uip = user->GetCurrIP(); -pair pi; +std::pair pi; STG_LOCKER lock(&mutex, __FILE__, __LINE__); // Find all packets with IP belongs to this user @@ -445,7 +450,7 @@ while (pi.first != pi.second) void TRAFFCOUNTER::DelUser(uint32_t uip) { printfd(__FILE__, "DelUser: %s \n", inet_ntostring(uip).c_str()); -pair pi; +std::pair pi; STG_LOCKER lock(&mutex, __FILE__, __LINE__); pi = ip2packets.equal_range(uip); @@ -495,7 +500,7 @@ while (pi.first != pi.second) ip2packets.erase(pi.first, pi.second); } //----------------------------------------------------------------------------- -void TRAFFCOUNTER::SetUserNotifiers(user_iter user) +void TRAFFCOUNTER::SetUserNotifiers(USER_PTR user) { // Adding user. Adding notifiers to user. TRF_IP_BEFORE ipBNotifier(*this, user); @@ -507,11 +512,11 @@ ipAfterNotifiers.push_front(ipANotifier); user->AddCurrIPAfterNotifier(&(*ipAfterNotifiers.begin())); } //----------------------------------------------------------------------------- -void TRAFFCOUNTER::UnSetUserNotifiers(user_iter user) +void TRAFFCOUNTER::UnSetUserNotifiers(USER_PTR user) { // Removing user. Removing notifiers from user. -list::iterator bi; -list::iterator ai; +std::list::iterator bi; +std::list::iterator ai; bi = ipBeforeNotifiers.begin(); while (bi != ipBeforeNotifiers.end()) @@ -552,7 +557,7 @@ bool foundD = false; // Was rule for D found ? enum { ICMP_RPOTO = 1, TCP_PROTO = 6, UDP_PROTO = 17 }; -list::const_iterator ln; +std::list::const_iterator ln; ln = rules.begin(); while (ln != rules.end()) @@ -662,7 +667,7 @@ if (!foundD) return; }; //----------------------------------------------------------------------------- -void TRAFFCOUNTER::SetRulesFile(const string & fn) +void TRAFFCOUNTER::SetRulesFile(const std::string & fn) { rulesFileName = fn; } @@ -930,7 +935,7 @@ printf("dir=%d \n", rule.dir); return; } //----------------------------------------------------------------------------- -void TRAFFCOUNTER::SetMonitorDir(const string & monitorDir) +void TRAFFCOUNTER::SetMonitorDir(const std::string & monitorDir) { TRAFFCOUNTER::monitorDir = monitorDir; monitoring = (monitorDir != ""); diff --git a/projects/stargazer/traffcounter.h b/projects/stargazer/traffcounter.h index 2742a7ec..d6a56881 100644 --- a/projects/stargazer/traffcounter.h +++ b/projects/stargazer/traffcounter.h @@ -44,6 +44,8 @@ #define PROTOMAX (5) +class TARIFFS; + //----------------------------------------------------------------------------- struct RULE { @@ -85,9 +87,9 @@ PACKET_EXTRA_DATA(const PACKET_EXTRA_DATA & pp) time_t flushTime; // Last flush time time_t updateTime; // Last update time -user_iter userU; // Uploader +USER_PTR userU; // Uploader bool userUPresent; // Uploader is registered user -user_iter userD; // Downloader +USER_PTR userD; // Downloader bool userDPresent; // Downloader is registered user int dirU; // Upload direction int dirD; // Download direction @@ -100,56 +102,56 @@ class TRAFFCOUNTER; class TRF_IP_BEFORE: public PROPERTY_NOTIFIER_BASE { public: - TRF_IP_BEFORE(TRAFFCOUNTER & t, user_iter u) + TRF_IP_BEFORE(TRAFFCOUNTER & t, USER_PTR u) : PROPERTY_NOTIFIER_BASE(), traffCnt(t), user(u) {}; void Notify(const uint32_t & oldValue, const uint32_t & newValue); - void SetUser(user_iter u) { user = u; } - user_iter GetUser() const { return user; } + void SetUser(USER_PTR u) { user = u; } + USER_PTR GetUser() const { return user; } private: TRAFFCOUNTER & traffCnt; - user_iter user; + USER_PTR user; }; //----------------------------------------------------------------------------- class TRF_IP_AFTER: public PROPERTY_NOTIFIER_BASE { public: - TRF_IP_AFTER(TRAFFCOUNTER & t, user_iter u) + TRF_IP_AFTER(TRAFFCOUNTER & t, USER_PTR u) : PROPERTY_NOTIFIER_BASE(), traffCnt(t), user(u) {}; void Notify(const uint32_t & oldValue, const uint32_t & newValue); - void SetUser(user_iter u) { user = u; } - user_iter GetUser() const { return user; } + void SetUser(USER_PTR u) { user = u; } + USER_PTR GetUser() const { return user; } private: TRAFFCOUNTER & traffCnt; - user_iter user; + USER_PTR user; }; //----------------------------------------------------------------------------- -class ADD_USER_NONIFIER: public NOTIFIER_BASE +class ADD_USER_NONIFIER: public NOTIFIER_BASE { public: ADD_USER_NONIFIER(TRAFFCOUNTER & t) : - NOTIFIER_BASE(), + NOTIFIER_BASE(), traffCnt(t) {}; virtual ~ADD_USER_NONIFIER(){}; - void Notify(const user_iter & user); + void Notify(const USER_PTR & user); private: TRAFFCOUNTER & traffCnt; }; //----------------------------------------------------------------------------- -class DEL_USER_NONIFIER: public NOTIFIER_BASE +class DEL_USER_NONIFIER: public NOTIFIER_BASE { public: DEL_USER_NONIFIER(TRAFFCOUNTER & t) : - NOTIFIER_BASE(), + NOTIFIER_BASE(), traffCnt(t) {}; virtual ~DEL_USER_NONIFIER(){}; - void Notify(const user_iter & user); + void Notify(const USER_PTR & user); private: TRAFFCOUNTER & traffCnt; }; @@ -188,10 +190,10 @@ private: void FlushAndRemove(); - void AddUser(user_iter user); + void AddUser(USER_PTR user); void DelUser(uint32_t uip); - void SetUserNotifiers(user_iter user); - void UnSetUserNotifiers(user_iter user); + void SetUserNotifiers(USER_PTR user); + void UnSetUserNotifiers(USER_PTR user); std::list rules; typedef std::list::iterator rule_iter; @@ -247,13 +249,13 @@ EVENT_LOOP_SINGLETON::GetInstance().Enqueue(traffCnt, &TRAFFCOUNTER::AddUser, us } //----------------------------------------------------------------------------- inline -void ADD_USER_NONIFIER::Notify(const user_iter & user) +void ADD_USER_NONIFIER::Notify(const USER_PTR & user) { EVENT_LOOP_SINGLETON::GetInstance().Enqueue(traffCnt, &TRAFFCOUNTER::SetUserNotifiers, user); } //----------------------------------------------------------------------------- inline -void DEL_USER_NONIFIER::Notify(const user_iter & user) +void DEL_USER_NONIFIER::Notify(const USER_PTR & user) { EVENT_LOOP_SINGLETON::GetInstance().Enqueue(traffCnt, &TRAFFCOUNTER::UnSetUserNotifiers, user); EVENT_LOOP_SINGLETON::GetInstance().Enqueue(traffCnt, &TRAFFCOUNTER::DelUser, user->GetCurrIP()); diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp index f18dd76e..0d6cfa84 100644 --- a/projects/stargazer/user_impl.cpp +++ b/projects/stargazer/user_impl.cpp @@ -47,7 +47,7 @@ #include "admin.h" USER_IMPL::USER_IMPL(const SETTINGS * s, - const BASE_STORE * st, + const STORE * st, const TARIFFS * t, const ADMIN & a, const USERS * u) @@ -351,7 +351,7 @@ if (store->SaveMonthStat(stat, t1.tm_mon, t1.tm_year, login)) return 0; } //----------------------------------------------------------------------------- -int USER_IMPL::Authorize(uint32_t ip, const string &, uint32_t dirs, const BASE_AUTH * auth) +int USER_IMPL::Authorize(uint32_t ip, uint32_t dirs, const AUTH * auth) { STG_LOCKER lock(&mutex, __FILE__, __LINE__); /* @@ -424,7 +424,7 @@ ScanMessage(); return 0; } //----------------------------------------------------------------------------- -void USER_IMPL::Unauthorize(const BASE_AUTH * auth) +void USER_IMPL::Unauthorize(const AUTH * auth) { STG_LOCKER lock(&mutex, __FILE__, __LINE__); /* @@ -441,7 +441,7 @@ if (authorizedBy.empty()) } } //----------------------------------------------------------------------------- -bool USER_IMPL::IsAuthorizedBy(const BASE_AUTH * auth) const +bool USER_IMPL::IsAuthorizedBy(const AUTH * auth) const { STG_LOCKER lock(&mutex, __FILE__, __LINE__); // Is this user authorized by specified authorizer? @@ -1190,7 +1190,7 @@ int USER_IMPL::SendMessage(STG_MSG & msg) const { // No lock `cause we are already locked from caller int ret = -1; -set::iterator it(authorizedBy.begin()); +set::iterator it(authorizedBy.begin()); while (it != authorizedBy.end()) { if (!(*it++)->SendMessage(msg, currIP)) diff --git a/projects/stargazer/user_impl.h b/projects/stargazer/user_impl.h index dc21f696..ad5b4516 100644 --- a/projects/stargazer/user_impl.h +++ b/projects/stargazer/user_impl.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include "user.h" @@ -40,12 +39,10 @@ #include "user_conf.h" #include "user_ips.h" #include "user_property.h" -#include "base_auth.h" +#include "auth.h" #include "stg_message.h" #include "noncopyable.h" -using namespace std; - //----------------------------------------------------------------------------- class TARIFF; class TARIFFS; @@ -69,11 +66,11 @@ private: USER_IMPL * user; }; //----------------------------------------------------------------------------- -class CHG_TARIFF_NOTIFIER : public PROPERTY_NOTIFIER_BASE, +class CHG_TARIFF_NOTIFIER : public PROPERTY_NOTIFIER_BASE, private NONCOPYABLE { public: CHG_TARIFF_NOTIFIER(USER_IMPL * u) : user(u) {} - void Notify(const string & oldTariff, const string & newTariff); + void Notify(const std::string & oldTariff, const std::string & newTariff); private: USER_IMPL * user; @@ -106,7 +103,7 @@ friend class CHG_CASH_NOTIFIER; friend class CHG_IP_NOTIFIER; public: USER_IMPL(const SETTINGS * settings, - const BASE_STORE * store, + const STORE * store, const TARIFFS * tariffs, const ADMIN & sysAdmin, const USERS * u); @@ -119,8 +116,8 @@ public: int WriteStat(); int WriteMonthStat(); - string const & GetLogin() const { return login; } - void SetLogin(string const & l); + std::string const & GetLogin() const { return login; } + void SetLogin(std::string const & l); uint32_t GetCurrIP() const { return currIP; } time_t GetCurrIPModificationTime() const { return currIP.ModificationTime(); } @@ -156,9 +153,9 @@ public: bool GetConnected() const { return connected; } time_t GetConnectedModificationTime() const { return connected.ModificationTime(); } int GetAuthorized() const { return authorizedBy.size(); } - int Authorize(uint32_t ip, const string & iface, uint32_t enabledDirs, const BASE_AUTH * auth); - void Unauthorize(const BASE_AUTH * auth); - bool IsAuthorizedBy(const BASE_AUTH * auth) const; + int Authorize(uint32_t ip, uint32_t enabledDirs, const AUTH * auth); + void Unauthorize(const AUTH * auth); + bool IsAuthorizedBy(const AUTH * auth) const; int AddMessage(STG_MSG * msg); @@ -168,7 +165,7 @@ public: void PrintUser() const; void Run(); - const string & GetStrError() const { return errorStr; } + const std::string & GetStrError() const { return errorStr; } USER_PROPERTIES & GetProperty() { return property; }; const USER_PROPERTIES & GetProperty() const { return property; }; @@ -185,7 +182,7 @@ public: void ProcessNewMonth(); bool IsInetable(); - string GetEnabledDirs(); + std::string GetEnabledDirs(); void OnAdd(); void OnDelete(); @@ -204,7 +201,7 @@ private: time_t lastScanMessages; - string login; + std::string login; int id; bool __connected; USER_PROPERTY connected; @@ -225,7 +222,7 @@ private: time_t pingTime; const ADMIN & sysAdmin; - const BASE_STORE * store; + const STORE * store; const TARIFFS * tariffs; const TARIFF * tariff; @@ -235,9 +232,9 @@ private: const SETTINGS * settings; - set authorizedBy; + std::set authorizedBy; - list messages; + std::list messages; bool deleted; @@ -253,32 +250,32 @@ private: USER_PROPERTY & lastCashAddTime; USER_PROPERTY & freeMb; USER_PROPERTY & lastActivityTime; - USER_PROPERTY & password; + USER_PROPERTY & password; USER_PROPERTY & passive; USER_PROPERTY & disabled; USER_PROPERTY & disabledDetailStat; USER_PROPERTY & alwaysOnline; - USER_PROPERTY & tariffName; - USER_PROPERTY & nextTariff; - USER_PROPERTY & address; - USER_PROPERTY & note; - USER_PROPERTY & group; - USER_PROPERTY & email; - USER_PROPERTY & phone; - USER_PROPERTY & realName; + USER_PROPERTY & tariffName; + USER_PROPERTY & nextTariff; + USER_PROPERTY & address; + USER_PROPERTY & note; + USER_PROPERTY & group; + USER_PROPERTY & email; + USER_PROPERTY & phone; + USER_PROPERTY & realName; USER_PROPERTY & credit; USER_PROPERTY & creditExpire; USER_PROPERTY & ips; - USER_PROPERTY & userdata0; - USER_PROPERTY & userdata1; - USER_PROPERTY & userdata2; - USER_PROPERTY & userdata3; - USER_PROPERTY & userdata4; - USER_PROPERTY & userdata5; - USER_PROPERTY & userdata6; - USER_PROPERTY & userdata7; - USER_PROPERTY & userdata8; - USER_PROPERTY & userdata9; + USER_PROPERTY & userdata0; + USER_PROPERTY & userdata1; + USER_PROPERTY & userdata2; + USER_PROPERTY & userdata3; + USER_PROPERTY & userdata4; + USER_PROPERTY & userdata5; + USER_PROPERTY & userdata6; + USER_PROPERTY & userdata7; + USER_PROPERTY & userdata8; + USER_PROPERTY & userdata9; // End properties @@ -292,7 +289,7 @@ private: mutable pthread_mutex_t mutex; - string errorStr; + std::string errorStr; }; //----------------------------------------------------------------------------- diff --git a/projects/stargazer/user_property.h b/projects/stargazer/user_property.h index 3ea1be45..704f371e 100644 --- a/projects/stargazer/user_property.h +++ b/projects/stargazer/user_property.h @@ -4,7 +4,6 @@ $Date: 2010/09/13 05:54:43 $ $Author: faust $ */ - #ifndef USER_PROPERTY_H #define USER_PROPERTY_H @@ -15,7 +14,7 @@ $Author: faust $ #include #include -#include "base_store.h" +#include "store.h" #include "stg_logger.h" #include "admin.h" #include "settings.h" @@ -24,20 +23,20 @@ $Author: faust $ #include "stg_locker.h" #include "script_executer.h" -using namespace std; - extern const volatile time_t stgTime; //----------------------------------------------------------------------------- template -class USER_PROPERTY - { +class USER_PROPERTY { public: USER_PROPERTY(varT& val); - USER_PROPERTY& operator= (const varT&); - USER_PROPERTY& operator-= (const varT&); virtual ~USER_PROPERTY(); + void Set(const varT & rvalue); + + USER_PROPERTY& operator= (const varT & rvalue); + USER_PROPERTY& operator-= (const varT & rvalue); + const varT * operator&() const throw(); const varT& ConstData() const throw(); @@ -46,8 +45,6 @@ public: return value; } - //bool IsEmpty() const throw(); - void AddBeforeNotifier(PROPERTY_NOTIFIER_BASE * n); void DelBeforeNotifier(PROPERTY_NOTIFIER_BASE * n); @@ -57,20 +54,18 @@ public: time_t ModificationTime() const throw(); void ModifyTime() throw(); -protected: +private: varT & value; time_t modificationTime; - //typedef set *>::iterator notifier_iter_t; - mutable set *> beforeNotifiers; - mutable set *> afterNotifiers; + set *> beforeNotifiers; + set *> afterNotifiers; mutable pthread_mutex_t mutex; - }; +}; //----------------------------------------------------------------------------- template -class USER_PROPERTY_LOGGED: public USER_PROPERTY - { +class USER_PROPERTY_LOGGED: public USER_PROPERTY { public: - USER_PROPERTY_LOGGED(varT& val, + USER_PROPERTY_LOGGED(varT & val, const string n, bool isPassword, bool isStat, @@ -78,27 +73,26 @@ public: const SETTINGS * s); virtual ~USER_PROPERTY_LOGGED(); - //operator const varT&() const throw();; USER_PROPERTY_LOGGED * GetPointer() throw(); const varT & Get() const; const string & GetName() const; bool Set(const varT & val, const ADMIN & admin, const string & login, - const BASE_STORE * store, + const STORE * store, const string & msg = ""); -protected: +private: void WriteAccessDenied(const string & login, - const ADMIN & admin, + const ADMIN & admin, const string & parameter); - void WriteSuccessChange(const string & login, - const ADMIN & admin, - const string & parameter, - const string & oldValue, - const string & newValue, - const string & msg, - const BASE_STORE * store); + void WriteSuccessChange(const string & login, + const ADMIN & admin, + const string & parameter, + const string & oldValue, + const string & newValue, + const string & msg, + const STORE * store); void OnChange(const string & login, const string & paramName, @@ -112,11 +106,9 @@ protected: mutable pthread_mutex_t mutex; STG_LOGGER & stgLogger; // server's logger const SETTINGS * settings; - }; +}; //----------------------------------------------------------------------------- -class USER_PROPERTIES - { - friend class USER; +class USER_PROPERTIES { /* В этом месте важен порядок следования приватной и открытой частей. Это связано с тем, что часть которая находится в публичной секции @@ -132,6 +124,8 @@ private: public: USER_PROPERTIES(const SETTINGS * settings); + USER_STAT & Stat() { return stat; } + USER_CONF & Conf() { return conf; } const USER_STAT & GetStat() const { return stat; } const USER_CONF & GetConf() const { return conf; } void SetStat(const USER_STAT & s) { stat = s; } @@ -174,8 +168,7 @@ public: USER_PROPERTY_LOGGED userdata7; USER_PROPERTY_LOGGED userdata8; USER_PROPERTY_LOGGED userdata9; - }; - +}; //============================================================================= //----------------------------------------------------------------------------- @@ -183,8 +176,7 @@ public: //----------------------------------------------------------------------------- template USER_PROPERTY::USER_PROPERTY(varT& val) -: -value(val) + : value(val) { pthread_mutex_init(&mutex, NULL); modificationTime = stgTime; @@ -202,77 +194,53 @@ void USER_PROPERTY::ModifyTime() throw() } //----------------------------------------------------------------------------- template -USER_PROPERTY& USER_PROPERTY::operator= (const varT& newValue) +void USER_PROPERTY::Set(const varT & rvalue) { STG_LOCKER locker(&mutex, __FILE__, __LINE__); -/* -TODO -if (value == newValue) - return *this;*/ - typename set *>::iterator ni; varT oldVal = value; ni = beforeNotifiers.begin(); while (ni != beforeNotifiers.end()) - (*ni++)->Notify(oldVal, newValue); + (*ni++)->Notify(oldVal, rvalue); -value = newValue; +value = rvalue; modificationTime = stgTime; ni = afterNotifiers.begin(); while (ni != afterNotifiers.end()) - (*ni++)->Notify(oldVal, newValue); - + (*ni++)->Notify(oldVal, rvalue); +} +//----------------------------------------------------------------------------- +template +USER_PROPERTY& USER_PROPERTY::operator= (const varT & newValue) +{ +Set(newValue); return *this; } //----------------------------------------------------------------------------- template -USER_PROPERTY& USER_PROPERTY::operator-= (const varT& delta) +USER_PROPERTY& USER_PROPERTY::operator-= (const varT & delta) { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); - -typename set *>::iterator ni; - -varT oldVal = value; - -ni = beforeNotifiers.begin(); -while (ni != beforeNotifiers.end()) - (*ni++)->Notify(oldVal, oldVal - delta); - -value -= delta; -modificationTime = stgTime; - -ni = afterNotifiers.begin(); -while (ni != afterNotifiers.end()) - (*ni++)->Notify(oldVal, value); - +varT newValue = ConstData() - delta; +Set(newValue); return *this; } //----------------------------------------------------------------------------- template const varT * USER_PROPERTY::operator&() const throw() { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); return &value; } //----------------------------------------------------------------------------- template const varT& USER_PROPERTY::ConstData() const throw() { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); return value; } //----------------------------------------------------------------------------- -/*template -bool USER_PROPERTY::IsEmpty() const throw() -{ -STG_LOCKER locker(&mutex, __FILE__, __LINE__); -return !is_set; -}*/ -//----------------------------------------------------------------------------- template void USER_PROPERTY::AddBeforeNotifier(PROPERTY_NOTIFIER_BASE * n) { @@ -304,27 +272,24 @@ afterNotifiers.erase(n); template time_t USER_PROPERTY::ModificationTime() const throw() { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); return modificationTime; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- template -USER_PROPERTY_LOGGED::USER_PROPERTY_LOGGED( - varT& val, - string n, - bool isPass, - bool isSt, - STG_LOGGER & logger, - const SETTINGS * s) - -:USER_PROPERTY(val), -stgLogger(logger) +USER_PROPERTY_LOGGED::USER_PROPERTY_LOGGED(varT& val, + string n, + bool isPass, + bool isSt, + STG_LOGGER & logger, + const SETTINGS * s) + + : USER_PROPERTY(val), + stgLogger(logger) { pthread_mutex_init(&mutex, NULL); STG_LOCKER locker(&mutex, __FILE__, __LINE__); -USER_PROPERTY::value = val; isPassword = isPass; isStat = isSt; name = n; @@ -334,27 +299,23 @@ settings = s; template USER_PROPERTY_LOGGED::~USER_PROPERTY_LOGGED() { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); } //----------------------------------------------------------------------------- template USER_PROPERTY_LOGGED * USER_PROPERTY_LOGGED::GetPointer() throw() { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); return this; } //----------------------------------------------------------------------------- template const varT & USER_PROPERTY_LOGGED::Get() const { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); -return USER_PROPERTY::value; +return USER_PROPERTY::ConstData(); }; //------------------------------------------------------------------------- template const string & USER_PROPERTY_LOGGED::GetName() const { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); return name; }; //------------------------------------------------------------------------- @@ -362,7 +323,7 @@ template bool USER_PROPERTY_LOGGED::Set(const varT & val, const ADMIN & admin, const string & login, - const BASE_STORE * store, + const STORE * store, const string & msg) { STG_LOCKER locker(&mutex, __FILE__, __LINE__); @@ -373,7 +334,7 @@ STG_LOCKER locker(&mutex, __FILE__, __LINE__); const PRIV * priv = admin.GetPriv(); string adm_login = admin.GetLogin(); -string adm_ip = admin.GetAdminIPStr(); +string adm_ip = admin.GetIPStr(); if ((priv->userConf && !isStat) || (priv->userStat && isStat) || (priv->userPasswd && isPassword) || (priv->userCash && name == "cash")) { @@ -383,7 +344,7 @@ if ((priv->userConf && !isStat) || (priv->userStat && isStat) || (priv->userPass oldVal.flags(oldVal.flags() | ios::fixed); newVal.flags(newVal.flags() | ios::fixed); - oldVal << USER_PROPERTY::value; + oldVal << USER_PROPERTY::ConstData(); newVal << val; OnChange(login, name, oldVal.str(), newVal.str(), admin); @@ -396,7 +357,7 @@ if ((priv->userConf && !isStat) || (priv->userStat && isStat) || (priv->userPass { WriteSuccessChange(login, admin, name, oldVal.str(), newVal.str(), msg, store); } - USER_PROPERTY::operator =(val); + USER_PROPERTY::Set(val); return true; } else @@ -418,12 +379,12 @@ stgLogger("%s Change user \'%s.\' Parameter \'%s\'. Access denied.", //------------------------------------------------------------------------- template void USER_PROPERTY_LOGGED::WriteSuccessChange(const string & login, - const ADMIN & admin, - const string & parameter, - const string & oldValue, - const string & newValue, - const string & msg, - const BASE_STORE * store) + const ADMIN & admin, + const string & parameter, + const string & oldValue, + const string & newValue, + const string & msg, + const STORE * store) { stgLogger("%s User \'%s\': \'%s\' parameter changed from \'%s\' to \'%s\'. %s", admin.GetLogStr().c_str(), @@ -433,7 +394,7 @@ stgLogger("%s User \'%s\': \'%s\' parameter changed from \'%s\' to \'%s\'. %s", newValue.c_str(), msg.c_str()); -store->WriteUserChgLog(login, admin.GetLogin(), admin.GetAdminIP(), parameter, oldValue, newValue, msg); +store->WriteUserChgLog(login, admin.GetLogin(), admin.GetIP(), parameter, oldValue, newValue, msg); } //------------------------------------------------------------------------- template @@ -449,7 +410,7 @@ str1 = settings->GetConfDir() + "/OnChange"; if (access(str1.c_str(), X_OK) == 0) { - string str2("\"" + str1 + "\" \"" + login + "\" \"" + paramName + "\" \"" + oldValue + "\" \"" + newValue + "\" \"" + admin.GetLogin() + "\" \"" + admin.GetAdminIPStr() + "\""); + string str2("\"" + str1 + "\" \"" + login + "\" \"" + paramName + "\" \"" + oldValue + "\" \"" + newValue + "\" \"" + admin.GetLogin() + "\" \"" + admin.GetIPStr() + "\""); ScriptExec(str2); } else @@ -460,20 +421,18 @@ else //------------------------------------------------------------------------- //------------------------------------------------------------------------- //------------------------------------------------------------------------- -template +/*template stringstream & operator<< (stringstream & s, const USER_PROPERTY & v) { s << v.ConstData(); return s; -} +}*/ //----------------------------------------------------------------------------- template -ostream & operator<< (ostream & o, const USER_PROPERTY & v) +ostream & operator<< (ostream & stream, const USER_PROPERTY & value) { -return o << v.ConstData(); +return stream << value.ConstData(); } //----------------------------------------------------------------------------- - #endif // USER_PROPERTY_H - diff --git a/projects/stargazer/users_impl.h b/projects/stargazer/users_impl.h index 2e0b5296..966487df 100644 --- a/projects/stargazer/users_impl.h +++ b/projects/stargazer/users_impl.h @@ -38,7 +38,7 @@ $Author: faust $ #include "os_int.h" -#include "base_store.h" +#include "store.h" #include "settings.h" #include "users.h" #include "user.h" @@ -92,7 +92,7 @@ class USERS_IMPL : private NONCOPYABLE, public USERS { friend class PROPERTY_NOTIFER_IP_AFTER; public: - USERS_IMPL(SETTINGS * s, BASE_STORE * store, TARIFFS * tariffs, const ADMIN & sysAdmin); + USERS_IMPL(SETTINGS * s, STORE * store, TARIFFS * tariffs, const ADMIN & sysAdmin); virtual ~USERS_IMPL(); int FindByName(const std::string & login, USER_PTR * user); @@ -153,7 +153,7 @@ private: SETTINGS * settings; TARIFFS * tariffs; - BASE_STORE * store; + STORE * store; const ADMIN & sysAdmin; STG_LOGGER & WriteServLog;