#include "stg_message.h"
#include "noncopyable.h"
-class AUTH : public PLUGIN, private NONCOPYABLE {
+class AUTH : public PLUGIN {
public:
virtual int SendMessage(const STG_MSG & msg, uint32_t ip) const = 0;
};
+++ /dev/null
- /*
- $Revision: 1.5 $
- $Date: 2010/03/04 11:49:52 $
- $Author: faust $
- */
-
-#ifndef MODULE_SETTINGS_H
-#define MODULE_SETTINGS_H
-
-#include <cstring> // strcasecmp
-#include <string>
-#include <vector>
-
-//-----------------------------------------------------------------------------
-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<std::string> 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<PARAM_VALUE> moduleParams;
-};
-//-----------------------------------------------------------------------------
-#endif
--- /dev/null
+ /*
+ $Revision: 1.5 $
+ $Date: 2010/03/04 11:49:52 $
+ $Author: faust $
+ */
+
+#ifndef MODULE_SETTINGS_H
+#define MODULE_SETTINGS_H
+
+#include <cstring> // strcasecmp
+#include <string>
+#include <vector>
+
+//-----------------------------------------------------------------------------
+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<std::string> 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<PARAM_VALUE> moduleParams;
+};
+//-----------------------------------------------------------------------------
+#endif
#include "service_conf.h"
#include "admin_conf.h"
#include "tariff_conf.h"
-#include "settings.h"
+#include "module_settings.h"
#include "stg_message.h"
//-----------------------------------------------------------------------------
#include "os_int.h"
#include "notifer.h"
-#include "auth.h"
#include "stg_message.h"
#include "tariff.h"
#include "user_traff.h"
class USER_PROPERTIES;
+class AUTH;
class USER {
public:
STORE * (*GetSourceStore)();
STORE * (*GetDestStore)();
-GetSourceStore = (BASE_STORE * (*)())dlsym(src_lh, "GetStore");
+GetSourceStore = (STORE * (*)())dlsym(src_lh, "GetStore");
if (!GetSourceStore)
{
printfd(__FILE__, "Source storage plugin loading failed. GetStore not found: %s\n", dlerror());
delete settings;
return -1;
}
-GetDestStore = (BASE_STORE * (*)())dlsym(dst_lh, "GetStore");
+GetDestStore = (STORE * (*)())dlsym(dst_lh, "GetStore");
if (!GetDestStore)
{
printfd(__FILE__, "Storage plugin (firebird) loading failed. GetStore not found: %s\n", dlerror());
using namespace std;
//-----------------------------------------------------------------------------
-ADMINS_IMPL::ADMINS_IMPL(BASE_STORE * st)
+ADMINS_IMPL::ADMINS_IMPL(STORE * st)
: stg(0xFFFF, "@stargazer", ""),
noAdmin(0xFFFF, "NO-ADMIN", ""),
data(),
#include "tariffs_impl.h"
#include "common.h"
#include "traffcounter.h"
-#include "base_plugin.h"
+#include "plugin.h"
#include "stg_logger.h"
#include "stg_timer.h"
#include "plugin_runner.h"
* */
SETTINGS * settings = NULL;
-BASE_STORE * dataStore = NULL;
+STORE * dataStore = NULL;
TARIFFS * tariffs = NULL;
ADMINS * admins = NULL;
USERS * users = NULL;
TARIFFS * t,
USERS * u,
TRAFFCOUNTER * tc,
- BASE_STORE * st,
+ STORE * st,
const SETTINGS * s)
: pluginFileName(pFileName),
pluginSettingFileName(),
USER_IPS ips = u->GetProperty().ips;
if (ips.OnlyOneIP())
{
- if (u->Authorize(ips[0].ip, "", 0xFFffFFff, this) == 0)
+ if (u->Authorize(ips[0].ip, 0xFFffFFff, this) == 0)
{
}
}
iaUser->phase.UpdateTime();
iaUser->lastSendAlive = iaUser->phase.GetTime();
- if (iaUser->user->Authorize(sip, "", enabledDirs, this) == 0)
+ if (iaUser->user->Authorize(sip, enabledDirs, this) == 0)
{
iaUser->phase.SetPhase3();
printfd(__FILE__, "Phase changed from 2 to 3. Reason: CONN_ACK_6\n");
{
iaUser->phase.UpdateTime();
iaUser->lastSendAlive = iaUser->phase.GetTime();
- if (iaUser->user->Authorize(sip, "", enabledDirs, this) == 0)
+ if (iaUser->user->Authorize(sip, enabledDirs, this) == 0)
{
iaUser->phase.SetPhase3();
printfd(__FILE__, "Phase changed from 2 to 3. Reason: CONN_ACK_8\n");
#include <cerrno>
#include <cstring>
+#include <vector>
+
#include "common.h"
#include "cap_nf.h"
#include "raw_ip_packet.h"
int NF_CAP::ParseSettings()
{
-vector<PARAM_VALUE>::iterator it;
+std::vector<PARAM_VALUE>::iterator it;
for (it = settings.moduleParams.begin(); it != settings.moduleParams.end(); ++it)
{
if (it->param == "TCPPort")
int Stop();
int Reload() { return 0; }
bool IsRunning() { return runningTCP || runningUDP; }
- const string & GetStrError() const { return errorStr; }
- const string GetVersion() const { return VERSION; }
+ const std::string & GetStrError() const { return errorStr; }
+ const std::string GetVersion() const { return VERSION; }
uint16_t GetStartPosition() const { return START_POS; }
uint16_t GetStopPosition() const { return STOP_POS; }
void SetSettings(const MODULE_SETTINGS &) {}
int ParseSettings() { return 0; }
- 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;
int IPQCapRead(void * buffer, int blen);
struct ipq_handle * ipq_h;
- mutable string errorStr;
+ mutable std::string errorStr;
pthread_t thread;
bool nonstop;
}
}
//-----------------------------------------------------------------------------
-void CONFIGPROTO::SetStore(BASE_STORE * s)
+void CONFIGPROTO::SetStore(STORE * s)
{
for (unsigned int i = 0; i < dataParser.size(); i++)
{
admins = a;
}
//-----------------------------------------------------------------------------
-void STG_CONFIG::SetStore(BASE_STORE * s)
+void STG_CONFIG::SetStore(STORE * s)
{
store = s;
}
}
}
//-----------------------------------------------------------------------------
-void CONFIGPROTO::SetStore(BASE_STORE * s)
+void CONFIGPROTO::SetStore(STORE * s)
{
store = s;
for (unsigned int i = 0; i < dataParser.size(); i++)
return -1;
}
USER_IPS ips = ui->GetProperty().ips;
- if (ui->Authorize(ips[0].ip, "", 0xffFFffFF, this))
+ if (ui->Authorize(ips[0].ip, 0xffFFffFF, this))
{
printfd(__FILE__, "RADIUS::ProcessAcctStartPacket cannot authorize user '%s'\n", packet->login);
packet->packetType = RAD_REJECT_PACKET;
RS_SETTINGS();
virtual ~RS_SETTINGS() {}
const std::string & GetStrError() const { return errorStr; }
- int ParseSettings(const MODULE_SETTINGS & s)
+ int ParseSettings(const MODULE_SETTINGS & s);
int GetSendPeriod() const { return sendPeriod; }
int GetPort() const { return port; }
const std::vector<NET_ROUTER> & GetSubnetsMap() const { return netRouters; }
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-BASE_STORE * GetStore()
+STORE * GetStore()
{
return fsc.GetStore();
}
} frsc;
//-----------------------------------------------------------------------------
-BASE_STORE * GetStore()
+STORE * GetStore()
{
return frsc.GetStore();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-BASE_STORE * GetStore()
+STORE * GetStore()
{
return msc.GetStore();
}
#include "postgresql_store.h"
#include "postgresql_store_utils.h"
-#include "base_settings.h"
+#include "module_settings.h"
class POSTGRESQL_STORE_CREATOR
{
} pqStoreeCreator;
//-----------------------------------------------------------------------------
-BASE_STORE * GetStore()
+STORE * GetStore()
{
return pqStoreeCreator.GetStore();
}
double cash,
double freeMb,
const std::string & reason) const;
- int WriteDetailedStat(const std::map<IP_DIR_PAIR, STAT_NODE> & statTree,
+ int WriteDetailedStat(const TRAFF_STAT & statTree,
time_t lastStat,
const std::string & login) const;
#ifndef SETTINGS_H
#define SETTINGS_H
+#include <string>
#include <vector>
#include "common.h"
-#include "base_settings.h"
-
-using namespace std;
+#include "stg_logger.h"
+#include "module_settings.h"
//-----------------------------------------------------------------------------
-enum DETAIL_STAT_PERIOD
-{
+enum DETAIL_STAT_PERIOD {
dsPeriod_1,
dsPeriod_1_2,
dsPeriod_1_4,
class STG_LOGGER;
class DOTCONFDocumentNode;
//-----------------------------------------------------------------------------
-class SETTINGS
-{
+class SETTINGS {
public:
SETTINGS();
SETTINGS(const std::string &);
SETTINGS(const SETTINGS &);
virtual ~SETTINGS();
- int Reload() { return ReadSettings(); };
+ int Reload() { return ReadSettings(); }
int ReadSettings();
- string GetStrError() const { return strError; };
-
- int GetExecMsgKey() const { return stgExecMsgKey; };
- unsigned GetExecutersNum() const { return executersNum; };
- const string & GetDirName(int num) const { return dirName[num]; };
- const string & GetConfDir() const { return confDir; };
- const string & GetScriptDir() const { return scriptDir; };
- const string & GetRulesFileName() const { return rules; };
- const string & GetLogFileName() const { return logFile; };
- const string & GetPIDFileName() const { return pidFile; };
- unsigned GetDetailStatWritePeriod() const
+ std::string GetStrError() const { return strError; }
+
+ int GetExecMsgKey() const { return stgExecMsgKey; }
+ unsigned GetExecutersNum() const { return executersNum; }
+ const std::string & GetDirName(int num) const { return dirName[num]; };
+ const std::string & GetConfDir() const { return confDir; }
+ const std::string & GetScriptDir() const { return scriptDir; }
+ const std::string & GetRulesFileName() const { return rules; }
+ const std::string & GetLogFileName() const { return logFile; }
+ const std::string & GetPIDFileName() const { return pidFile; }
+ unsigned GetDetailStatWritePeriod() const
{ return detailStatWritePeriod; };
- unsigned GetStatWritePeriod() const { return statWritePeriod * 60; };
- unsigned GetDayFee() const { return dayFee; };
- bool GetFullFee() const { return fullFee; };
- unsigned GetDayResetTraff() const { return dayResetTraff; };
- bool GetSpreadFee() const { return spreadFee; };
- bool GetFreeMbAllowInet() const { return freeMbAllowInet; };
- bool GetDayFeeIsLastDay() const { return dayFeeIsLastDay; };
- bool GetWriteFreeMbTraffCost() const
+ unsigned GetStatWritePeriod() const { return statWritePeriod * 60; }
+ unsigned GetDayFee() const { return dayFee; }
+ bool GetFullFee() const { return fullFee; }
+ unsigned GetDayResetTraff() const { return dayResetTraff; }
+ bool GetSpreadFee() const { return spreadFee; }
+ bool GetFreeMbAllowInet() const { return freeMbAllowInet; }
+ bool GetDayFeeIsLastDay() const { return dayFeeIsLastDay; }
+ bool GetWriteFreeMbTraffCost() const
{ return writeFreeMbTraffCost; };
- bool GetShowFeeInCash() const { return showFeeInCash; };
- const string & GetMonitorDir() const { return monitorDir; };
- bool GetMonitoring() const { return monitoring; };
- unsigned GetMessageTimeout() const { return messageTimeout * 3600 * 24; };
+ bool GetShowFeeInCash() const { return showFeeInCash; }
+ const std::string & GetMonitorDir() const { return monitorDir; }
+ bool GetMonitoring() const { return monitoring; }
+ unsigned GetMessageTimeout() const { return messageTimeout * 3600 * 24; }
- const string & GetModulesPath() const { return modulesPath; };
+ const std::string & GetModulesPath() const { return modulesPath; }
const MODULE_SETTINGS & GetStoreModuleSettings() const
- { return storeModuleSettings; };
- const vector<MODULE_SETTINGS> & GetModulesSettings() const
- { return modulesSettings; };
+ { return storeModuleSettings; }
+ const std::vector<MODULE_SETTINGS> & GetModulesSettings() const
+ { return modulesSettings; }
private:
- int ParseInt(const string & value, int * val);
- int ParseUnsigned(const string & value, unsigned * val);
- int ParseIntInRange(const string & value, int min, int max, int * val);
- int ParseUnsignedInRange(const string & value, unsigned min, unsigned max, unsigned * val);
- int ParseYesNo(const string & value, bool * val);
- int ParseDetailStatWritePeriod(const string & detailStatPeriodStr);
+ int ParseInt(const std::string & value, int * val);
+ int ParseUnsigned(const std::string & value, unsigned * val);
+ int ParseIntInRange(const std::string & value, int min, int max, int * val);
+ int ParseUnsignedInRange(const std::string & value, unsigned min, unsigned max, unsigned * val);
+ int ParseYesNo(const std::string & value, bool * val);
+ int ParseDetailStatWritePeriod(const std::string & detailStatPeriodStr);
- int ParseModuleSettings(const DOTCONFDocumentNode * dirNameNode, vector<PARAM_VALUE> * params);
+ int ParseModuleSettings(const DOTCONFDocumentNode * dirNameNode, std::vector<PARAM_VALUE> * params);
static void ErrorCallback(void * data, const char * buf);
- string strError;
+ std::string strError;
//////////settings
- string modulesPath;
- string dirName[DIR_NUM];
- string confDir;
- string scriptDir;
- string rules;
- string logFile;
- string pidFile;
- string monitorDir;
+ std::string modulesPath;
+ std::string dirName[DIR_NUM];
+ std::string confDir;
+ std::string scriptDir;
+ std::string rules;
+ std::string logFile;
+ std::string pidFile;
+ std::string monitorDir;
bool monitoring;
unsigned detailStatWritePeriod;
unsigned statWritePeriod;
bool showFeeInCash; // ðÏËÁÚÙ×ÁÔØ ÐÏÌØÚÏ×ÁÔÅÌÀ áð ÎÅ ÓÞÅÔÕ É ÐÏÚ×ÏÌÑÔØ ÅÅ ÉÓÐÏÌØÚÏ×ÁÔØ
unsigned messageTimeout; // ÷ÒÅÍÑ ÖÉÚÎÉ ÎÅÏÔÐÒÁ×ÌÅÎÎÏÇÏ ÓÏÏÂÝÅÎÉÑ × ÓÅËÕÎÄÁÈ
- vector<MODULE_SETTINGS> modulesSettings;
- MODULE_SETTINGS storeModuleSettings;
+ std::vector<MODULE_SETTINGS> modulesSettings;
+ MODULE_SETTINGS storeModuleSettings;
STG_LOGGER & logger;
};
isLoaded = true;
-BASE_STORE * (*GetStore)();
-GetStore = (BASE_STORE * (*)())dlsym(handle, "GetStore");
+STORE * (*GetStore)();
+GetStore = (STORE * (*)())dlsym(handle, "GetStore");
if (!GetStore)
{
errorStr = "GetStore not found.";
//#define USERS_DEBUG 1
//-----------------------------------------------------------------------------
-USERS_IMPL::USERS_IMPL(SETTINGS * s, BASE_STORE * st, TARIFFS * t, const ADMIN & sa)
+USERS_IMPL::USERS_IMPL(SETTINGS * s, STORE * st, TARIFFS * t, const ADMIN & sa)
: users(),
usersToDelete(),
userIPNotifiersBefore(),