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,
{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.
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} |
State#state.opts]};
{host, Host} ->
State;
- {hosts, Hosts} ->
+ {hosts, _Hosts} ->
State;
{odbc_server, ODBC_server} ->
odbc_modules_found = check_odbc_modules(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.
%% {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},
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),
ok
end,
{reply, Reply, State};
-handle_call(Request, From, State) ->
+handle_call(_Request, _From, State) ->
Reply = ok,
{reply, Reply, State}.
%% {noreply, State, Timeout} |
%% {stop, Reason, State} (terminate/2 is called)
%%----------------------------------------------------------------------
-handle_cast(Msg, State) ->
+handle_cast(_Msg, State) ->
{noreply, State}.
%%----------------------------------------------------------------------
%% {noreply, State, Timeout} |
%% {stop, Reason, State} (terminate/2 is called)
%%----------------------------------------------------------------------
-handle_info(Info, State) ->
+handle_info(_Info, State) ->
{noreply, State}.
%%----------------------------------------------------------------------
%% Purpose: Shutdown the server
%% Returns: any (ignored by gen_server)
%%----------------------------------------------------------------------
-terminate(Reason, State) ->
+terminate(_Reason, _State) ->
ok.
%%% Internal functions
%%%----------------------------------------------------------------------
-run1([], Hook, Args) ->
+run1([], _Hook, _Args) ->
ok;
run1([{_Seq, Module, Function} | Ls], Hook, Args) ->
case catch apply(Module, Function, Args) of
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
new = false, verify = false,
timer}).
-%-define(DBGFSM, true).
+%%-define(DBGFSM, true).
-ifdef(DBGFSM).
-define(FSMOPTS, [{debug, [trace]}]).
%% 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:
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
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)",
%%----------------------------------------------------------------------
-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};
{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};
{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 =
_ ->
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
?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,
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}
{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};
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,
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};
{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};
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,
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;
_ ->
{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};
{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};
{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) ->
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};
%% {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
%% {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)}.
%%----------------------------------------------------------------------
%% {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}.
%%----------------------------------------------------------------------
?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};
{{value, El}, Q1} ->
send_element(StateData, El),
send_queue(StateData, Q1);
- {empty, Q1} ->
+ {empty, _Q1} ->
ok
end.
case StateData#state.verify of
false ->
ok;
- {Pid, Key2, SID} ->
+ {_Pid, Key2, SID} ->
send_element(StateData,
{xmlelement,
"db:verify",
{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),
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% SRV support
+%% SRV support
-include_lib("kernel/include/inet.hrl").
[{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(
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