25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +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>
* src/acl.erl and other 64 files: Remove Erlang module attribute

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@
-module(idna).
-author('alexey@sevcom.net').
%-compile(export_all).
%%-compile(export_all).
-export([domain_utf8_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([C1, C2 | S], R) when C1 < 16#E0 ->
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(S, [((C1 band 16#0F) bsl 12) bor
((C2 band 16#3F) bsl 6) bor
(C3 band 16#3F) | R]).
((C2 band 16#3F) bsl 6) bor
(C3 band 16#3F) | R]).
domain_ucs2_to_ascii(Domain) ->
@ -49,15 +49,15 @@ domain_ucs2_to_ascii1(Domain) ->
string:strip(lists:flatmap(fun(P) -> [$. | P] end, ASCIIParts),
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) ->
false = lists:any(
fun(C) when
( 0 =< C) and (C =< 16#2C) or
(16#2E =< C) and (C =< 16#2F) or
(16#3A =< C) and (C =< 16#40) or
(16#5B =< C) and (C =< 16#60) or
(16#7B =< C) and (C =< 16#7F) ->
( 0 =< C) and (C =< 16#2C) or
(16#2E =< C) and (C =< 16#2F) or
(16#3A =< C) and (C =< 16#40) or
(16#5B =< C) and (C =< 16#60) or
(16#7B =< C) and (C =< 16#7F) ->
true;
(_) ->
false
@ -101,9 +101,9 @@ punycode_encode(Input) ->
B = length(Basic),
SNonBasic = lists:usort(NonBasic),
Output1 = if
B > 0 -> Basic ++ "-";
true -> ""
end,
B > 0 -> Basic ++ "-";
true -> ""
end,
Output2 = punycode_encode1(Input, SNonBasic, B, B, L, N, Delta, Bias, ""),
Output1 ++ Output2.
@ -111,7 +111,7 @@ punycode_encode(Input) ->
punycode_encode1(Input, [M | SNonBasic], B, H, L, N, Delta, Bias, Out)
when H < L ->
Delta1 = Delta + (M - N) * (H + 1),
% let n = m
% let n = m
{NewDelta, NewBias, NewH, NewOut} =
lists:foldl(
fun(C, {ADelta, ABias, AH, AOut}) ->
@ -129,7 +129,7 @@ punycode_encode1(Input, [M | SNonBasic], B, H, L, N, Delta, Bias, Out)
punycode_encode1(
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).
@ -167,7 +167,7 @@ adapt1(Delta, K) ->
true ->
K + (((?BASE - ?TMIN + 1) * Delta) div (Delta + ?SKEW))
end.
codepoint(C) ->
if

View File

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