32 std::ostream&
operator<<(std::ostream& o,
const banned&
n);
52 typedef std::set<banned_ptr, banned_compare_subnet>
ban_set;
56 typedef std::pair<unsigned int, unsigned int>
ip_mask;
64 utils::optional<std::chrono::system_clock::time_point>
end_time_;
65 utils::optional<std::chrono::system_clock::time_point>
start_time_;
73 banned(
const std::string& ip,
74 const utils::optional<std::chrono::system_clock::time_point>& end_time,
75 const std::string& reason,
77 const std::string& group =
"",
78 const std::string& nick =
"");
82 banned(
const std::string& ip);
109 {
return group_ == group; }
140 return c >=
'0' &&
c <=
'9';
149 void check_ban_times(
const std::chrono::system_clock::time_point& time_now);
168 std::pair<bool, utils::optional<std::chrono::system_clock::time_point>>
parse_time(
169 const std::string& duration, std::chrono::system_clock::time_point start_time)
const;
171 std::string
ban(
const std::string& ip,
172 const utils::optional<std::chrono::system_clock::time_point>& end_time,
173 const std::string& reason,
174 const std::string& who_banned,
175 const std::string& group,
176 const std::string& nick =
"");
178 void unban(std::ostringstream& os,
const std::string& ip,
bool immediate_write=
true);
179 void unban_group(std::ostringstream& os,
const std::string& group);
181 void list_deleted_bans(std::ostringstream& out,
const std::string& mask =
"*")
const;
182 void list_bans(std::ostringstream& out,
const std::string& mask =
"*");
A config object defines a single node in a WML file, with access to child nodes.
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 list_bans(std::ostringstream &out, const std::string &mask="*")
void unban(std::ostringstream &os, const std::string &ip, bool immediate_write=true)
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 ...
void check_ban_times(const std::chrono::system_clock::time_point &time_now)
default_ban_times ban_times_
void unban_group(std::ostringstream &os, const std::string &group)
bool is_digit(const char &c) const
std::size_t to_digit(const char &c) const
ban_time_queue time_queue_
const std::string & get_ban_help() const
std::string is_ip_banned(const std::string &ip)
deleted_ban_list deleted_bans_
void list_deleted_bans(std::ostringstream &out, const std::string &mask="*") const
void load_config(const config &)
utils::optional< std::chrono::system_clock::time_point > start_time_
bool match_ipmask(const ip_mask &ip) const
std::string get_human_start_time() const
unsigned int get_mask_ip(unsigned int) const
std::string get_group() const
unsigned int get_int_ip() const
unsigned int mask() const
void read(const config &)
static const std::string who_banned_default_
std::string get_reason() const
std::string get_nick() const
bool operator>(const banned &b) const
void write(config &) const
std::string get_who_banned() const
banned(const std::string &ip, const utils::optional< std::chrono::system_clock::time_point > &end_time, const std::string &reason, const std::string &who_banned=who_banned_default_, const std::string &group="", const std::string &nick="")
bool match_ip(const ip_mask &ip) const
std::string get_human_end_time() const
bool match_group(const std::string &group) const
std::string get_human_time_span() const
std::string get_ip() const
utils::optional< std::chrono::system_clock::time_point > end_time_
const auto & get_end_time() const
std::ostream & operator<<(std::ostream &o, const banned &n)
std::set< banned_ptr, banned_compare_subnet > ban_set
std::map< std::string, std::chrono::seconds > default_ban_times
std::priority_queue< banned_ptr, std::vector< banned_ptr >, banned_compare > ban_time_queue
std::list< banned_ptr > deleted_ban_list
std::shared_ptr< banned > banned_ptr
ip_mask parse_ip(const std::string &ip)
std::pair< unsigned int, unsigned int > ip_mask
Base class for all the errors encountered by the engine.
error(const std::string &message)
bool operator()(const banned_ptr &a, const banned_ptr &b) const
static compare_fn active_
bool(banned_compare_subnet::* compare_fn)(const banned_ptr &a, const banned_ptr &b) const
bool less(const banned_ptr &a, const banned_ptr &b) const
We want to move the lowest value to the top.
bool operator()(const banned_ptr &a, const banned_ptr &b) const
static map_location::direction n