25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

Error converting times in mod_fail2ban (#889)

This commit is contained in:
Badlop 2016-01-05 12:29:13 +01:00
parent da45a064a8
commit c01e3f24a5

View File

@ -83,7 +83,7 @@ check_bl_c2s(_Acc, Addr, Lang) ->
true -> true ->
IP = jlib:ip_to_list(Addr), IP = jlib:ip_to_list(Addr),
UnbanDate = format_date( UnbanDate = format_date(
calendar:now_to_universal_time(TS)), calendar:now_to_universal_time(seconds_to_now(TS))),
LogReason = io_lib:fwrite( LogReason = io_lib:fwrite(
"Too many (~p) failed authentications " "Too many (~p) failed authentications "
"from this IP address (~s). The address " "from this IP address (~s). The address "
@ -179,6 +179,9 @@ is_loaded_at_other_hosts(Host) ->
gen_mod:is_loaded(VHost, ?MODULE) gen_mod:is_loaded(VHost, ?MODULE)
end, ?MYHOSTS). end, ?MYHOSTS).
seconds_to_now(Secs) ->
{Secs div 1000000, Secs rem 1000000, 0}.
format_date({{Year, Month, Day}, {Hour, Minute, Second}}) -> format_date({{Year, Month, Day}, {Hour, Minute, Second}}) ->
io_lib:format("~2..0w:~2..0w:~2..0w ~2..0w.~2..0w.~4..0w", io_lib:format("~2..0w:~2..0w:~2..0w ~2..0w.~2..0w.~4..0w",
[Hour, Minute, Second, Day, Month, Year]). [Hour, Minute, Second, Day, Month, Year]).