mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-07 21:58:36 +00:00
Expire the ban when no longer needed.
Actually, we expire it just before checking for bans during login and for the /q bans (list current bans) command.
This commit is contained in:
parent
745f8d29c3
commit
88545de4b0
@ -609,8 +609,9 @@ static lg::log_domain log_server("server");
|
||||
|
||||
|
||||
|
||||
void ban_manager::list_bans(std::ostringstream& out, const std::string& mask) const
|
||||
void ban_manager::list_bans(std::ostringstream& out, const std::string& mask)
|
||||
{
|
||||
expire_bans();
|
||||
if (bans_.empty())
|
||||
{
|
||||
out << "No bans set.";
|
||||
@ -652,8 +653,9 @@ static lg::log_domain log_server("server");
|
||||
}
|
||||
|
||||
|
||||
std::string ban_manager::is_ip_banned(const std::string& ip) const
|
||||
std::string ban_manager::is_ip_banned(const std::string& ip)
|
||||
{
|
||||
expire_bans();
|
||||
ip_mask pair;
|
||||
try {
|
||||
pair = parse_ip(ip);
|
||||
|
@ -135,6 +135,10 @@ namespace wesnothd {
|
||||
{ return c - '0'; }
|
||||
|
||||
void init_ban_help();
|
||||
void check_ban_times(time_t time_now);
|
||||
inline void expire_bans() {
|
||||
check_ban_times(time(nullptr));
|
||||
}
|
||||
public:
|
||||
ban_manager();
|
||||
~ban_manager();
|
||||
@ -155,12 +159,10 @@ namespace wesnothd {
|
||||
void unban_group(std::ostringstream& os, const std::string& group);
|
||||
|
||||
|
||||
void check_ban_times(time_t time_now);
|
||||
|
||||
void list_deleted_bans(std::ostringstream& out, const std::string& mask = "*") const;
|
||||
void list_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 is_ip_banned(const std::string& ip);
|
||||
|
||||
const std::string& get_ban_help() const
|
||||
{ return ban_help_; }
|
||||
|
@ -485,7 +485,7 @@ void server::load_config() {
|
||||
}
|
||||
}
|
||||
|
||||
std::string server::is_ip_banned(const std::string& ip) const {
|
||||
std::string server::is_ip_banned(const std::string& ip) {
|
||||
if (!tor_ip_list_.empty()) {
|
||||
if (find(tor_ip_list_.begin(), tor_ip_list_.end(), ip) != tor_ip_list_.end()) return "TOR IP";
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ private:
|
||||
void load_config();
|
||||
|
||||
bool ip_exceeds_connection_limit(const std::string& ip) const;
|
||||
std::string is_ip_banned(const std::string& ip) const;
|
||||
std::string is_ip_banned(const std::string& ip);
|
||||
|
||||
simple_wml::document version_query_response_;
|
||||
simple_wml::document login_response_;
|
||||
|
@ -58,7 +58,7 @@ protected:
|
||||
virtual void handle_new_client(socket_ptr socket) = 0;
|
||||
|
||||
virtual bool accepting_connections() const { return true; }
|
||||
virtual std::string is_ip_banned(const std::string&) const { return std::string(); }
|
||||
virtual std::string is_ip_banned(const std::string&) { return std::string(); }
|
||||
|
||||
#ifndef _WIN32
|
||||
boost::asio::posix::stream_descriptor input_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user