From: Christophe Romain Date: Fri, 11 Jul 2008 07:13:41 +0000 (+0000) Subject: change needed to support previous blacklist support X-Git-Tag: v2.0.2~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c90d7c2b936ef94e00782988fb3cbe6c5413f01;p=ejabberd change needed to support previous blacklist support SVN Revision: 1432 --- diff --git a/ChangeLog b/ChangeLog index 5ae951697..2177e9afe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,10 @@ * src/ejabberd_c2s.erl: Backport C2S blacklist support from trunk was (EJAB-625). - * src/mod_ip_blacklist.erl: Likewise. + * src/mod_ip_blacklist.erl: Likewise + * src/jlib.erl: Added IP format tuple to string function + * src/ejabberd_socket.erl: Properly handled c2s start failure (happen + for blacklisted IP). 2008-07-10 Badlop diff --git a/src/ejabberd_socket.erl b/src/ejabberd_socket.erl index f94a0a0e1..389b3a106 100644 --- a/src/ejabberd_socket.erl +++ b/src/ejabberd_socket.erl @@ -65,19 +65,27 @@ start(Module, SockMod, Socket, Opts) -> SocketData = #socket_state{sockmod = SockMod, socket = Socket, receiver = Receiver}, - {ok, Pid} = Module:start({?MODULE, SocketData}, Opts), - case SockMod:controlling_process(Socket, Receiver) of - ok -> - ok; + case Module:start({?MODULE, SocketData}, Opts) of + {ok, Pid} -> + case SockMod:controlling_process(Socket, Receiver) of + ok -> + ok; + {error, _Reason} -> + SockMod:close(Socket) + end, + ejabberd_receiver:become_controller(Receiver, Pid); {error, _Reason} -> SockMod:close(Socket) - end, - ejabberd_receiver:become_controller(Receiver, Pid); + end; raw -> - {ok, Pid} = Module:start({SockMod, Socket}, Opts), - case SockMod:controlling_process(Socket, Pid) of - ok -> - ok; + case Module:start({SockMod, Socket}, Opts) of + {ok, Pid} -> + case SockMod:controlling_process(Socket, Pid) of + ok -> + ok; + {error, _Reason} -> + SockMod:close(Socket) + end; {error, _Reason} -> SockMod:close(Socket) end diff --git a/src/jlib.erl b/src/jlib.erl index 1ee2e4ffa..4fd897599 100644 --- a/src/jlib.erl +++ b/src/jlib.erl @@ -59,7 +59,8 @@ now_to_local_string/1, datetime_string_to_timestamp/1, decode_base64/1, - encode_base64/1]). + encode_base64/1, + ip_to_list/1]). -include("jlib.hrl"). @@ -676,3 +677,9 @@ e(X) when X>51, X<62 -> X-4; e(62) -> $+; e(63) -> $/; e(X) -> exit({bad_encode_base64_token, X}). + +%% Convert Erlang inet IP to list +ip_to_list({IP, _Port}) -> + ip_to_list(IP); +ip_to_list({A,B,C,D}) -> + lists:flatten(io_lib:format("~w.~w.~w.~w",[A,B,C,D])).