X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/37324ea9b8c06d96b9383be993da02a01f103253..21ba4dfad49d2d489a9399d36d078eab8c44e0d6:/projects/stargazer/plugins/other/radius/radius.h?ds=sidebyside diff --git a/projects/stargazer/plugins/other/radius/radius.h b/projects/stargazer/plugins/other/radius/radius.h index 4e06e463..80e032a8 100644 --- a/projects/stargazer/plugins/other/radius/radius.h +++ b/projects/stargazer/plugins/other/radius/radius.h @@ -1,39 +1,114 @@ #pragma once #include "stg/auth.h" +#include "stg/plugin.h" +#include "stg/module_settings.h" +#include "stg/subscriptions.h" #include "stg/logger.h" +#include "server.h" +#include #include +#include #include #include +#include //uint8_t, uint32_t namespace STG { + struct Settings; + + class Users; + + class RAD_SETTINGS + { + public: + RAD_SETTINGS(); + virtual ~RAD_SETTINGS() {} + + struct AttrValue + { + enum class Type + { + PARAM_NAME, + VALUE + }; + std::string value; + Type type; + }; + + struct ASection + { + using Pairs = std::vector>; + Pairs match; + Pairs send; + }; + + const std::string& GetStrError() const { return m_errorStr; } + int ParseSettings(const ModuleSettings& s); + + uint16_t GetPort() const { return m_port; } + const std::string& GetDictionaries() const { return m_dictionaries; } + const std::string& GetSecret() const { return m_secret; } + const ASection& getAuth() const { return m_auth; } + const ASection& getAutz() const { return m_autz; } + + private: + std::vector> ParseRules(const std::string& value, const std::string& paramName); + ASection parseASection(const std::vector& conf); + + std::string m_errorStr; + uint16_t m_port; + std::string m_dictionaries; + std::string m_secret; + + ASection m_auth; + ASection m_autz; + + PluginLogger m_logger; + }; + class RADIUS : public Auth { public: RADIUS(); + RADIUS(const RADIUS&) = delete; + RADIUS& operator=(const RADIUS&) = delete; + + void SetUsers(Users* u) override { m_users = u; } + void SetSettings(const ModuleSettings& s) override { m_settings = s; } + int ParseSettings() override; int Start() override; int Stop() override; - int Reload(const ModuleSettings & /*ms*/) override { return 0; } + 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; } + + 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; } + int SendMessage(const Message& /*msg*/, uint32_t /*ip*/) const override { return 0; } private: std::mutex m_mutex; + + boost::asio::io_context m_ioContext; + int Run(std::stop_token token); + mutable std::string m_errorStr; - std::jthread m_thread; + RAD_SETTINGS m_radSettings; + ModuleSettings m_settings; + bool m_running; + + std::jthread m_thread; + Users* m_users; PluginLogger m_logger; - int Run(std::stop_token token); + std::unique_ptr m_server; }; }