R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
ban_list.hpp
Go to the documentation of this file.
1
3#pragma once
4#include <aegis2d/net/endpoint.hpp>
5
6#include <filesystem>
7#include <optional>
8#include <string>
9#include <vector>
10
11namespace rtype {
12
20class BanList {
21public:
24 explicit BanList(std::filesystem::path file);
25
29 bool ban(const aegis2d::net::Endpoint& address);
30
34 [[nodiscard]] bool banned(const aegis2d::net::Endpoint& address) const;
35
38 [[nodiscard]] const std::vector<aegis2d::net::Endpoint>& addresses() const noexcept;
39
42 [[nodiscard]] const std::optional<std::string>& load_error() const noexcept;
43
44private:
45 void load();
46 void save() const;
47
48 std::filesystem::path file_;
49 std::vector<aegis2d::net::Endpoint> addresses_;
50 std::optional<std::string> load_error_;
51};
52
53} // namespace rtype
The IP addresses that cannot log in, kept in a JSON file.
Definition ban_list.hpp:20
bool ban(const aegis2d::net::Endpoint &address)
Bans an address, its port ignored.
bool banned(const aegis2d::net::Endpoint &address) const
Tells whether an address is banned, whatever its port.
const std::optional< std::string > & load_error() const noexcept
Why the file could not be read at start.
const std::vector< aegis2d::net::Endpoint > & addresses() const noexcept
The banned addresses, port 0.
BanList(std::filesystem::path file)
Reads the bans of a file.
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16