* 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>
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
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").
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])).