//-----------------------------------------------------------------------------
ADMIN_IMPL::ADMIN_IMPL()
- : ADMIN(),
- conf(),
- ip(0)
+ : ip(0)
{
}
//-----------------------------------------------------------------------------
ADMIN_IMPL::ADMIN_IMPL(const ADMIN_CONF & ac)
- : ADMIN(),
- conf(ac),
+ : conf(ac),
ip(0)
{
}
ADMIN_IMPL::ADMIN_IMPL(const PRIV & priv,
const std::string & login,
const std::string & password)
- : ADMIN(),
- conf(priv, login, password),
+ : conf(priv, login, password),
ip(0)
{
}
//-----------------------------------------------------------------------------
-ADMIN_IMPL & ADMIN_IMPL::operator=(const ADMIN_IMPL & adm)
-{
-if (&adm == this)
- return *this;
-
-conf = adm.conf;
-ip = adm.ip;
-return *this;
-}
-//-----------------------------------------------------------------------------
ADMIN_IMPL & ADMIN_IMPL::operator=(const ADMIN_CONF & ac)
{
conf = ac;
const std::string & password);
virtual ~ADMIN_IMPL() {}
- ADMIN_IMPL & operator=(const ADMIN_IMPL &);
ADMIN_IMPL & operator=(const ADMIN_CONF &);
bool operator==(const ADMIN_IMPL & rhs) const;
bool operator!=(const ADMIN_IMPL & rhs) const;
-#include <cstdio>
-#include <cassert>
-#include <csignal>
-#include <ctime>
-#include <algorithm>
+#include "ping.h"
#include "stg/user.h"
#include "stg/locker.h"
#include "stg/user_property.h"
#include "stg/plugin_creator.h"
-#include "ping.h"
+
+#include <cstdio>
+#include <cassert>
+#include <csignal>
+#include <ctime>
+#include <algorithm>
namespace
{
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-// ëÌÁÓÓ ÄÌÑ ÐÏÉÓËÁ ÀÚÅÒÁ × ÓÐÉÓËÅ ÎÏÔÉÆÉËÁÔÏÒÏ×
template <typename varType>
-class IS_CONTAINS_USER: public std::binary_function<varType, USER_PTR, bool>
+class HAS_USER: public std::binary_function<varType, USER_PTR, bool>
{
public:
- IS_CONTAINS_USER(const USER_PTR & u) : user(u) {}
+ explicit HAS_USER(const USER_PTR & u) : user(u) {}
bool operator()(varType notifier) const
{
return notifier.GetUser() == user;
ping->isRunning = true;
long delay = (10000000 * ping->pingSettings.GetPingDelay()) / 3 + 50000000;
-
+
while (ping->nonstop)
{
std::list<USER_PTR>::iterator iter = ping->usersList.begin();
void PING::UnSetUserNotifiers(USER_PTR u)
{
// --- CurrIP ---
-IS_CONTAINS_USER<CHG_CURRIP_NOTIFIER_PING> IsContainsUserCurrIP(u);
-IS_CONTAINS_USER<CHG_IPS_NOTIFIER_PING> IsContainsUserIP(u);
+HAS_USER<CHG_CURRIP_NOTIFIER_PING> IsContainsUserCurrIP(u);
+HAS_USER<CHG_IPS_NOTIFIER_PING> IsContainsUserIP(u);
std::list<CHG_CURRIP_NOTIFIER_PING>::iterator currIPter;
std::list<CHG_IPS_NOTIFIER_PING>::iterator IPIter;
{
uint32_t ip = u->GetCurrIP();
if (ip)
- {
pinger.AddIP(ip);
- }
}
}
{
ping.pinger.DelIP(oldIP);
if (newIP)
- {
ping.pinger.AddIP(newIP);
- }
}
//-----------------------------------------------------------------------------
void CHG_IPS_NOTIFIER_PING::Notify(const USER_IPS & oldIPS, const USER_IPS & newIPS)
{
if (oldIPS.OnlyOneIP())
- {
ping.pinger.DelIP(oldIPS[0].ip);
- }
if (newIPS.OnlyOneIP())
- {
ping.pinger.AddIP(newIPS[0].ip);
- }
}
//-----------------------------------------------------------------------------
void ADD_USER_NONIFIER_PING::Notify(const USER_PTR & user)
class CHG_CURRIP_NOTIFIER_PING: public PROPERTY_NOTIFIER_BASE<uint32_t> {
public:
CHG_CURRIP_NOTIFIER_PING(const PING & p, USER_PTR u)
- : PROPERTY_NOTIFIER_BASE<uint32_t>(), user(u), ping(p) {}
- CHG_CURRIP_NOTIFIER_PING(const CHG_CURRIP_NOTIFIER_PING & rvalue)
- : PROPERTY_NOTIFIER_BASE<uint32_t>(),
- user(rvalue.user), ping(rvalue.ping) {}
+ : user(u), ping(p) {}
void Notify(const uint32_t & oldIP, const uint32_t & newIP);
USER_PTR GetUser() const { return user; }
private:
- CHG_CURRIP_NOTIFIER_PING & operator=(const CHG_CURRIP_NOTIFIER_PING & rvalue);
+ CHG_CURRIP_NOTIFIER_PING & operator=(const CHG_CURRIP_NOTIFIER_PING &);
USER_PTR user;
const PING & ping;
class CHG_IPS_NOTIFIER_PING: public PROPERTY_NOTIFIER_BASE<USER_IPS> {
public:
CHG_IPS_NOTIFIER_PING(const PING & p, USER_PTR u)
- : PROPERTY_NOTIFIER_BASE<USER_IPS>(), user(u), ping(p) {}
- CHG_IPS_NOTIFIER_PING(const CHG_IPS_NOTIFIER_PING & rvalue)
- : PROPERTY_NOTIFIER_BASE<USER_IPS>(),
- user(rvalue.user), ping(rvalue.ping) {}
+ : user(u), ping(p) {}
void Notify(const USER_IPS & oldIPS, const USER_IPS & newIPS);
USER_PTR GetUser() const { return user; }
private:
- CHG_IPS_NOTIFIER_PING & operator=(const CHG_IPS_NOTIFIER_PING & rvalue);
+ CHG_IPS_NOTIFIER_PING & operator=(const CHG_IPS_NOTIFIER_PING &);
USER_PTR user;
const PING & ping;
//-----------------------------------------------------------------------------
class ADD_USER_NONIFIER_PING: public NOTIFIER_BASE<USER_PTR> {
public:
- explicit ADD_USER_NONIFIER_PING(PING & p) : NOTIFIER_BASE<USER_PTR>(), ping(p) {}
- virtual ~ADD_USER_NONIFIER_PING() {}
+ explicit ADD_USER_NONIFIER_PING(PING & p) : ping(p) {}
void Notify(const USER_PTR & user);
private:
- ADD_USER_NONIFIER_PING(const ADD_USER_NONIFIER_PING & rvalue);
- ADD_USER_NONIFIER_PING & operator=(const ADD_USER_NONIFIER_PING & rvalue);
+ ADD_USER_NONIFIER_PING(const ADD_USER_NONIFIER_PING &);
+ ADD_USER_NONIFIER_PING & operator=(const ADD_USER_NONIFIER_PING &);
PING & ping;
};
//-----------------------------------------------------------------------------
class DEL_USER_NONIFIER_PING: public NOTIFIER_BASE<USER_PTR> {
public:
- explicit DEL_USER_NONIFIER_PING(PING & p) : NOTIFIER_BASE<USER_PTR>(), ping(p) {}
- virtual ~DEL_USER_NONIFIER_PING() {}
+ explicit DEL_USER_NONIFIER_PING(PING & p) : ping(p) {}
void Notify(const USER_PTR & user);
private:
- DEL_USER_NONIFIER_PING(const DEL_USER_NONIFIER_PING & rvalue);
- DEL_USER_NONIFIER_PING & operator=(const DEL_USER_NONIFIER_PING & rvalue);
+ DEL_USER_NONIFIER_PING(const DEL_USER_NONIFIER_PING &);
+ DEL_USER_NONIFIER_PING & operator=(const DEL_USER_NONIFIER_PING &);
PING & ping;
};
//-----------------------------------------------------------------------------
class PING_SETTINGS {
public:
- PING_SETTINGS() : pingDelay(0), errorStr() {}
- virtual ~PING_SETTINGS() {}
+ PING_SETTINGS() : pingDelay(0) {}
const std::string & GetStrError() const { return errorStr; }
int ParseSettings(const MODULE_SETTINGS & s);
int GetPingDelay() const { return pingDelay; }
$Author: faust $
*/
-#include <ctime>
-#include <algorithm> // std::max
-
-#include "stg/common.h"
#include "tariff_impl.h"
+
#include "stg_timer.h"
+#include "stg/common.h"
+
+#include <ctime>
+#include <algorithm> // std::max
//-----------------------------------------------------------------------------
TARIFF_IMPL & TARIFF_IMPL::operator=(const TARIFF_DATA & td)
return *this;
}
//-----------------------------------------------------------------------------
-TARIFF_IMPL & TARIFF_IMPL::operator=(const TARIFF_IMPL & t)
-{
-tariffData = t.tariffData;
-return *this;
-}
-//-----------------------------------------------------------------------------
double TARIFF_IMPL::GetPriceWithTraffType(uint64_t up,
uint64_t down,
int dir,
class TARIFF_IMPL : public TARIFF {
public:
- TARIFF_IMPL()
- : TARIFF(),
- tariffData()
- {}
explicit TARIFF_IMPL(const std::string & name)
: TARIFF(),
tariffData(name)
const TARIFF_DATA & GetTariffData() const { return tariffData; }
TARIFF_IMPL & operator=(const TARIFF_DATA & td);
- TARIFF_IMPL & operator=(const TARIFF_IMPL & t);
bool operator==(const TARIFF_IMPL & rhs) const { return GetName() == rhs.GetName(); }
bool operator!=(const TARIFF_IMPL & rhs) const { return GetName() != rhs.GetName(); }
std::string TariffChangeIsAllowed(const TARIFF & to, time_t currentTime) const;
//-----------------------------------------------------------------------------
TRAFFCOUNTER_IMPL::TRAFFCOUNTER_IMPL(USERS_IMPL * u, const std::string & fn)
- : TRAFFCOUNTER(),
- rules(),
- packets(),
- ip2packets(),
- dirName(),
- WriteServLog(GetStgLogger()),
+ : WriteServLog(GetStgLogger()),
rulesFileName(fn),
- monitorDir(),
monitoring(false),
touchTimeP(stgTime - MONITOR_TIME_DELAY_SEC),
users(u),
running(false),
stopped(true),
- mutex(),
- thread(),
- ipBeforeNotifiers(),
- ipAfterNotifiers(),
addUserNotifier(*this),
delUserNotifier(*this)
{
USER_IMPL * u;
while (users->SearchNext(h, &u) == 0)
- {
SetUserNotifiers(u);
- }
users->CloseSearch(h);
running = true;
USER_IMPL * u;
while (users->SearchNext(h, &u) == 0)
- {
UnSetUserNotifiers(u);
- }
users->CloseSearch(h);
//5 seconds to thread stops itself
{
if (pi.first->second->first.GetSrcIP() == uip)
{
- assert((!pi.first->second->second.userUPresent ||
+ assert((!pi.first->second->second.userUPresent ||
pi.first->second->second.userU == user) &&
"U user present but it's not current user");
if (pi.first->second->first.GetDstIP() == uip)
{
- assert((!pi.first->second->second.userDPresent ||
+ assert((!pi.first->second->second.userDPresent ||
pi.first->second->second.userD == user) &&
"D user present but it's not current user");
rule->ip = ipaddr.s_addr;
rule->mask = CalcMask(msk);
-//msk = 1;
-//printfd(__FILE__, "msk=%d mask=%08X mask=%08X\n", msk, rule->mask, (0xFFffFFff << (32 - msk)));
if ((ipaddr.s_addr & rule->mask) != ipaddr.s_addr)
{
lenD(0)
{}
-PACKET_EXTRA_DATA(const PACKET_EXTRA_DATA & pp)
- : flushTime(pp.flushTime),
- updateTime(pp.updateTime),
- userU(pp.userU),
- userUPresent(pp.userUPresent),
- userD(pp.userD),
- userDPresent(pp.userDPresent),
- dirU(pp.dirU),
- dirD(pp.dirD),
- lenU(pp.lenU),
- lenD(pp.lenD)
-{}
-
time_t flushTime; // Last flush time
time_t updateTime; // Last update time
USER_IMPL * userU; // Uploader
size_t RulesCount() const { return rules.size(); }
private:
- TRAFFCOUNTER_IMPL(const TRAFFCOUNTER_IMPL & rvalue);
- TRAFFCOUNTER_IMPL & operator=(const TRAFFCOUNTER_IMPL & rvalue);
+ TRAFFCOUNTER_IMPL(const TRAFFCOUNTER_IMPL &);
+ TRAFFCOUNTER_IMPL & operator=(const TRAFFCOUNTER_IMPL &);
bool ParseAddress(const char * ta, RULE * rule) const;
uint32_t CalcMask(uint32_t msk) const;