32 std::ostream&
operator<<(std::ostream& o,
const banned&
n);
39 bool operator()(
const banned_ptr&
a,
const banned_ptr&
b)
const;
44 bool operator()(
const banned_ptr&
a,
const banned_ptr&
b)
const;
47 bool less(
const banned_ptr& a,
const banned_ptr& b)
const;
52 typedef std::set<banned_ptr, banned_compare_subnet>
ban_set;
56 typedef std::pair<unsigned int, unsigned int>
ip_mask;
58 ip_mask
parse_ip(
const std::string&);
73 banned(
const std::string& ip,
const std::time_t end_time,
const std::string& reason,
const std::string& who_banned=who_banned_default_,
const std::string& group=
"",
const std::string& nick=
"");
76 banned(
const std::string& ip);
84 std::string get_human_end_time()
const;
85 std::string get_human_start_time()
const;
86 std::string get_human_time_span()
const;
87 static std::string get_human_time(
const std::time_t&);
98 {
return who_banned_; }
104 {
return group_ == group; }
106 bool match_ip(
const ip_mask& ip)
const;
107 bool match_ipmask(
const ip_mask& ip)
const;
109 unsigned int get_mask_ip(
unsigned int)
const;
135 return c >=
'0' && c <=
'9';
143 void init_ban_help();
144 void check_ban_times(std::time_t time_now);
147 check_ban_times(std::time(
nullptr));
163 bool parse_time(
const std::string& duration, std::time_t* time)
const;
165 std::string ban(
const std::string&,
const std::time_t&,
const std::string&,
const std::string&,
const std::string&,
const std::string& =
"");
166 void unban(std::ostringstream& os,
const std::string& ip,
bool immediate_write=
true);
167 void unban_group(std::ostringstream& os,
const std::string& group);
169 void list_deleted_bans(std::ostringstream& out,
const std::string& mask =
"*")
const;
170 void list_bans(std::ostringstream& out,
const std::string& mask =
"*");
172 std::string is_ip_banned(
const std::string& ip);
175 {
return ban_help_; }
177 void load_config(
const config&);
std::string get_reason() const
std::list< banned_ptr > deleted_ban_list
default_ban_times ban_times_
bool is_digit(const char &c) const
unsigned int get_int_ip() const
std::time_t get_end_time() const
deleted_ban_list deleted_bans_
bool match_group(const std::string &group) const
static compare_fn active_
std::pair< unsigned int, unsigned int > ip_mask
std::shared_ptr< banned > banned_ptr
std::string get_who_banned() const
void write(std::ostream &out, const configr_of &cfg, unsigned int level)
void read(config &cfg, std::istream &in, abstract_validator *validator)
bool operator()(const banned_ptr &a, const banned_ptr &b) const
We want to move the lowest value to the top.
ip_mask parse_ip(const std::string &ip)
std::size_t to_digit(const char &c) const
unsigned int mask() const
ban_time_queue time_queue_
std::string get_group() const
std::ostream & operator<<(std::ostream &o, const banned &n)
std::string get_nick() const
std::set< banned_ptr, banned_compare_subnet > ban_set
static const std::string who_banned_default_
Base class for all the errors encountered by the engine.
std::string get_ip() const
std::priority_queue< banned_ptr, std::vector< banned_ptr >, banned_compare > ban_time_queue
error(const std::string &message)
std::map< std::string, std::size_t > default_ban_times
A config object defines a single node in a WML file, with access to child nodes.
const std::string & get_ban_help() const
static map_location::DIRECTION n
bool operator>(const version_info &l, const version_info &r)
Greater-than operator for version_info.