From fb6267f38ee47f3f725f88324d132741c85dfb6a Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Mon, 1 Jun 2015 15:38:27 +0300 Subject: Add config validation at startup --- src/mod_fail2ban.erl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/mod_fail2ban.erl') diff --git a/src/mod_fail2ban.erl b/src/mod_fail2ban.erl index 63c09db26..67b705d9a 100644 --- a/src/mod_fail2ban.erl +++ b/src/mod_fail2ban.erl @@ -31,9 +31,9 @@ %% API -export([start_link/2, start/2, stop/1, c2s_auth_result/4, check_bl_c2s/3]). -%% gen_server callbacks --export([init/1, handle_call/3, handle_cast/2, handle_info/2, - terminate/2, code_change/3]). +-export([init/1, handle_call/3, handle_cast/2, + handle_info/2, terminate/2, code_change/3, + mod_opt_type/1]). -include_lib("stdlib/include/ms_transform.hrl"). -include("ejabberd.hrl"). @@ -187,3 +187,12 @@ is_loaded_at_other_hosts(Host) -> format_date({{Year, Month, Day}, {Hour, Minute, Second}}) -> io_lib:format("~2..0w:~2..0w:~2..0w ~2..0w.~2..0w.~4..0w", [Hour, Minute, Second, Day, Month, Year]). + +mod_opt_type(access) -> + fun (A) when is_atom(A) -> A end; +mod_opt_type(c2s_auth_ban_lifetime) -> + fun (T) when is_integer(T), T > 0 -> T end; +mod_opt_type(c2s_max_auth_failures) -> + fun (I) when is_integer(I), I > 0 -> I end; +mod_opt_type(_) -> + [access, c2s_auth_ban_lifetime, c2s_max_auth_failures]. -- cgit v1.2.3