]> granicus.if.org Git - ejabberd/commitdiff
Error converting times in mod_fail2ban (#889)
authorBadlop <badlop@process-one.net>
Tue, 5 Jan 2016 11:29:13 +0000 (12:29 +0100)
committerBadlop <badlop@process-one.net>
Tue, 5 Jan 2016 11:29:21 +0000 (12:29 +0100)
src/mod_fail2ban.erl

index 523cbb3f94fffb8d3e36fde8e944c0d8a5cb7aaf..394a7186f878d7e82892ae54450539043e4ef175 100644 (file)
@@ -83,7 +83,7 @@ check_bl_c2s(_Acc, Addr, Lang) ->
                true ->
                    IP = jlib:ip_to_list(Addr),
                    UnbanDate = format_date(
-                                   calendar:now_to_universal_time(TS)),
+                                   calendar:now_to_universal_time(seconds_to_now(TS))),
                    LogReason = io_lib:fwrite(
                                  "Too many (~p) failed authentications "
                                  "from this IP address (~s). The address "
@@ -179,6 +179,9 @@ is_loaded_at_other_hosts(Host) ->
              gen_mod:is_loaded(VHost, ?MODULE)
       end, ?MYHOSTS).
 
+seconds_to_now(Secs) ->
+    {Secs div 1000000, Secs rem 1000000, 0}.
+
 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]).