]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/other/radius/server.h
Radius (#9)
[stg.git] / projects / stargazer / plugins / other / radius / server.h
1 #pragma once
2
3 #include "radproto/socket.h"
4 #include "radproto/packet.h"
5 #include "radproto/dictionaries.h"
6 #include "stg/logger.h"
7 #include <boost/asio.hpp>
8 #include <stop_token.hpp>
9 #include <optional>
10 #include <cstdint> //uint8_t, uint32_t
11
12 namespace STG
13 {
14     class Server
15     {
16         public:
17             Server(boost::asio::io_service& io_service, const std::string& secret, uint16_t port, const std::string& filePath, std::stop_token token, PluginLogger& logger);
18             void stop();
19         private:
20             RadProto::Packet makeResponse(const RadProto::Packet& request);
21             void handleReceive(const boost::system::error_code& error, const std::optional<RadProto::Packet>& packet, const boost::asio::ip::udp::endpoint& source);
22             void handleSend(const boost::system::error_code& ec);
23             void start();
24             void startReceive();
25
26             RadProto::Socket m_radius;
27             RadProto::Dictionaries m_dictionaries;
28             std::stop_token m_token;
29
30             PluginLogger& m_logger;
31     };
32 }