]> granicus.if.org Git - ejabberd/commitdiff
change needed to support previous blacklist support
authorChristophe Romain <christophe.romain@process-one.net>
Fri, 11 Jul 2008 07:13:41 +0000 (07:13 +0000)
committerChristophe Romain <christophe.romain@process-one.net>
Fri, 11 Jul 2008 07:13:41 +0000 (07:13 +0000)
SVN Revision: 1432

ChangeLog
src/ejabberd_socket.erl
src/jlib.erl

index 5ae9516974ef04f225a99d4a684bd63bec84c363..2177e9afe0604dfe355a02ddbad4dd6a661a16ed 100644 (file)
--- 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  <badlop@process-one.net>
 
index f94a0a0e175c0bc95d29b69a605cd6b5045df7f9..389b3a10656dbc3ff01a5a11d35563998c028ff2 100644 (file)
@@ -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
index 1ee2e4ffa0f0c10d7a75df0e66cd6c2f2c2b1908..4fd8975995fd34ed641f80121c21a3e5d062adac 100644 (file)
@@ -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])).