-public:
- RADIUS();
- virtual ~RADIUS(){};
-
- void SetUsers(USERS * u);
- void SetTariffs(TARIFFS *){};
- void SetAdmins(ADMINS *){};
- void SetTraffcounter(TRAFFCOUNTER *){};
- void SetStore(BASE_STORE * );
- void SetStgSettings(const SETTINGS * s);
- void SetSettings(const MODULE_SETTINGS & s);
- int ParseSettings();
-
- int Start();
- int Stop();
- int Reload() { return 0; };
- bool IsRunning();
-
- const string & GetStrError() const { return errorStr; };
- const string GetVersion() const;
- uint16_t GetStartPosition() const;
- uint16_t GetStopPosition() const;
-
- int SendMessage(const STG_MSG &, uint32_t) const { return 0; };
-
-private:
- static void * Run(void *);
- int PrepareNet();
- int FinalizeNet();
-
- int Send(const RAD_PACKET & packet, struct sockaddr_in * outerAddr);
- int RecvData(RAD_PACKET * packet, struct sockaddr_in * outerAddr);
- int ProcessData(RAD_PACKET * packet);
-
- int ProcessAutzPacket(RAD_PACKET * packet);
- int ProcessAuthPacket(RAD_PACKET * packet);
- int ProcessPostAuthPacket(RAD_PACKET * packet);
- int ProcessAcctStartPacket(RAD_PACKET * packet);
- int ProcessAcctStopPacket(RAD_PACKET * packet);
- int ProcessAcctUpdatePacket(RAD_PACKET * packet);
- int ProcessAcctOtherPacket(RAD_PACKET * packet);
-
- bool FindUser(user_iter * ui, const std::string & login) const;
- bool CanAuthService(const std::string & svc) const;
- bool CanAcctService(const std::string & svc) const;
- bool IsAllowedService(const std::string & svc) const;
-
- bool WaitPackets(int sd) const;
-
- void PrintServices(const std::list<std::string> & svcs);
-
- struct Printer : public unary_function<std::string, void>
- {
- void operator()(const std::string & line)
- {
- printfd("radius.cpp", "'%s'\n", line.c_str());
- };
- };
- struct SPrinter : public unary_function<std::pair<std::string, RAD_SESSION>, void>
- {
- void operator()(const std::pair<std::string, RAD_SESSION> & it)
- {
- printfd("radius.cpp", "%s - ('%s', '%s')\n", it.first.c_str(), it.second.userName.c_str(), it.second.serviceType.c_str());
- };
+ class RADIUS : public Auth
+ {
+ public:
+ RADIUS();
+
+ int Start() override;
+ int Stop() override;
+ int Reload(const ModuleSettings & /*ms*/) override { return 0; }
+ bool IsRunning() override;
+ void SetRunning(bool val);
+ int ParseSettings() override { return 0; }
+ const std::string & GetStrError() const override { return m_errorStr; }
+ std::string GetVersion() const override;
+ uint16_t GetStartPosition() const override { return 0; }
+ uint16_t GetStopPosition() const override { return 0; }
+
+ int SendMessage(const Message & msg, uint32_t ip) const override { return 0; }
+
+ private:
+ std::mutex m_mutex;
+ mutable std::string m_errorStr;
+ std::jthread m_thread;
+ bool m_running;
+ PluginLogger m_logger;
+
+ int Run(std::stop_token token);