]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/radius/radius.h
Merge branch 'stg-2.409-radius'
[stg.git] / projects / stargazer / plugins / other / radius / radius.h
index ff8ecf5e08410839cf5ab08fad3396bf5110afd7..52da138ec6eeab1a21c25e71e3e2eed31d14740a 100644 (file)
 #include "stg/module_settings.h"
 #include "stg/logger.h"
 
+#include "config.h"
+#include "conn.h"
+
 #include <string>
+#include <deque>
+#include <set>
 
 #include <pthread.h>
 #include <unistd.h>
@@ -43,36 +48,44 @@ public:
     RADIUS();
     virtual ~RADIUS() {}
 
-    void SetUsers(USERS* u) { users = u; }
-    void SetStore(STORE* s) { store = s; }
+    void SetUsers(USERS* u) { m_users = u; }
+    void SetStore(STORE* s) { m_store = s; }
     void SetStgSettings(const SETTINGS*) {}
-    void SetSettings(const MODULE_SETTINGS& s) { settings = s; }
+    void SetSettings(const MODULE_SETTINGS& s) { m_settings = s; }
     int ParseSettings();
 
     int Start();
     int Stop();
-    int Reload() { return 0; }
+    int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; }
     bool IsRunning() { return m_running; }
 
     const std::string& GetStrError() const { return m_error; }
-    std::string GetVersion() const { return "RADIUS data access plugin v 1.0"; }
+    std::string GetVersion() const { return "RADIUS data access plugin v. 2.0"; }
     uint16_t GetStartPosition() const { return 30; }
     uint16_t GetStopPosition() const { return 30; }
 
     int SendMessage(const STG_MSG&, uint32_t) const { return 0; }
 
+    void authorize(const USER& user);
+    void unauthorize(const std::string& login, const std::string& reason);
+
 private:
     RADIUS(const RADIUS & rvalue);
     RADIUS & operator=(const RADIUS & rvalue);
 
     static void* run(void*);
 
-    void rumImpl();
+    bool reconnect();
+    int createUNIX() const;
+    int createTCP() const;
+    void runImpl();
     int maxFD() const;
     void buildFDSet(fd_set & fds) const;
     void cleanupConns();
     void handleEvents(const fd_set & fds);
     void acceptConnection();
+    void acceptUNIX();
+    void acceptTCP();
 
     mutable std::string m_error;
     STG::Config m_config;
@@ -85,8 +98,11 @@ private:
     USERS* m_users;
     const STORE* m_store;
 
+    int m_listenSocket;
+    std::deque<STG::Conn*> m_conns;
+    std::set<std::string> m_logins;
+
     pthread_t m_thread;
-    pthread_mutex_t m_mutex;
 
     PLUGIN_LOGGER m_logger;
 };