property.tariffName.AddBeforeNotifier(&tariffNotifier);
property.passive.AddBeforeNotifier(&passiveNotifier);
property.cash.AddBeforeNotifier(&cashNotifier);
-currIP.AddAfterNotifier(&ipNotifier);
+ips.AddAfterNotifier(&ipNotifier);
lastScanMessages = 0;
property.tariffName.AddBeforeNotifier(&tariffNotifier);
property.passive.AddBeforeNotifier(&passiveNotifier);
property.cash.AddBeforeNotifier(&cashNotifier);
-currIP.AddAfterNotifier(&ipNotifier);
+ips.AddAfterNotifier(&ipNotifier);
lastScanMessages = 0;
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
USER_STAT stat(property.GetStat());
-printfd(__FILE__, "USER::WriteStat()\n");
-
if (store->SaveUserStat(stat, login))
{
WriteServLog("Cannot write stat for user %s.", login.c_str());
if (currIP != ip)
{
// We are already authorized, but with different IP address
- errorStr = "User " + login + " alredy authorized with IP address " + inet_ntostring(ip);
+ errorStr = "User " + login + " already authorized with IP address " + inet_ntostring(ip);
return -1;
}
// If it's not our IP - throw an error
if (u != this)
{
- errorStr = "IP address " + inet_ntostring(ip) + " alredy in use";
+ errorStr = "IP address " + inet_ntostring(ip) + " already in use";
return -1;
}
}
if (users->IsIPInIndex(ip))
{
// Address is already present in IP-index
- errorStr = "IP address " + inet_ntostring(ip) + " alredy in use";
+ errorStr = "IP address " + inet_ntostring(ip) + " already in use";
return -1;
}
user->lastCashAdd = newCash - oldCash;
}
//-----------------------------------------------------------------------------
-void CHG_IP_NOTIFIER::Notify(const uint32_t & from, const uint32_t & to)
+void CHG_IPS_NOTIFIER::Notify(const USER_IPS & from, const USER_IPS & to)
{
- printfd(__FILE__, "Change IP from %s to %s\n", inet_ntostring(from).c_str(), inet_ntostring(to).c_str());
- if (from != 0)
- if (user->connected)
- user->Disconnect(false, "Change IP");
- if (to != 0)
- if (user->IsInetable())
- user->Connect(false);
+ printfd(__FILE__, "Change IP from '%s' to '%s'\n", from.GetIpStr().c_str(), to.GetIpStr().c_str());
+ if (user->connected)
+ user->Disconnect(true, "Change IP");
+ if (user->IsInetable())
+ user->Connect(true);
}
//-----------------------------------------------------------------------------
USER_IMPL * user;
};
//-----------------------------------------------------------------------------
-class CHG_IP_NOTIFIER : public PROPERTY_NOTIFIER_BASE<uint32_t>,
- private NONCOPYABLE {
+class CHG_IPS_NOTIFIER : public PROPERTY_NOTIFIER_BASE<USER_IPS>,
+ private NONCOPYABLE {
public:
- CHG_IP_NOTIFIER(USER_IMPL * u) : user(u) {}
- void Notify(const uint32_t & oldCash, const uint32_t & newCash);
+ CHG_IPS_NOTIFIER(USER_IMPL * u) : user(u) {}
+ void Notify(const USER_IPS & oldIPs, const USER_IPS & newIPs);
private:
USER_IMPL * user;
friend class CHG_PASSIVE_NOTIFIER;
friend class CHG_TARIFF_NOTIFIER;
friend class CHG_CASH_NOTIFIER;
-friend class CHG_IP_NOTIFIER;
+friend class CHG_IPS_NOTIFIER;
public:
USER_IMPL(const SETTINGS_IMPL * settings,
const STORE * store,
CHG_PASSIVE_NOTIFIER passiveNotifier;
CHG_TARIFF_NOTIFIER tariffNotifier;
CHG_CASH_NOTIFIER cashNotifier;
- CHG_IP_NOTIFIER ipNotifier;
+ CHG_IPS_NOTIFIER ipNotifier;
mutable pthread_mutex_t mutex;