Update mod_logsession to work with ejabberd master branch #41
This commit is contained in:
parent
ba64c794c7
commit
198f14a7c0
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
Homepage: http://www.ejabberd.im/mod_logsession
|
Homepage: http://www.ejabberd.im/mod_logsession
|
||||||
Author: Badlop
|
Author: Badlop
|
||||||
Requirements: ejabberd trunk SVN 1635 or newer
|
Requirements: ejabberd 14.05 or newer
|
||||||
|
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
|
@ -23,7 +23,7 @@ Note: to log the failed authentication attempts, you need to patch ejabberd.
|
||||||
1 Copy this file to ejabberd/src/mod_logsession.erl
|
1 Copy this file to ejabberd/src/mod_logsession.erl
|
||||||
2 Recompile ejabberd
|
2 Recompile ejabberd
|
||||||
3 Add to ejabberd.cfg, 'modules' section the basic configuration:
|
3 Add to ejabberd.cfg, 'modules' section the basic configuration:
|
||||||
{mod_logsession, []},
|
mod_logsession: {}
|
||||||
4 With this configuration, the log files are:
|
4 With this configuration, the log files are:
|
||||||
/tmp/ejabberd_logsession_@HOST@.log
|
/tmp/ejabberd_logsession_@HOST@.log
|
||||||
|
|
||||||
|
@ -40,13 +40,11 @@ sessionlog:
|
||||||
EXAMPLE CONFIGURATION
|
EXAMPLE CONFIGURATION
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
{modules, [
|
modules:
|
||||||
...
|
...
|
||||||
{mod_logsession, [
|
mod_logsession:
|
||||||
{sessionlog, "/var/log/ejabberd/session_@HOST@.log"}
|
sessionlog: "/var/log/ejabberd/session_@HOST@.log"
|
||||||
]},
|
|
||||||
...
|
...
|
||||||
]}.
|
|
||||||
|
|
||||||
With that configuration, if the server has three vhosts:
|
With that configuration, if the server has three vhosts:
|
||||||
"localhost", "example.org" and "example.net",
|
"localhost", "example.org" and "example.net",
|
||||||
|
|
|
@ -1,30 +1,41 @@
|
||||||
--- ejabberd_c2s.erl
|
From 86a811a92b27afe43adcc3ab3692df13949c4221 Mon Sep 17 00:00:00 2001
|
||||||
+++ ejabberd_c2s.erl
|
From: Badlop <badlop@process-one.net>
|
||||||
@@ -496,6 +496,11 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
Date: Mon, 23 Jun 2014 13:47:10 +0200
|
||||||
fsm_next_state_pack(session_established,
|
Subject: [PATCH] Patch for mod_logsession
|
||||||
NewStateData);
|
|
||||||
|
---
|
||||||
|
src/ejabberd_c2s.erl | 21 +++++++++++++++++++++
|
||||||
|
1 file changed, 21 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl
|
||||||
|
index 9ce66d0..d59ec58 100644
|
||||||
|
--- a/src/ejabberd_c2s.erl
|
||||||
|
+++ b/src/ejabberd_c2s.erl
|
||||||
|
@@ -659,6 +659,11 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
||||||
|
privacy_list = PrivList},
|
||||||
|
fsm_next_state(session_established, NewStateData);
|
||||||
_ ->
|
_ ->
|
||||||
+ ejabberd_hooks:run(failed_auth_hook,
|
+ ejabberd_hooks:run(failed_auth_hook,
|
||||||
+ StateData#state.server,
|
+ StateData#state.server,
|
||||||
+ [legacy, U,
|
+ [legacy, U,
|
||||||
+ StateData#state.server,
|
+ StateData#state.server,
|
||||||
+ StateData#state.ip]),
|
+ StateData#state.ip]),
|
||||||
?INFO_MSG(
|
IP = peerip(StateData#state.sockmod,
|
||||||
"(~w) Failed legacy authentication for ~s",
|
StateData#state.socket),
|
||||||
[StateData#state.socket,
|
?INFO_MSG("(~w) Failed legacy authentication for "
|
||||||
@@ -586,6 +591,11 @@ wait_for_feature_request({xmlstreamelement, El}, StateData) ->
|
@@ -753,6 +758,11 @@ wait_for_feature_request({xmlstreamelement, El},
|
||||||
StateData#state{
|
fsm_next_state(wait_for_sasl_response,
|
||||||
sasl_state = NewSASLState});
|
StateData#state{sasl_state = NewSASLState});
|
||||||
{error, Error, Username} ->
|
{error, Error, Username} ->
|
||||||
+ ejabberd_hooks:run(failed_auth_hook,
|
+ ejabberd_hooks:run(failed_auth_hook,
|
||||||
+ StateData#state.server,
|
+ StateData#state.server,
|
||||||
+ [sasl_auth, Username,
|
+ [sasl_auth, Username,
|
||||||
+ StateData#state.server,
|
+ StateData#state.server,
|
||||||
+ StateData#state.ip]),
|
+ StateData#state.ip]),
|
||||||
?INFO_MSG(
|
IP = peerip(StateData#state.sockmod, StateData#state.socket),
|
||||||
"(~w) Failed authentication for ~s@~s",
|
?INFO_MSG("(~w) Failed authentication for ~s@~s from IP ~s",
|
||||||
[StateData#state.socket,
|
[StateData#state.socket,
|
||||||
@@ -721,10 +731,15 @@ wait_for_sasl_response({xmlstreamelement, El}, StateData) ->
|
@@ -935,6 +945,11 @@ wait_for_sasl_response({xmlstreamelement, El},
|
||||||
fsm_next_state(wait_for_sasl_response,
|
fsm_next_state(wait_for_sasl_response,
|
||||||
StateData#state{sasl_state = NewSASLState});
|
StateData#state{sasl_state = NewSASLState});
|
||||||
{error, Error, Username} ->
|
{error, Error, Username} ->
|
||||||
|
@ -33,12 +44,22 @@
|
||||||
+ [sasl_resp, Username,
|
+ [sasl_resp, Username,
|
||||||
+ StateData#state.server,
|
+ StateData#state.server,
|
||||||
+ StateData#state.ip]),
|
+ StateData#state.ip]),
|
||||||
?INFO_MSG(
|
IP = peerip(StateData#state.sockmod, StateData#state.socket),
|
||||||
- "(~w) Failed authentication for ~s@~s",
|
?INFO_MSG("(~w) Failed authentication for ~s@~s from IP ~s",
|
||||||
+ "(~w) Failed authentication for ~s@~s ~n~p",
|
|
||||||
[StateData#state.socket,
|
[StateData#state.socket,
|
||||||
- Username, StateData#state.server]),
|
@@ -947,6 +962,12 @@ wait_for_sasl_response({xmlstreamelement, El},
|
||||||
+ Username, StateData#state.server, StateData]),
|
children = []}]}),
|
||||||
|
fsm_next_state(wait_for_feature_request, StateData);
|
||||||
|
{error, Error} ->
|
||||||
|
+ Username = element(5, element(9, StateData#state.sasl_state)),
|
||||||
|
+ ejabberd_hooks:run(failed_auth_hook,
|
||||||
|
+ StateData#state.server,
|
||||||
|
+ [sasl_resp, Username,
|
||||||
|
+ StateData#state.server,
|
||||||
|
+ StateData#state.ip]),
|
||||||
send_element(StateData,
|
send_element(StateData,
|
||||||
{xmlelement, "failure",
|
#xmlel{name = <<"failure">>,
|
||||||
[{"xmlns", ?NS_SASL}],
|
attrs = [{<<"xmlns">>, ?NS_SASL}],
|
||||||
|
--
|
||||||
|
1.8.5.3
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ start(Host, Opts) ->
|
||||||
Filename1 = gen_mod:get_opt(
|
Filename1 = gen_mod:get_opt(
|
||||||
sessionlog,
|
sessionlog,
|
||||||
Opts,
|
Opts,
|
||||||
|
fun(S) -> S end,
|
||||||
"/tmp/ejabberd_logsession_@HOST@.log"),
|
"/tmp/ejabberd_logsession_@HOST@.log"),
|
||||||
Filename = replace_host(Host, Filename1),
|
Filename = replace_host(Host, Filename1),
|
||||||
File = open_file(Filename),
|
File = open_file(Filename),
|
||||||
|
@ -115,7 +116,7 @@ get_process_name(Host) ->
|
||||||
gen_mod:get_module_proc(Host, ?PROCNAME).
|
gen_mod:get_module_proc(Host, ?PROCNAME).
|
||||||
|
|
||||||
replace_host(Host, Filename) ->
|
replace_host(Host, Filename) ->
|
||||||
re:replace(Filename, "@HOST@", Host, [global, {return, list}]).
|
re:replace(Filename, "@HOST@", binary_to_list(Host), [global, {return, list}]).
|
||||||
|
|
||||||
open_file(Filename) ->
|
open_file(Filename) ->
|
||||||
{ok, File} = file:open(Filename, [append]),
|
{ok, File} = file:open(Filename, [append]),
|
||||||
|
|
Loading…
Reference in New Issue