#include <ban.hpp>
Public Member Functions | |
ban_manager () | |
~ban_manager () | |
void | read () |
void | write () |
std::pair< bool, utils::optional< std::chrono::system_clock::time_point > > | parse_time (const std::string &duration, std::chrono::system_clock::time_point start_time) const |
Parses the given duration and adds it to *time except if the duration is '0' or 'permanent' in which case *time will be set to '0'. More... | |
std::string | ban (const std::string &ip, const utils::optional< std::chrono::system_clock::time_point > &end_time, const std::string &reason, const std::string &who_banned, const std::string &group, const std::string &nick="") |
void | unban (std::ostringstream &os, const std::string &ip, bool immediate_write=true) |
void | unban_group (std::ostringstream &os, const std::string &group) |
void | list_deleted_bans (std::ostringstream &out, const std::string &mask="*") const |
void | list_bans (std::ostringstream &out, const std::string &mask="*") |
std::string | is_ip_banned (const std::string &ip) |
const std::string & | get_ban_help () const |
void | load_config (const config &) |
Private Member Functions | |
bool | is_digit (const char &c) const |
std::size_t | to_digit (const char &c) const |
void | init_ban_help () |
void | check_ban_times (const std::chrono::system_clock::time_point &time_now) |
void | expire_bans () |
Private Attributes | |
ban_set | bans_ |
deleted_ban_list | deleted_bans_ |
ban_time_queue | time_queue_ |
default_ban_times | ban_times_ |
std::string | ban_help_ |
std::string | filename_ |
bool | dirty_ |
wesnothd::ban_manager::ban_manager | ( | ) |
Definition at line 727 of file ban.cpp.
References init_ban_help().
wesnothd::ban_manager::~ban_manager | ( | ) |
Definition at line 718 of file ban.cpp.
References DBG_SERVER, utils::get_unknown_exception_type(), and write().
std::string wesnothd::ban_manager::ban | ( | const std::string & | ip, |
const utils::optional< std::chrono::system_clock::time_point > & | end_time, | ||
const std::string & | reason, | ||
const std::string & | who_banned, | ||
const std::string & | group, | ||
const std::string & | nick = "" |
||
) |
Definition at line 490 of file ban.cpp.
References bans_, dirty_, e, ERR_SERVER, time_queue_, and write().
Referenced by wesnothd::server::authenticate(), wesnothd::server::ban_handler(), check_ban_times(), wesnothd::server::gban_handler(), is_ip_banned(), wesnothd::server::kickban_handler(), and unban().
|
private |
Definition at line 566 of file ban.cpp.
References ban(), DBG_SERVER, chrono::format_local_timestamp(), LOG_SERVER, time_queue_, unban(), and write().
Referenced by expire_bans().
|
inlineprivate |
Definition at line 150 of file ban.hpp.
References check_ban_times().
Referenced by is_ip_banned(), and list_bans().
|
inline |
Definition at line 186 of file ban.hpp.
References ban_help_.
Referenced by wesnothd::server::ban_handler(), wesnothd::server::gban_handler(), and wesnothd::server::kickban_handler().
|
private |
Definition at line 674 of file ban.cpp.
References ban_help_, and ban_times_.
Referenced by ban_manager(), and load_config().
|
inlineprivate |
std::string wesnothd::ban_manager::is_ip_banned | ( | const std::string & | ip | ) |
Definition at line 658 of file ban.cpp.
References ban(), bans_, expire_bans(), p, and wesnothd::parse_ip().
Referenced by wesnothd::server::is_ip_banned().
void wesnothd::ban_manager::list_bans | ( | std::ostringstream & | out, |
const std::string & | mask = "*" |
||
) |
Definition at line 618 of file ban.cpp.
References b, bans_, e, expire_bans(), and wesnothd::parse_ip().
Referenced by wesnothd::server::bans_handler().
void wesnothd::ban_manager::list_deleted_bans | ( | std::ostringstream & | out, |
const std::string & | mask = "*" |
||
) | const |
Definition at line 595 of file ban.cpp.
References deleted_bans_, e, i, and wesnothd::parse_ip().
Referenced by wesnothd::server::bans_handler().
void wesnothd::ban_manager::load_config | ( | const config & | cfg | ) |
Definition at line 698 of file ban.cpp.
References ban_times_, config::child_range(), dirty_, filename_, init_ban_help(), and parse_time().
Referenced by wesnothd::server::load_config().
std::pair< bool, utils::optional< std::chrono::system_clock::time_point > > wesnothd::ban_manager::parse_time | ( | const std::string & | duration, |
std::chrono::system_clock::time_point | start_time | ||
) | const |
Parses the given duration and adds it to *time except if the duration is '0' or 'permanent' in which case *time will be set to '0'.
Definition at line 332 of file ban.cpp.
References ban_times_, e, ERR_SERVER, i, is_digit(), LOG_SERVER, utf8::lowercase(), and to_digit().
Referenced by wesnothd::server::ban_handler(), wesnothd::server::gban_handler(), wesnothd::server::kickban_handler(), and load_config().
void wesnothd::ban_manager::read | ( | ) |
Definition at line 269 of file ban.cpp.
References b, bans_, config::child_range(), deleted_bans_, dirty_, e, ERR_SERVER, filesystem::file_exists(), filename_, filesystem::istream_file(), LOG_SERVER, config::optional_child(), read_gz(), and time_queue_.
Referenced by wesnothd::server::server().
|
inlineprivate |
void wesnothd::ban_manager::unban | ( | std::ostringstream & | os, |
const std::string & | ip, | ||
bool | immediate_write = true |
||
) |
Definition at line 527 of file ban.cpp.
References ban(), bans_, deleted_bans_, dirty_, e, ERR_SERVER, and write().
Referenced by check_ban_times(), and wesnothd::server::unban_handler().
void wesnothd::ban_manager::unban_group | ( | std::ostringstream & | os, |
const std::string & | group | ||
) |
void wesnothd::ban_manager::write | ( | ) |
Definition at line 306 of file ban.cpp.
References config::add_child(), b, bans_, deleted_bans_, dirty_, filename_, LOG_SERVER, filesystem::ostream_file(), and config_writer::write().
Referenced by ban(), check_ban_times(), unban(), unban_group(), and ~ban_manager().
|
private |
Definition at line 134 of file ban.hpp.
Referenced by get_ban_help(), and init_ban_help().
|
private |
Definition at line 133 of file ban.hpp.
Referenced by init_ban_help(), load_config(), and parse_time().
|
private |
Definition at line 130 of file ban.hpp.
Referenced by ban(), is_ip_banned(), list_bans(), read(), unban(), unban_group(), and write().
|
private |
|
private |
Definition at line 136 of file ban.hpp.
Referenced by ban(), load_config(), read(), unban(), unban_group(), and write().
|
private |
Definition at line 135 of file ban.hpp.
Referenced by load_config(), read(), and write().
|
private |
Definition at line 132 of file ban.hpp.
Referenced by ban(), check_ban_times(), and read().