25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

* src/cyrsasl.erl: Fix compilation warnings: Part 1 (EJAB-290)

* src/ejabberd_auth_odbc.erl: Likewise
* src/ejabberd_config.erl: Likewise
* src/ejabberd_hooks.erl: Likewise
* src/ejabberd_s2s_out.erl: Likewise
* src/ejabberd_sm.erl: Likewise
* src/idna.erl: Likewise
* src/jd2ejd.erl: Likewise

SVN Revision: 1045
This commit is contained in:
Badlop 2007-12-06 23:15:04 +00:00
parent d625fc80fc
commit 6342c258a7
9 changed files with 137 additions and 126 deletions

View File

@ -1,3 +1,14 @@
2007-12-07 Badlop <badlop@process-one.net>
* src/cyrsasl.erl: Fix compilation warnings: Part 1 (EJAB-290)
* src/ejabberd_auth_odbc.erl: Likewise
* src/ejabberd_config.erl: Likewise
* src/ejabberd_hooks.erl: Likewise
* src/ejabberd_s2s_out.erl: Likewise
* src/ejabberd_sm.erl: Likewise
* src/idna.erl: Likewise
* src/jd2ejd.erl: Likewise
2007-12-06 Badlop <badlop@process-one.net> 2007-12-06 Badlop <badlop@process-one.net>
* src/acl.erl and other 64 files: Remove Erlang module attribute * src/acl.erl and other 64 files: Remove Erlang module attribute

View File

@ -25,7 +25,7 @@
behaviour_info(callbacks) -> behaviour_info(callbacks) ->
[{mech_new, 3}, {mech_step, 2}]; [{mech_new, 3}, {mech_step, 2}];
behaviour_info(Other) -> behaviour_info(_Other) ->
undefined. undefined.
start() -> start() ->
@ -43,44 +43,44 @@ register_mechanism(Mechanism, Module, RequirePlainPassword) ->
module = Module, module = Module,
require_plain_password = RequirePlainPassword}). require_plain_password = RequirePlainPassword}).
% TODO: use callbacks %%% TODO: use callbacks
-include("ejabberd.hrl"). %%-include("ejabberd.hrl").
-include("jlib.hrl"). %%-include("jlib.hrl").
check_authzid(State, Props) -> %%check_authzid(_State, Props) ->
AuthzId = xml:get_attr_s(authzid, Props), %% AuthzId = xml:get_attr_s(authzid, Props),
case jlib:string_to_jid(AuthzId) of %% case jlib:string_to_jid(AuthzId) of
error -> %% error ->
{error, "invalid-authzid"}; %% {error, "invalid-authzid"};
JID -> %% JID ->
LUser = jlib:nodeprep(xml:get_attr_s(username, Props)), %% LUser = jlib:nodeprep(xml:get_attr_s(username, Props)),
{U, S, R} = jlib:jid_tolower(JID), %% {U, S, R} = jlib:jid_tolower(JID),
case R of %% case R of
"" -> %% "" ->
{error, "invalid-authzid"}; %% {error, "invalid-authzid"};
_ -> %% _ ->
case {LUser, ?MYNAME} of %% case {LUser, ?MYNAME} of
{U, S} -> %% {U, S} ->
ok; %% ok;
_ -> %% _ ->
{error, "invalid-authzid"} %% {error, "invalid-authzid"}
end %% end
end %% end
end. %% end.
check_credentials(State, Props) -> check_credentials(_State, Props) ->
User = xml:get_attr_s(username, Props), User = xml:get_attr_s(username, Props),
case jlib:nodeprep(User) of case jlib:nodeprep(User) of
error -> error ->
{error, "not-authorized"}; {error, "not-authorized"};
"" -> "" ->
{error, "not-authorized"}; {error, "not-authorized"};
LUser -> _LUser ->
ok ok
end. end.
listmech(Host) -> listmech(Host) ->
RequirePlainPassword = ejabberd_auth:plain_password_required(Host), RequirePlainPassword = ejabberd_auth:plain_password_required(Host),
Mechs = ets:select(sasl_mechanism, Mechs = ets:select(sasl_mechanism,
[{#sasl_mechanism{mechanism = '$1', [{#sasl_mechanism{mechanism = '$1',
require_plain_password = '$2', require_plain_password = '$2',
@ -94,7 +94,7 @@ listmech(Host) ->
['$1']}]), ['$1']}]),
filter_anonymous(Host, Mechs). filter_anonymous(Host, Mechs).
server_new(Service, ServerFQDN, UserRealm, SecFlags, server_new(Service, ServerFQDN, UserRealm, _SecFlags,
GetPassword, CheckPassword) -> GetPassword, CheckPassword) ->
#sasl_state{service = Service, #sasl_state{service = Service,
myname = ServerFQDN, myname = ServerFQDN,

View File

@ -146,7 +146,7 @@ get_vh_registered_users_number(Server, Opts) ->
case catch odbc_queries:users_number(LServer, Opts) of case catch odbc_queries:users_number(LServer, Opts) of
{selected, [_], [{Res}]} -> {selected, [_], [{Res}]} ->
list_to_integer(Res); list_to_integer(Res);
Other -> _Other ->
0 0
end. end.

View File

@ -99,17 +99,17 @@ process_term(Term, State) ->
State#state{override_local = true}; State#state{override_local = true};
override_acls -> override_acls ->
State#state{override_acls = true}; State#state{override_acls = true};
{acl, ACLName, ACLData} -> {acl, _ACLName, _ACLData} ->
process_host_term(Term, global, State); process_host_term(Term, global, State);
{access, RuleName, Rules} -> {access, _RuleName, _Rules} ->
process_host_term(Term, global, State); process_host_term(Term, global, State);
{shaper, Name, Data} -> {shaper, _Name, _Data} ->
%lists:foldl(fun(Host, S) -> process_host_term(Term, Host, S) end, %%lists:foldl(fun(Host, S) -> process_host_term(Term, Host, S) end,
% State, State#state.hosts); %% State, State#state.hosts);
process_host_term(Term, global, State); process_host_term(Term, global, State);
{host, Host} -> {host, _Host} ->
State; State;
{hosts, Hosts} -> {hosts, _Hosts} ->
State; State;
{host_config, Host, Terms} -> {host_config, Host, Terms} ->
lists:foldl(fun(T, S) -> process_host_term(T, Host, S) end, lists:foldl(fun(T, S) -> process_host_term(T, Host, S) end,
@ -139,7 +139,7 @@ process_term(Term, State) ->
{loglevel, Loglevel} -> {loglevel, Loglevel} ->
ejabberd_loglevel:set(Loglevel), ejabberd_loglevel:set(Loglevel),
State; State;
{Opt, Val} -> {_Opt, _Val} ->
lists:foldl(fun(Host, S) -> process_host_term(Term, Host, S) end, lists:foldl(fun(Host, S) -> process_host_term(Term, Host, S) end,
State, State#state.hosts) State, State#state.hosts)
end. end.
@ -148,7 +148,7 @@ process_host_term(Term, Host, State) ->
case Term of case Term of
{acl, ACLName, ACLData} -> {acl, ACLName, ACLData} ->
State#state{opts = State#state{opts =
[acl:to_record(Host, ACLName, ACLData) | State#state.opts]}; [acl:to_record(Host, ACLName, ACLData) | State#state.opts]};
{access, RuleName, Rules} -> {access, RuleName, Rules} ->
State#state{opts = [#config{key = {access, RuleName, Host}, State#state{opts = [#config{key = {access, RuleName, Host},
value = Rules} | value = Rules} |
@ -159,7 +159,7 @@ process_host_term(Term, Host, State) ->
State#state.opts]}; State#state.opts]};
{host, Host} -> {host, Host} ->
State; State;
{hosts, Hosts} -> {hosts, _Hosts} ->
State; State;
{odbc_server, ODBC_server} -> {odbc_server, ODBC_server} ->
odbc_modules_found = check_odbc_modules(ODBC_server), odbc_modules_found = check_odbc_modules(ODBC_server),
@ -285,16 +285,16 @@ check_odbc_modules2(ODBC_server) ->
case ODBC_server of case ODBC_server of
{mysql, _Server, _DB, _Username, _Password} -> {mysql, _Server, _DB, _Username, _Password} ->
check_modules_exists([mysql, mysql_auth, mysql_conn, mysql_recv]); check_modules_exists([mysql, mysql_auth, mysql_conn, mysql_recv]);
{mysql, _Server, _Port, _DB, _Username, _Password} -> {mysql, _Server, _Port, _DB, _Username, _Password} ->
check_modules_exists([mysql, mysql_auth, mysql_conn, mysql_recv]); check_modules_exists([mysql, mysql_auth, mysql_conn, mysql_recv]);
{pgsql, _Server, _DB, _Username, _Password} -> {pgsql, _Server, _DB, _Username, _Password} ->
check_modules_exists([pgsql, pgsql_proto, pgsql_tcp, pgsql_util]); check_modules_exists([pgsql, pgsql_proto, pgsql_tcp, pgsql_util]);
{pgsql, _Server, _Port, _DB, _Username, _Password} -> {pgsql, _Server, _Port, _DB, _Username, _Password} ->
check_modules_exists([pgsql, pgsql_proto, pgsql_tcp, pgsql_util]); check_modules_exists([pgsql, pgsql_proto, pgsql_tcp, pgsql_util]);
Server when is_list(Server) -> Server when is_list(Server) ->
ok ok
end. end.

View File

@ -98,7 +98,7 @@ init([]) ->
%% {stop, Reason, Reply, State} | (terminate/2 is called) %% {stop, Reason, Reply, State} | (terminate/2 is called)
%% {stop, Reason, State} (terminate/2 is called) %% {stop, Reason, State} (terminate/2 is called)
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
handle_call({add, Hook, Host, Module, Function, Seq}, From, State) -> handle_call({add, Hook, Host, Module, Function, Seq}, _From, State) ->
Reply = case ets:lookup(hooks, {Hook, Host}) of Reply = case ets:lookup(hooks, {Hook, Host}) of
[{_, Ls}] -> [{_, Ls}] ->
El = {Seq, Module, Function}, El = {Seq, Module, Function},
@ -116,7 +116,7 @@ handle_call({add, Hook, Host, Module, Function, Seq}, From, State) ->
ok ok
end, end,
{reply, Reply, State}; {reply, Reply, State};
handle_call({delete, Hook, Host, Module, Function, Seq}, From, State) -> handle_call({delete, Hook, Host, Module, Function, Seq}, _From, State) ->
Reply = case ets:lookup(hooks, {Hook, Host}) of Reply = case ets:lookup(hooks, {Hook, Host}) of
[{_, Ls}] -> [{_, Ls}] ->
NewLs = lists:delete({Seq, Module, Function}, Ls), NewLs = lists:delete({Seq, Module, Function}, Ls),
@ -126,7 +126,7 @@ handle_call({delete, Hook, Host, Module, Function, Seq}, From, State) ->
ok ok
end, end,
{reply, Reply, State}; {reply, Reply, State};
handle_call(Request, From, State) -> handle_call(_Request, _From, State) ->
Reply = ok, Reply = ok,
{reply, Reply, State}. {reply, Reply, State}.
@ -136,7 +136,7 @@ handle_call(Request, From, State) ->
%% {noreply, State, Timeout} | %% {noreply, State, Timeout} |
%% {stop, Reason, State} (terminate/2 is called) %% {stop, Reason, State} (terminate/2 is called)
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
handle_cast(Msg, State) -> handle_cast(_Msg, State) ->
{noreply, State}. {noreply, State}.
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
@ -145,7 +145,7 @@ handle_cast(Msg, State) ->
%% {noreply, State, Timeout} | %% {noreply, State, Timeout} |
%% {stop, Reason, State} (terminate/2 is called) %% {stop, Reason, State} (terminate/2 is called)
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
handle_info(Info, State) -> handle_info(_Info, State) ->
{noreply, State}. {noreply, State}.
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
@ -153,7 +153,7 @@ handle_info(Info, State) ->
%% Purpose: Shutdown the server %% Purpose: Shutdown the server
%% Returns: any (ignored by gen_server) %% Returns: any (ignored by gen_server)
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
terminate(Reason, State) -> terminate(_Reason, _State) ->
ok. ok.
@ -164,7 +164,7 @@ code_change(_OldVsn, State, _Extra) ->
%%% Internal functions %%% Internal functions
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
run1([], Hook, Args) -> run1([], _Hook, _Args) ->
ok; ok;
run1([{_Seq, Module, Function} | Ls], Hook, Args) -> run1([{_Seq, Module, Function} | Ls], Hook, Args) ->
case catch apply(Module, Function, Args) of case catch apply(Module, Function, Args) of
@ -179,7 +179,7 @@ run1([{_Seq, Module, Function} | Ls], Hook, Args) ->
end. end.
run_fold1([], Hook, Val, Args) -> run_fold1([], _Hook, Val, _Args) ->
Val; Val;
run_fold1([{_Seq, Module, Function} | Ls], Hook, Val, Args) -> run_fold1([{_Seq, Module, Function} | Ls], Hook, Val, Args) ->
case catch apply(Module, Function, [Val | Args]) of case catch apply(Module, Function, [Val | Args]) of

View File

@ -51,7 +51,7 @@
new = false, verify = false, new = false, verify = false,
timer}). timer}).
%-define(DBGFSM, true). %%-define(DBGFSM, true).
-ifdef(DBGFSM). -ifdef(DBGFSM).
-define(FSMOPTS, [{debug, [trace]}]). -define(FSMOPTS, [{debug, [trace]}]).
@ -62,10 +62,10 @@
%% Module start with or without supervisor: %% Module start with or without supervisor:
-ifdef(NO_TRANSIENT_SUPERVISORS). -ifdef(NO_TRANSIENT_SUPERVISORS).
-define(SUPERVISOR_START, p1_fsm:start(ejabberd_s2s_out, [From, Host, Type], -define(SUPERVISOR_START, p1_fsm:start(ejabberd_s2s_out, [From, Host, Type],
?FSMLIMITS ++ ?FSMOPTS)). ?FSMLIMITS ++ ?FSMOPTS)).
-else. -else.
-define(SUPERVISOR_START, supervisor:start_child(ejabberd_s2s_out_sup, -define(SUPERVISOR_START, supervisor:start_child(ejabberd_s2s_out_sup,
[From, Host, Type])). [From, Host, Type])).
-endif. -endif.
%% Only change this value if you now what your are doing: %% Only change this value if you now what your are doing:
@ -174,12 +174,12 @@ open_socket(init, StateData) ->
get_addr_port(ASCIIAddr) get_addr_port(ASCIIAddr)
end, end,
case lists:foldl(fun({Addr, Port}, Acc) -> case lists:foldl(fun({Addr, Port}, Acc) ->
case Acc of case Acc of
{ok, Socket} -> {ok, Socket} ->
{ok, Socket}; {ok, Socket};
_ -> _ ->
open_socket1(Addr, Port) open_socket1(Addr, Port)
end end
end, {error, badarg}, AddrList) of end, {error, badarg}, AddrList) of
{ok, Socket} -> {ok, Socket} ->
Version = if Version = if
@ -192,8 +192,8 @@ open_socket(init, StateData) ->
tls_enabled = false, tls_enabled = false,
streamid = new_id()}, streamid = new_id()},
send_text(NewStateData, io_lib:format(?STREAM_HEADER, send_text(NewStateData, io_lib:format(?STREAM_HEADER,
[StateData#state.server, [StateData#state.server,
Version])), Version])),
{next_state, wait_for_stream, NewStateData, ?FSMTIMEOUT}; {next_state, wait_for_stream, NewStateData, ?FSMTIMEOUT};
{error, _Reason} -> {error, _Reason} ->
?INFO_MSG("s2s connection: ~s -> ~s (remote server not found)", ?INFO_MSG("s2s connection: ~s -> ~s (remote server not found)",
@ -247,14 +247,14 @@ open_socket1(Addr, Port) ->
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) -> wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
case {xml:get_attr_s("xmlns", Attrs), case {xml:get_attr_s("xmlns", Attrs),
xml:get_attr_s("xmlns:db", Attrs), xml:get_attr_s("xmlns:db", Attrs),
xml:get_attr_s("version", Attrs) == "1.0"} of xml:get_attr_s("version", Attrs) == "1.0"} of
{"jabber:server", "jabber:server:dialback", false} -> {"jabber:server", "jabber:server:dialback", false} ->
send_db_request(StateData); send_db_request(StateData);
{"jabber:server", "jabber:server:dialback", true} when {"jabber:server", "jabber:server:dialback", true} when
StateData#state.use_v10 -> StateData#state.use_v10 ->
{next_state, wait_for_features, StateData, ?FSMTIMEOUT}; {next_state, wait_for_features, StateData, ?FSMTIMEOUT};
{"jabber:server", "", true} when StateData#state.use_v10 -> {"jabber:server", "", true} when StateData#state.use_v10 ->
{next_state, wait_for_features, StateData#state{db_enabled = false}, ?FSMTIMEOUT}; {next_state, wait_for_features, StateData#state{db_enabled = false}, ?FSMTIMEOUT};
@ -332,7 +332,7 @@ wait_for_validation({xmlstreamelement, El}, StateData) ->
{next_state, wait_for_validation, StateData, ?FSMTIMEOUT*3} {next_state, wait_for_validation, StateData, ?FSMTIMEOUT*3}
end; end;
wait_for_validation({xmlstreamend, Name}, StateData) -> wait_for_validation({xmlstreamend, _Name}, StateData) ->
?INFO_MSG("wait for validation: ~s -> ~s (xmlstreamend)", ?INFO_MSG("wait for validation: ~s -> ~s (xmlstreamend)",
[StateData#state.myname, StateData#state.server]), [StateData#state.myname, StateData#state.server]),
{stop, normal, StateData}; {stop, normal, StateData};
@ -360,8 +360,8 @@ wait_for_features({xmlstreamelement, El}, StateData) ->
{xmlelement, "stream:features", _Attrs, Els} -> {xmlelement, "stream:features", _Attrs, Els} ->
{SASLEXT, StartTLS, StartTLSRequired} = {SASLEXT, StartTLS, StartTLSRequired} =
lists:foldl( lists:foldl(
fun({xmlelement, "mechanisms", Attrs1, Els1} = El1, fun({xmlelement, "mechanisms", Attrs1, Els1} = _El1,
{SEXT, STLS, STLSReq} = Acc) -> {_SEXT, STLS, STLSReq} = Acc) ->
case xml:get_attr_s("xmlns", Attrs1) of case xml:get_attr_s("xmlns", Attrs1) of
?NS_SASL -> ?NS_SASL ->
NewSEXT = NewSEXT =
@ -377,8 +377,8 @@ wait_for_features({xmlstreamelement, El}, StateData) ->
_ -> _ ->
Acc Acc
end; end;
({xmlelement, "starttls", Attrs1, Els1} = El1, ({xmlelement, "starttls", Attrs1, _Els1} = El1,
{SEXT, STLS, STLSReq} = Acc) -> {SEXT, _STLS, _STLSReq} = Acc) ->
case xml:get_attr_s("xmlns", Attrs1) of case xml:get_attr_s("xmlns", Attrs1) of
?NS_TLS -> ?NS_TLS ->
Req = case xml:get_subtag(El1, "required") of Req = case xml:get_subtag(El1, "required") of
@ -420,7 +420,7 @@ wait_for_features({xmlstreamelement, El}, StateData) ->
?FSMTIMEOUT}; ?FSMTIMEOUT};
StartTLSRequired and (not StateData#state.tls) -> StartTLSRequired and (not StateData#state.tls) ->
?DEBUG("restarted: ~p", [{StateData#state.myname, ?DEBUG("restarted: ~p", [{StateData#state.myname,
StateData#state.server}]), StateData#state.server}]),
ejabberd_socket:close(StateData#state.socket), ejabberd_socket:close(StateData#state.socket),
{next_state, reopen_socket, {next_state, reopen_socket,
StateData#state{socket = undefined, StateData#state{socket = undefined,
@ -429,8 +429,8 @@ wait_for_features({xmlstreamelement, El}, StateData) ->
send_db_request(StateData); send_db_request(StateData);
true -> true ->
?DEBUG("restarted: ~p", [{StateData#state.myname, ?DEBUG("restarted: ~p", [{StateData#state.myname,
StateData#state.server}]), StateData#state.server}]),
% TODO: clear message queue % TODO: clear message queue
ejabberd_socket:close(StateData#state.socket), ejabberd_socket:close(StateData#state.socket),
{next_state, reopen_socket, StateData#state{socket = undefined, {next_state, reopen_socket, StateData#state{socket = undefined,
use_v10 = false}, ?FSMTIMEOUT} use_v10 = false}, ?FSMTIMEOUT}
@ -444,7 +444,7 @@ wait_for_features({xmlstreamelement, El}, StateData) ->
{stop, normal, StateData} {stop, normal, StateData}
end; end;
wait_for_features({xmlstreamend, Name}, StateData) -> wait_for_features({xmlstreamend, _Name}, StateData) ->
?INFO_MSG("wait_for_features: xmlstreamend", []), ?INFO_MSG("wait_for_features: xmlstreamend", []),
{stop, normal, StateData}; {stop, normal, StateData};
@ -469,7 +469,7 @@ wait_for_auth_result({xmlstreamelement, El}, StateData) ->
case xml:get_attr_s("xmlns", Attrs) of case xml:get_attr_s("xmlns", Attrs) of
?NS_SASL -> ?NS_SASL ->
?DEBUG("auth: ~p", [{StateData#state.myname, ?DEBUG("auth: ~p", [{StateData#state.myname,
StateData#state.server}]), StateData#state.server}]),
ejabberd_socket:reset_stream(StateData#state.socket), ejabberd_socket:reset_stream(StateData#state.socket),
send_text(StateData, send_text(StateData,
io_lib:format(?STREAM_HEADER, io_lib:format(?STREAM_HEADER,
@ -491,7 +491,7 @@ wait_for_auth_result({xmlstreamelement, El}, StateData) ->
case xml:get_attr_s("xmlns", Attrs) of case xml:get_attr_s("xmlns", Attrs) of
?NS_SASL -> ?NS_SASL ->
?DEBUG("restarted: ~p", [{StateData#state.myname, ?DEBUG("restarted: ~p", [{StateData#state.myname,
StateData#state.server}]), StateData#state.server}]),
ejabberd_socket:close(StateData#state.socket), ejabberd_socket:close(StateData#state.socket),
{next_state, reopen_socket, {next_state, reopen_socket,
StateData#state{socket = undefined}, ?FSMTIMEOUT}; StateData#state{socket = undefined}, ?FSMTIMEOUT};
@ -512,7 +512,7 @@ wait_for_auth_result({xmlstreamelement, El}, StateData) ->
{stop, normal, StateData} {stop, normal, StateData}
end; end;
wait_for_auth_result({xmlstreamend, Name}, StateData) -> wait_for_auth_result({xmlstreamend, _Name}, StateData) ->
?INFO_MSG("wait for auth result: xmlstreamend", []), ?INFO_MSG("wait for auth result: xmlstreamend", []),
{stop, normal, StateData}; {stop, normal, StateData};
@ -537,7 +537,7 @@ wait_for_starttls_proceed({xmlstreamelement, El}, StateData) ->
case xml:get_attr_s("xmlns", Attrs) of case xml:get_attr_s("xmlns", Attrs) of
?NS_TLS -> ?NS_TLS ->
?DEBUG("starttls: ~p", [{StateData#state.myname, ?DEBUG("starttls: ~p", [{StateData#state.myname,
StateData#state.server}]), StateData#state.server}]),
Socket = StateData#state.socket, Socket = StateData#state.socket,
TLSOpts = case ejabberd_config:get_local_option( TLSOpts = case ejabberd_config:get_local_option(
{domain_certfile, {domain_certfile,
@ -565,7 +565,7 @@ wait_for_starttls_proceed({xmlstreamelement, El}, StateData) ->
xml:element_to_string(?SERR_BAD_FORMAT) ++ xml:element_to_string(?SERR_BAD_FORMAT) ++
?STREAM_TRAILER), ?STREAM_TRAILER),
?INFO_MSG("Closing s2s connection: ~s -> ~s (bad format)", ?INFO_MSG("Closing s2s connection: ~s -> ~s (bad format)",
[StateData#state.myname, StateData#state.server]), [StateData#state.myname, StateData#state.server]),
{stop, normal, StateData} {stop, normal, StateData}
end; end;
_ -> _ ->
@ -574,7 +574,7 @@ wait_for_starttls_proceed({xmlstreamelement, El}, StateData) ->
{stop, normal, StateData} {stop, normal, StateData}
end; end;
wait_for_starttls_proceed({xmlstreamend, Name}, StateData) -> wait_for_starttls_proceed({xmlstreamend, _Name}, StateData) ->
?INFO_MSG("wait for starttls proceed: xmlstreamend", []), ?INFO_MSG("wait for starttls proceed: xmlstreamend", []),
{stop, normal, StateData}; {stop, normal, StateData};
@ -593,9 +593,9 @@ wait_for_starttls_proceed(closed, StateData) ->
{stop, normal, StateData}. {stop, normal, StateData}.
reopen_socket({xmlstreamelement, El}, StateData) -> reopen_socket({xmlstreamelement, _El}, StateData) ->
{next_state, reopen_socket, StateData, ?FSMTIMEOUT}; {next_state, reopen_socket, StateData, ?FSMTIMEOUT};
reopen_socket({xmlstreamend, Name}, StateData) -> reopen_socket({xmlstreamend, _Name}, StateData) ->
{next_state, reopen_socket, StateData, ?FSMTIMEOUT}; {next_state, reopen_socket, StateData, ?FSMTIMEOUT};
reopen_socket({xmlstreamerror, _}, StateData) -> reopen_socket({xmlstreamerror, _}, StateData) ->
{next_state, reopen_socket, StateData, ?FSMTIMEOUT}; {next_state, reopen_socket, StateData, ?FSMTIMEOUT};
@ -607,7 +607,7 @@ reopen_socket(closed, StateData) ->
{next_state, open_socket, StateData, ?FSMTIMEOUT}. {next_state, open_socket, StateData, ?FSMTIMEOUT}.
%% This state is use to avoid reconnecting to often to bad sockets %% This state is use to avoid reconnecting to often to bad sockets
wait_before_retry(Event, StateData) -> wait_before_retry(_Event, StateData) ->
{next_state, wait_before_retry, StateData, ?FSMTIMEOUT}. {next_state, wait_before_retry, StateData, ?FSMTIMEOUT}.
stream_established({xmlstreamelement, El}, StateData) -> stream_established({xmlstreamelement, El}, StateData) ->
@ -637,7 +637,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
end, end,
{next_state, stream_established, StateData}; {next_state, stream_established, StateData};
stream_established({xmlstreamend, Name}, StateData) -> stream_established({xmlstreamend, _Name}, StateData) ->
?INFO_MSG("stream established: ~s -> ~s (xmlstreamend)", ?INFO_MSG("stream established: ~s -> ~s (xmlstreamend)",
[StateData#state.myname, StateData#state.server]), [StateData#state.myname, StateData#state.server]),
{stop, normal, StateData}; {stop, normal, StateData};
@ -670,9 +670,9 @@ stream_established(closed, StateData) ->
%% {stop, Reason, NewStateData} | %% {stop, Reason, NewStateData} |
%% {stop, Reason, Reply, NewStateData} %% {stop, Reason, Reply, NewStateData}
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
%state_name(Event, From, StateData) -> %%state_name(Event, From, StateData) ->
% Reply = ok, %% Reply = ok,
% {reply, Reply, state_name, StateData}. %% {reply, Reply, state_name, StateData}.
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
%% Func: handle_event/3 %% Func: handle_event/3
@ -680,7 +680,7 @@ stream_established(closed, StateData) ->
%% {next_state, NextStateName, NextStateData, Timeout} | %% {next_state, NextStateName, NextStateData, Timeout} |
%% {stop, Reason, NewStateData} %% {stop, Reason, NewStateData}
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
handle_event(Event, StateName, StateData) -> handle_event(_Event, StateName, StateData) ->
{next_state, StateName, StateData, get_timeout_interval(StateName)}. {next_state, StateName, StateData, get_timeout_interval(StateName)}.
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
@ -692,11 +692,11 @@ handle_event(Event, StateName, StateData) ->
%% {stop, Reason, NewStateData} | %% {stop, Reason, NewStateData} |
%% {stop, Reason, Reply, NewStateData} %% {stop, Reason, Reply, NewStateData}
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
handle_sync_event(Event, From, StateName, StateData) -> handle_sync_event(_Event, _From, StateName, StateData) ->
Reply = ok, Reply = ok,
{reply, Reply, StateName, StateData, get_timeout_interval(StateName)}. {reply, Reply, StateName, StateData, get_timeout_interval(StateName)}.
code_change(OldVsn, StateName, StateData, Extra) -> code_change(_OldVsn, StateName, StateData, _Extra) ->
{ok, StateName, StateData}. {ok, StateName, StateData}.
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
@ -735,7 +735,7 @@ handle_info({timeout, Timer, _}, wait_before_retry,
?INFO_MSG("Reconnect delay expired: Will now retry to connect to ~s when needed.", [StateData#state.server]), ?INFO_MSG("Reconnect delay expired: Will now retry to connect to ~s when needed.", [StateData#state.server]),
{stop, normal, StateData}; {stop, normal, StateData};
handle_info({timeout, Timer, _}, StateName, handle_info({timeout, Timer, _}, _StateName,
#state{timer = Timer} = StateData) -> #state{timer = Timer} = StateData) ->
?INFO_MSG("Closing connection with ~s: timeout", [StateData#state.server]), ?INFO_MSG("Closing connection with ~s: timeout", [StateData#state.server]),
{stop, normal, StateData}; {stop, normal, StateData};
@ -783,7 +783,7 @@ send_queue(StateData, Q) ->
{{value, El}, Q1} -> {{value, El}, Q1} ->
send_element(StateData, El), send_element(StateData, El),
send_queue(StateData, Q1); send_queue(StateData, Q1);
{empty, Q1} -> {empty, _Q1} ->
ok ok
end. end.
@ -859,7 +859,7 @@ send_db_request(StateData) ->
case StateData#state.verify of case StateData#state.verify of
false -> false ->
ok; ok;
{Pid, Key2, SID} -> {_Pid, Key2, SID} ->
send_element(StateData, send_element(StateData,
{xmlelement, {xmlelement,
"db:verify", "db:verify",
@ -871,13 +871,13 @@ send_db_request(StateData) ->
{next_state, wait_for_validation, StateData#state{new = New}, ?FSMTIMEOUT*6}. {next_state, wait_for_validation, StateData#state{new = New}, ?FSMTIMEOUT*6}.
is_verify_res({xmlelement, Name, Attrs, Els}) when Name == "db:result" -> is_verify_res({xmlelement, Name, Attrs, _Els}) when Name == "db:result" ->
{result, {result,
xml:get_attr_s("to", Attrs), xml:get_attr_s("to", Attrs),
xml:get_attr_s("from", Attrs), xml:get_attr_s("from", Attrs),
xml:get_attr_s("id", Attrs), xml:get_attr_s("id", Attrs),
xml:get_attr_s("type", Attrs)}; xml:get_attr_s("type", Attrs)};
is_verify_res({xmlelement, Name, Attrs, Els}) when Name == "db:verify" -> is_verify_res({xmlelement, Name, Attrs, _Els}) when Name == "db:verify" ->
{verify, {verify,
xml:get_attr_s("to", Attrs), xml:get_attr_s("to", Attrs),
xml:get_attr_s("from", Attrs), xml:get_attr_s("from", Attrs),
@ -888,7 +888,7 @@ is_verify_res(_) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SRV support %% SRV support
-include_lib("kernel/include/inet.hrl"). -include_lib("kernel/include/inet.hrl").
@ -910,8 +910,8 @@ get_addr_port(Server) ->
[{Server, [{Server,
ejabberd_config:get_local_option(outgoing_s2s_port)}]; ejabberd_config:get_local_option(outgoing_s2s_port)}];
AddrList -> AddrList ->
% Probabilities are not exactly proportional to weights %% Probabilities are not exactly proportional to weights
% for simplicity (higher weigths are overvalued) %% for simplicity (higher weigths are overvalued)
{A1, A2, A3} = now(), {A1, A2, A3} = now(),
random:seed(A1, A2, A3), random:seed(A1, A2, A3),
case (catch lists:map( case (catch lists:map(
@ -938,15 +938,15 @@ get_addr_port(Server) ->
test_get_addr_port(Server) -> test_get_addr_port(Server) ->
lists:foldl( lists:foldl(
fun(_, Acc) -> fun(_, Acc) ->
[HostPort | _] = get_addr_port(Server), [HostPort | _] = get_addr_port(Server),
case lists:keysearch(HostPort, 1, Acc) of case lists:keysearch(HostPort, 1, Acc) of
false -> false ->
[{HostPort, 1} | Acc]; [{HostPort, 1} | Acc];
{value, {_, Num}} -> {value, {_, Num}} ->
lists:keyreplace(HostPort, 1, Acc, {HostPort, Num + 1}) lists:keyreplace(HostPort, 1, Acc, {HostPort, Num + 1})
end end
end, [], lists:seq(1, 100000)). end, [], lists:seq(1, 100000)).
%% Human readable S2S logging: Log only new outgoing connections as INFO %% Human readable S2S logging: Log only new outgoing connections as INFO

View File

@ -341,7 +341,7 @@ do_route(From, To, Packet) ->
"" -> "" ->
case Name of case Name of
"presence" -> "presence" ->
{Pass, Subsc} = {Pass, _Subsc} =
case xml:get_attr_s("type", Attrs) of case xml:get_attr_s("type", Attrs) of
"subscribe" -> "subscribe" ->
Reason = xml:get_path_s( Reason = xml:get_path_s(
@ -448,7 +448,7 @@ route_message(From, To, Packet) ->
USR = {LUser, LServer, LResource}, USR = {LUser, LServer, LResource},
case mnesia:dirty_index_read(session, USR, #session.usr) of case mnesia:dirty_index_read(session, USR, #session.usr) of
[] -> [] ->
ok; % Race condition ok; % Race condition
Ss -> Ss ->
Session = lists:max(Ss), Session = lists:max(Ss),
Pid = element(2, Session#session.sid), Pid = element(2, Session#session.sid),

View File

@ -9,7 +9,7 @@
-module(idna). -module(idna).
-author('alexey@sevcom.net'). -author('alexey@sevcom.net').
%-compile(export_all). %%-compile(export_all).
-export([domain_utf8_to_ascii/1, -export([domain_utf8_to_ascii/1,
domain_ucs2_to_ascii/1]). domain_ucs2_to_ascii/1]).
@ -26,11 +26,11 @@ utf8_to_ucs2([C | S], R) when C < 16#80 ->
utf8_to_ucs2(S, [C | R]); utf8_to_ucs2(S, [C | R]);
utf8_to_ucs2([C1, C2 | S], R) when C1 < 16#E0 -> utf8_to_ucs2([C1, C2 | S], R) when C1 < 16#E0 ->
utf8_to_ucs2(S, [((C1 band 16#1F) bsl 6) bor utf8_to_ucs2(S, [((C1 band 16#1F) bsl 6) bor
(C2 band 16#3F) | R]); (C2 band 16#3F) | R]);
utf8_to_ucs2([C1, C2, C3 | S], R) when C1 < 16#F0 -> utf8_to_ucs2([C1, C2, C3 | S], R) when C1 < 16#F0 ->
utf8_to_ucs2(S, [((C1 band 16#0F) bsl 12) bor utf8_to_ucs2(S, [((C1 band 16#0F) bsl 12) bor
((C2 band 16#3F) bsl 6) bor ((C2 band 16#3F) bsl 6) bor
(C3 band 16#3F) | R]). (C3 band 16#3F) | R]).
domain_ucs2_to_ascii(Domain) -> domain_ucs2_to_ascii(Domain) ->
@ -49,15 +49,15 @@ domain_ucs2_to_ascii1(Domain) ->
string:strip(lists:flatmap(fun(P) -> [$. | P] end, ASCIIParts), string:strip(lists:flatmap(fun(P) -> [$. | P] end, ASCIIParts),
left, $.). left, $.).
% Domain names are already nameprep'ed in ejabberd, so we skiping this step %% Domain names are already nameprep'ed in ejabberd, so we skiping this step
to_ascii(Name) -> to_ascii(Name) ->
false = lists:any( false = lists:any(
fun(C) when fun(C) when
( 0 =< C) and (C =< 16#2C) or ( 0 =< C) and (C =< 16#2C) or
(16#2E =< C) and (C =< 16#2F) or (16#2E =< C) and (C =< 16#2F) or
(16#3A =< C) and (C =< 16#40) or (16#3A =< C) and (C =< 16#40) or
(16#5B =< C) and (C =< 16#60) or (16#5B =< C) and (C =< 16#60) or
(16#7B =< C) and (C =< 16#7F) -> (16#7B =< C) and (C =< 16#7F) ->
true; true;
(_) -> (_) ->
false false
@ -101,9 +101,9 @@ punycode_encode(Input) ->
B = length(Basic), B = length(Basic),
SNonBasic = lists:usort(NonBasic), SNonBasic = lists:usort(NonBasic),
Output1 = if Output1 = if
B > 0 -> Basic ++ "-"; B > 0 -> Basic ++ "-";
true -> "" true -> ""
end, end,
Output2 = punycode_encode1(Input, SNonBasic, B, B, L, N, Delta, Bias, ""), Output2 = punycode_encode1(Input, SNonBasic, B, B, L, N, Delta, Bias, ""),
Output1 ++ Output2. Output1 ++ Output2.
@ -111,7 +111,7 @@ punycode_encode(Input) ->
punycode_encode1(Input, [M | SNonBasic], B, H, L, N, Delta, Bias, Out) punycode_encode1(Input, [M | SNonBasic], B, H, L, N, Delta, Bias, Out)
when H < L -> when H < L ->
Delta1 = Delta + (M - N) * (H + 1), Delta1 = Delta + (M - N) * (H + 1),
% let n = m % let n = m
{NewDelta, NewBias, NewH, NewOut} = {NewDelta, NewBias, NewH, NewOut} =
lists:foldl( lists:foldl(
fun(C, {ADelta, ABias, AH, AOut}) -> fun(C, {ADelta, ABias, AH, AOut}) ->
@ -129,7 +129,7 @@ punycode_encode1(Input, [M | SNonBasic], B, H, L, N, Delta, Bias, Out)
punycode_encode1( punycode_encode1(
Input, SNonBasic, B, NewH, L, M + 1, NewDelta + 1, NewBias, NewOut); Input, SNonBasic, B, NewH, L, M + 1, NewDelta + 1, NewBias, NewOut);
punycode_encode1(Input, SNonBasic, B, H, L, N, Delta, Bias, Out) -> punycode_encode1(_Input, _SNonBasic, _B, _H, _L, _N, _Delta, _Bias, Out) ->
lists:reverse(Out). lists:reverse(Out).
@ -167,7 +167,7 @@ adapt1(Delta, K) ->
true -> true ->
K + (((?BASE - ?TMIN + 1) * Delta) div (Delta + ?SKEW)) K + (((?BASE - ?TMIN + 1) * Delta) div (Delta + ?SKEW))
end. end.
codepoint(C) -> codepoint(C) ->
if if

View File

@ -37,7 +37,7 @@ import_file(File) ->
?ERROR_MSG( ?ERROR_MSG(
"Error while processing file \"~s\": ~p~n", "Error while processing file \"~s\": ~p~n",
[File, Reason]), [File, Reason]),
{error, Reason}; {error, Reason};
_ -> _ ->
ok ok
end; end;
@ -94,7 +94,7 @@ process_xdb(User, Server, {xmlelement, Name, _Attrs, Els}) ->
end. end.
xdb_data(User, Server, {xmlcdata, _CData}) -> xdb_data(_User, _Server, {xmlcdata, _CData}) ->
ok; ok;
xdb_data(User, Server, {xmlelement, _Name, Attrs, _Els} = El) -> xdb_data(User, Server, {xmlelement, _Name, Attrs, _Els} = El) ->
From = jlib:make_jid(User, Server, ""), From = jlib:make_jid(User, Server, ""),