The Battle for Wesnoth  1.19.0-dev
Public Member Functions | Private Member Functions | Private Attributes | List of all members
wesnothd::ban_manager Class Reference

#include <ban.hpp>

Public Member Functions

 ban_manager ()
 
 ~ban_manager ()
 
void read ()
 
void write ()
 
bool parse_time (const std::string &duration, std::time_t *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 &, const std::time_t &, const std::string &, const std::string &, const std::string &, const std::string &="")
 
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 (std::time_t 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_
 

Detailed Description

Definition at line 123 of file ban.hpp.

Constructor & Destructor Documentation

◆ ban_manager()

wesnothd::ban_manager::ban_manager ( )

Definition at line 723 of file ban.cpp.

References init_ban_help().

◆ ~ban_manager()

wesnothd::ban_manager::~ban_manager ( )

Definition at line 714 of file ban.cpp.

References DBG_SERVER, utils::get_unknown_exception_type(), and write().

Member Function Documentation

◆ ban()

std::string wesnothd::ban_manager::ban ( const std::string &  ip,
const std::time_t &  end_time,
const std::string &  reason,
const std::string &  who_banned,
const std::string &  group,
const std::string &  nick = "" 
)

◆ check_ban_times()

void wesnothd::ban_manager::check_ban_times ( std::time_t  time_now)
private

Definition at line 571 of file ban.cpp.

References ban(), DBG_SERVER, LOG_SERVER, time_queue_, unban(), and write().

Referenced by expire_bans().

◆ expire_bans()

void wesnothd::ban_manager::expire_bans ( )
inlineprivate

Definition at line 145 of file ban.hpp.

References check_ban_times().

Referenced by is_ip_banned(), and list_bans().

◆ get_ban_help()

const std::string& wesnothd::ban_manager::get_ban_help ( ) const
inline

◆ init_ban_help()

void wesnothd::ban_manager::init_ban_help ( )
private

Definition at line 673 of file ban.cpp.

References ban_help_, and ban_times_.

Referenced by ban_manager(), and load_config().

◆ is_digit()

bool wesnothd::ban_manager::is_digit ( const char &  c) const
inlineprivate

Definition at line 133 of file ban.hpp.

References c.

Referenced by parse_time().

◆ is_ip_banned()

std::string wesnothd::ban_manager::is_ip_banned ( const std::string &  ip)

Definition at line 657 of file ban.cpp.

References ban(), bans_, expire_bans(), p, and wesnothd::parse_ip().

Referenced by wesnothd::server::is_ip_banned().

◆ list_bans()

void wesnothd::ban_manager::list_bans ( std::ostringstream &  out,
const std::string &  mask = "*" 
)

Definition at line 617 of file ban.cpp.

References b, bans_, e, expire_bans(), and wesnothd::parse_ip().

Referenced by wesnothd::server::bans_handler().

◆ list_deleted_bans()

void wesnothd::ban_manager::list_deleted_bans ( std::ostringstream &  out,
const std::string &  mask = "*" 
) const

Definition at line 594 of file ban.cpp.

References deleted_bans_, e, i, and wesnothd::parse_ip().

Referenced by wesnothd::server::bans_handler().

◆ load_config()

void wesnothd::ban_manager::load_config ( const config cfg)

◆ parse_time()

bool wesnothd::ban_manager::parse_time ( const std::string &  duration,
std::time_t *  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'.

Returns
false if an invalid time modifier is encountered. *time is undefined in that case.

Definition at line 333 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().

◆ read()

void wesnothd::ban_manager::read ( )

◆ to_digit()

std::size_t wesnothd::ban_manager::to_digit ( const char &  c) const
inlineprivate

Definition at line 138 of file ban.hpp.

References c.

Referenced by parse_time().

◆ unban()

void wesnothd::ban_manager::unban ( std::ostringstream &  os,
const std::string &  ip,
bool  immediate_write = true 
)

Definition at line 532 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().

◆ unban_group()

void wesnothd::ban_manager::unban_group ( std::ostringstream &  os,
const std::string &  group 
)

Definition at line 559 of file ban.cpp.

References bans_, dirty_, p, and write().

Referenced by wesnothd::server::ungban_handler().

◆ write()

void wesnothd::ban_manager::write ( )

Member Data Documentation

◆ ban_help_

std::string wesnothd::ban_manager::ban_help_
private

Definition at line 129 of file ban.hpp.

Referenced by get_ban_help(), and init_ban_help().

◆ ban_times_

default_ban_times wesnothd::ban_manager::ban_times_
private

Definition at line 128 of file ban.hpp.

Referenced by init_ban_help(), load_config(), and parse_time().

◆ bans_

ban_set wesnothd::ban_manager::bans_
private

Definition at line 125 of file ban.hpp.

Referenced by ban(), is_ip_banned(), list_bans(), read(), unban(), unban_group(), and write().

◆ deleted_bans_

deleted_ban_list wesnothd::ban_manager::deleted_bans_
private

Definition at line 126 of file ban.hpp.

Referenced by list_deleted_bans(), read(), unban(), and write().

◆ dirty_

bool wesnothd::ban_manager::dirty_
private

Definition at line 131 of file ban.hpp.

Referenced by ban(), load_config(), read(), unban(), unban_group(), and write().

◆ filename_

std::string wesnothd::ban_manager::filename_
private

Definition at line 130 of file ban.hpp.

Referenced by load_config(), read(), and write().

◆ time_queue_

ban_time_queue wesnothd::ban_manager::time_queue_
private

Definition at line 127 of file ban.hpp.

Referenced by ban(), check_ban_times(), and read().


The documentation for this class was generated from the following files: