]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/other/radius/radius.h
Sending attributes from <auth>/send section. (#13)
[stg.git] / projects / stargazer / plugins / other / radius / radius.h
1 #pragma once
2
3 #include "stg/auth.h"
4 #include "stg/plugin.h"
5 #include "config.h"
6 #include "stg/module_settings.h"
7 #include "stg/subscriptions.h"
8 #include "stg/logger.h"
9 #include "server.h"
10
11 #include <boost/asio.hpp>
12 #include <string>
13 #include <memory>
14 #include <mutex>
15 #include <jthread.hpp>
16 #include <cstdint> //uint8_t, uint32_t
17
18 namespace STG
19 {
20     class Users;
21
22     class RADIUS : public Auth
23     {
24         public:
25             RADIUS();
26             RADIUS(const RADIUS&) = delete;
27             RADIUS& operator=(const RADIUS&) = delete;
28
29             void SetUsers(Users* u) override { m_users = u; }
30             void SetSettings(const ModuleSettings& s) override { m_settings = s; }
31             int ParseSettings() override;
32
33             int Start() override;
34             int Stop() override;
35             int Reload(const ModuleSettings& /*ms*/) override { return 0; }
36             bool IsRunning() override;
37
38             const std::string& GetStrError() const override { return m_errorStr; }
39             std::string GetVersion() const override;
40
41             uint16_t GetStartPosition() const override { return 0; }
42             uint16_t GetStopPosition() const override { return 0; }
43
44             int SendMessage(const Message& /*msg*/, uint32_t /*ip*/) const override { return 0; }
45
46         private:
47             std::mutex m_mutex;
48
49             boost::asio::io_context m_ioContext;
50             void SetRunning(bool val);
51             int Run(std::stop_token token);
52
53             mutable std::string m_errorStr;
54             Config m_config;
55             ModuleSettings m_settings;
56
57             bool m_running;
58
59             std::jthread m_thread;
60             Users* m_users;
61             PluginLogger m_logger;
62
63             std::unique_ptr<Server> m_server;
64     };
65 }