ignore bans with invalid times from the ban_save_file

explain what went wrong when we couldn't parse the ban duration
This commit is contained in:
Gunter Labes 2009-08-10 16:18:48 +00:00
parent 228144c1fb
commit 85de349336
2 changed files with 5 additions and 3 deletions

View file

@ -715,8 +715,9 @@ static lg::log_domain log_server("server");
ban_times_.clear();
foreach (const config &bt, cfg.child_range("ban_time")) {
time_t duration = 0;
parse_time(bt["time"], &duration);
ban_times_.insert(default_ban_times::value_type(bt["name"], duration));
if (parse_time(bt["time"], &duration)) {
ban_times_.insert(default_ban_times::value_type(bt["name"], duration));
}
}
init_ban_help();
if (filename_ != cfg["ban_save_file"])

View file

@ -1450,7 +1450,8 @@ std::string server::process_command(std::string query, std::string issuer_name)
const std::string duration(first_space + 1, second_space);
time_t parsed_time = time(NULL);
if (ban_manager_.parse_time(duration, &parsed_time) == false) {
return ban_manager_.get_ban_help();
return "Failed to parse the ban duration: '" + duration + "'\n"
+ ban_manager_.get_ban_help();
}
if (second_space == parameters.end()) {