]> git.stg.codes - stg.git/commitdiff
Added last disconnect reason and last authorization time.
authorMaxim Mamontov <faust.madf@gmail.com>
Mon, 5 Aug 2013 16:56:57 +0000 (19:56 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Mon, 5 Aug 2013 16:56:57 +0000 (19:56 +0300)
include/stg/user.h
projects/stargazer/user_impl.cpp
projects/stargazer/user_impl.h

index 0adb342ae9261841017370c169398e22449f981a..1fa4920179e6a2a55505c9f14be141db9d17c61e 100644 (file)
@@ -74,11 +74,10 @@ public:
 
     virtual bool                GetConnected() const = 0;
     virtual time_t              GetConnectedModificationTime() const = 0;
 
     virtual bool                GetConnected() const = 0;
     virtual time_t              GetConnectedModificationTime() const = 0;
+    virtual const std::string & GetLastDisconnectReason() const = 0;
     virtual int                 GetAuthorized() const = 0;
     virtual int                 GetAuthorized() const = 0;
-    /*virtual int                 Authorize(uint32_t ip,
-                                          uint32_t enabledDirs,
-                                          const AUTH * auth) = 0;
-    virtual void                Unauthorize(const AUTH * auth) = 0;*/
+    virtual time_t              GetAuthorizedModificationTime() const = 0;
+
     virtual bool                IsAuthorizedBy(const AUTH * auth) const = 0;
     virtual std::vector<std::string> GetAuthorizers() const = 0;
 
     virtual bool                IsAuthorizedBy(const AUTH * auth) const = 0;
     virtual std::vector<std::string> GetAuthorizers() const = 0;
 
index 5bb0069fb6f04b79a476001e135d09ddd7a3176d..f6bf007003c4f541a976ea822c86f864393ce3fa 100644 (file)
@@ -62,12 +62,9 @@ USER_IMPL::USER_IMPL(const SETTINGS * s,
       property(s->GetScriptsDir()),
       WriteServLog(GetStgLogger()),
       lastScanMessages(0),
       property(s->GetScriptsDir()),
       WriteServLog(GetStgLogger()),
       lastScanMessages(0),
-      login(),
       id(0),
       __connected(0),
       connected(__connected),
       id(0),
       __connected(0),
       connected(__connected),
-      enabledDirs(),
-      userIDGenerator(),
       __currIP(0),
       currIP(__currIP),
       lastIPForDisconnect(0),
       __currIP(0),
       currIP(__currIP),
       lastIPForDisconnect(0),
@@ -76,11 +73,8 @@ USER_IMPL::USER_IMPL(const SETTINGS * s,
       store(st),
       tariffs(t),
       tariff(NULL),
       store(st),
       tariffs(t),
       tariff(NULL),
-      traffStat(),
-      traffStatSaved(),
       settings(s),
       settings(s),
-      authorizedBy(),
-      messages(),
+      authorizedModificationTime(0),
       deleted(false),
       lastWriteStat(0),
       lastWriteDetailedStat(0),
       deleted(false),
       lastWriteStat(0),
       lastWriteDetailedStat(0),
@@ -118,14 +112,10 @@ USER_IMPL::USER_IMPL(const SETTINGS * s,
       userdata7(property.userdata7),
       userdata8(property.userdata8),
       userdata9(property.userdata9),
       userdata7(property.userdata7),
       userdata8(property.userdata8),
       userdata9(property.userdata9),
-      sessionUpload(),
-      sessionDownload(),
       passiveNotifier(this),
       tariffNotifier(this),
       cashNotifier(this),
       passiveNotifier(this),
       tariffNotifier(this),
       cashNotifier(this),
-      ipNotifier(this),
-      mutex(),
-      errorStr()
+      ipNotifier(this)
 {
 password = "*_EMPTY_PASSWORD_*";
 tariffName = NO_TARIFF_NAME;
 {
 password = "*_EMPTY_PASSWORD_*";
 tariffName = NO_TARIFF_NAME;
@@ -155,12 +145,9 @@ USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s,
       property(s->GetScriptsDir()),
       WriteServLog(GetStgLogger()),
       lastScanMessages(0),
       property(s->GetScriptsDir()),
       WriteServLog(GetStgLogger()),
       lastScanMessages(0),
-      login(),
       id(0),
       __connected(0),
       connected(__connected),
       id(0),
       __connected(0),
       connected(__connected),
-      enabledDirs(),
-      userIDGenerator(),
       __currIP(0),
       currIP(__currIP),
       lastIPForDisconnect(0),
       __currIP(0),
       currIP(__currIP),
       lastIPForDisconnect(0),
@@ -169,11 +156,8 @@ USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s,
       store(st),
       tariffs(t),
       tariff(NULL),
       store(st),
       tariffs(t),
       tariff(NULL),
-      traffStat(),
-      traffStatSaved(),
       settings(s),
       settings(s),
-      authorizedBy(),
-      messages(),
+      authorizedModificationTime(0),
       deleted(false),
       lastWriteStat(0),
       lastWriteDetailedStat(0),
       deleted(false),
       lastWriteStat(0),
       lastWriteDetailedStat(0),
@@ -211,15 +195,11 @@ USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s,
       userdata7(property.userdata7),
       userdata8(property.userdata8),
       userdata9(property.userdata9),
       userdata7(property.userdata7),
       userdata8(property.userdata8),
       userdata9(property.userdata9),
-      sessionUpload(),
-      sessionDownload(),
       passiveNotifier(this),
       disabledNotifier(this),
       tariffNotifier(this),
       cashNotifier(this),
       passiveNotifier(this),
       disabledNotifier(this),
       tariffNotifier(this),
       cashNotifier(this),
-      ipNotifier(this),
-      mutex(),
-      errorStr()
+      ipNotifier(this)
 {
 password = "*_EMPTY_PASSWORD_*";
 tariffName = NO_TARIFF_NAME;
 {
 password = "*_EMPTY_PASSWORD_*";
 tariffName = NO_TARIFF_NAME;
@@ -250,7 +230,6 @@ USER_IMPL::USER_IMPL(const USER_IMPL & u)
       id(u.id),
       __connected(0),
       connected(__connected),
       id(u.id),
       __connected(0),
       connected(__connected),
-      enabledDirs(),
       userIDGenerator(u.userIDGenerator),
       __currIP(u.__currIP),
       currIP(__currIP),
       userIDGenerator(u.userIDGenerator),
       __currIP(u.__currIP),
       currIP(__currIP),
@@ -263,7 +242,7 @@ USER_IMPL::USER_IMPL(const USER_IMPL & u)
       traffStat(u.traffStat),
       traffStatSaved(u.traffStatSaved),
       settings(u.settings),
       traffStat(u.traffStat),
       traffStatSaved(u.traffStatSaved),
       settings(u.settings),
-      authorizedBy(),
+      authorizedModificationTime(u.authorizedModificationTime),
       messages(u.messages),
       deleted(u.deleted),
       lastWriteStat(u.lastWriteStat),
       messages(u.messages),
       deleted(u.deleted),
       lastWriteStat(u.lastWriteStat),
@@ -308,9 +287,7 @@ USER_IMPL::USER_IMPL(const USER_IMPL & u)
       disabledNotifier(this),
       tariffNotifier(this),
       cashNotifier(this),
       disabledNotifier(this),
       tariffNotifier(this),
       cashNotifier(this),
-      ipNotifier(this),
-      mutex(),
-      errorStr()
+      ipNotifier(this)
 {
 if (&u == this)
     return;
 {
 if (&u == this)
     return;
@@ -537,6 +514,8 @@ else
         }
     }
 
         }
     }
 
+if (authorizedBy.empty())
+    authorizedModificationTime = stgTime;
 authorizedBy.insert(auth);
 
 ScanMessage();
 authorizedBy.insert(auth);
 
 ScanMessage();
@@ -555,6 +534,7 @@ if (!authorizedBy.erase(auth))
 
 if (authorizedBy.empty())
     {
 
 if (authorizedBy.empty())
     {
+    authorizedModificationTime = stgTime;
     lastIPForDisconnect = currIP;
     currIP = 0; // DelUser in traffcounter
     return;
     lastIPForDisconnect = currIP;
     currIP = 0; // DelUser in traffcounter
     return;
@@ -642,6 +622,7 @@ if (!lastIPForDisconnect)
 
 if (!fakeDisconnect)
     {
 
 if (!fakeDisconnect)
     {
+    lastDisconnectReason = reason;
     std::string scriptOnDisonnect = settings->GetScriptsDir() + "/OnDisconnect";
 
     if (access(scriptOnDisonnect.c_str(), X_OK) == 0)
     std::string scriptOnDisonnect = settings->GetScriptsDir() + "/OnDisconnect";
 
     if (access(scriptOnDisonnect.c_str(), X_OK) == 0)
index a581f2e55c48f586d98017e69c016e36ba7b8b2c..412816c34154a67716208fe8b620fb3c3cecfa3c 100644 (file)
@@ -183,7 +183,9 @@ public:
 
     bool            GetConnected() const { return connected; }
     time_t          GetConnectedModificationTime() const { return connected.ModificationTime(); }
 
     bool            GetConnected() const { return connected; }
     time_t          GetConnectedModificationTime() const { return connected.ModificationTime(); }
+    const std::string & GetLastDisconnectReason() const { return lastDisconnectReason; }
     int             GetAuthorized() const { return static_cast<int>(authorizedBy.size()); }
     int             GetAuthorized() const { return static_cast<int>(authorizedBy.size()); }
+    time_t          GetAuthorizedModificationTime() const { return authorizedModificationTime; }
     int             Authorize(uint32_t ip, uint32_t enabledDirs, const AUTH * auth);
     void            Unauthorize(const AUTH * auth);
     bool            IsAuthorizedBy(const 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;
@@ -240,6 +242,7 @@ private:
     int             id;
     bool            __connected;
     USER_PROPERTY<bool> connected;
     int             id;
     bool            __connected;
     USER_PROPERTY<bool> connected;
+    std::string     lastDisconnectReason;
 
     bool            enabledDirs[DIR_NUM];
 
 
     bool            enabledDirs[DIR_NUM];
 
@@ -268,6 +271,7 @@ private:
 #endif
 
     std::set<const AUTH *> authorizedBy;
 #endif
 
     std::set<const AUTH *> authorizedBy;
+    time_t          authorizedModificationTime;
 
     std::list<STG_MSG> messages;
 
 
     std::list<STG_MSG> messages;