mirror of
https://github.com/processone/ejabberd.git
synced 2024-10-13 15:16:49 +02:00
Get rid of ejabberd.hrl header
The header consisted of too many unrelated stuff and macros misuse. Some stuff is moved into scram.hrl and type_compat.hrl. All macros have been replaced with the corresponding function calls. TODO: probably type_compat.hrl is not even needed anymore since we support only Erlang >= OTP 17.5
This commit is contained in:
parent
c3c75affa9
commit
fd8e07af47
@ -42,3 +42,6 @@
|
||||
false -> ok;
|
||||
_ -> 'Elixir.Logger':bare_log(error, io_lib:format(Format, Args), [?MODULE])
|
||||
end).
|
||||
|
||||
%% Uncomment if you want to debug p1_fsm/gen_fsm
|
||||
%%-define(DBGFSM, true).
|
||||
|
@ -18,7 +18,7 @@
|
||||
%%%
|
||||
%%%----------------------------------------------------------------------
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("type_compat.hrl").
|
||||
|
||||
-define(MAX_USERS_DEFAULT, 200).
|
||||
|
||||
@ -67,7 +67,7 @@
|
||||
captcha_whitelist = (?SETS):empty() :: ?TGB_SET,
|
||||
mam = false :: boolean(),
|
||||
pubsub = <<"">> :: binary(),
|
||||
lang = ?MYLANG :: binary()
|
||||
lang = ejabberd_config:get_mylang() :: binary()
|
||||
}).
|
||||
|
||||
-type config() :: #config{}.
|
||||
|
@ -18,8 +18,6 @@
|
||||
%%%
|
||||
%%%----------------------------------------------------------------------
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
|
||||
%% -------------------------------
|
||||
%% Pubsub constants
|
||||
-define(ERR_EXTENDED(E, C), mod_pubsub:extended_error(E, C)).
|
||||
|
28
include/scram.hrl
Normal file
28
include/scram.hrl
Normal file
@ -0,0 +1,28 @@
|
||||
%%%----------------------------------------------------------------------
|
||||
%%%
|
||||
%%% ejabberd, Copyright (C) 2002-2018 ProcessOne
|
||||
%%%
|
||||
%%% This program is free software; you can redistribute it and/or
|
||||
%%% modify it under the terms of the GNU General Public License as
|
||||
%%% published by the Free Software Foundation; either version 2 of the
|
||||
%%% License, or (at your option) any later version.
|
||||
%%%
|
||||
%%% This program is distributed in the hope that it will be useful,
|
||||
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
%%% General Public License for more details.
|
||||
%%%
|
||||
%%% You should have received a copy of the GNU General Public License along
|
||||
%%% with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
%%%
|
||||
%%%----------------------------------------------------------------------
|
||||
|
||||
-record(scram, {storedkey = <<"">> :: binary(),
|
||||
serverkey = <<"">> :: binary(),
|
||||
salt = <<"">> :: binary(),
|
||||
iterationcount = 0 :: integer()}).
|
||||
|
||||
-type scram() :: #scram{}.
|
||||
|
||||
-define(SCRAM_DEFAULT_ITERATION_COUNT, 4096).
|
@ -18,41 +18,6 @@
|
||||
%%%
|
||||
%%%----------------------------------------------------------------------
|
||||
|
||||
-ifndef(EJABBERD_HRL).
|
||||
-define(EJABBERD_HRL, true).
|
||||
|
||||
-define(VERSION, ejabberd_config:get_version()).
|
||||
|
||||
-define(MYHOSTS, ejabberd_config:get_myhosts()).
|
||||
|
||||
-define(MYNAME, hd(ejabberd_config:get_myhosts())).
|
||||
|
||||
-define(MYLANG, ejabberd_config:get_mylang()).
|
||||
|
||||
-define(MSGS_DIR, filename:join(["priv", "msgs"])).
|
||||
|
||||
-define(SQL_DIR, filename:join(["priv", "sql"])).
|
||||
|
||||
-define(CONFIG_PATH, <<"ejabberd.yml">>).
|
||||
|
||||
-define(LOG_PATH, "ejabberd.log").
|
||||
|
||||
-define(EJABBERD_URI, <<"http://www.process-one.net/en/ejabberd/">>).
|
||||
|
||||
-define(COPYRIGHT, "Copyright (c) ProcessOne").
|
||||
|
||||
%%-define(DBGFSM, true).
|
||||
|
||||
-record(scram,
|
||||
{storedkey = <<"">>,
|
||||
serverkey = <<"">>,
|
||||
salt = <<"">>,
|
||||
iterationcount = 0 :: integer()}).
|
||||
|
||||
-type scram() :: #scram{}.
|
||||
|
||||
-define(SCRAM_DEFAULT_ITERATION_COUNT, 4096).
|
||||
|
||||
-ifdef(ERL_DEPRECATED_TYPES).
|
||||
|
||||
-define(TDICT, dict()).
|
||||
@ -68,5 +33,3 @@
|
||||
-define(TQUEUE, queue:queue()).
|
||||
|
||||
-endif.
|
||||
|
||||
-endif.
|
@ -43,7 +43,6 @@
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
terminate/2, code_change/3]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("jid.hrl").
|
||||
|
||||
@ -195,7 +194,7 @@ add_access(Host, Access, Rules) ->
|
||||
-spec load_from_config() -> ok.
|
||||
|
||||
load_from_config() ->
|
||||
Hosts = [global|?MYHOSTS],
|
||||
Hosts = [global|ejabberd_config:get_myhosts()],
|
||||
lists:foreach(
|
||||
fun(Host) ->
|
||||
ACLs = ejabberd_config:get_option(
|
||||
@ -453,7 +452,7 @@ acl_rule_matches({ip, {Net, Mask}}, #{ip := IP}, _Host) ->
|
||||
acl_rule_matches({user, {U, S}}, #{usr := {U, S, _}}, _Host) ->
|
||||
true;
|
||||
acl_rule_matches({user, U}, #{usr := {U, S, _}}, _Host) ->
|
||||
lists:member(S, ?MYHOSTS);
|
||||
lists:member(S, ejabberd_config:get_myhosts());
|
||||
acl_rule_matches({server, S}, #{usr := {_, S, _}}, _Host) ->
|
||||
true;
|
||||
acl_rule_matches({resource, R}, #{usr := {_, _, R}}, _Host) ->
|
||||
@ -467,7 +466,7 @@ acl_rule_matches({shared_group, G}, #{usr := {U, S, _}}, Host) ->
|
||||
acl_rule_matches({user_regexp, {UR, S}}, #{usr := {U, S, _}}, _Host) ->
|
||||
is_regexp_match(U, UR);
|
||||
acl_rule_matches({user_regexp, UR}, #{usr := {U, S, _}}, _Host) ->
|
||||
lists:member(S, ?MYHOSTS) andalso is_regexp_match(U, UR);
|
||||
lists:member(S, ejabberd_config:get_myhosts()) andalso is_regexp_match(U, UR);
|
||||
acl_rule_matches({server_regexp, SR}, #{usr := {_, S, _}}, _Host) ->
|
||||
is_regexp_match(S, SR);
|
||||
acl_rule_matches({resource_regexp, RR}, #{usr := {_, _, R}}, _Host) ->
|
||||
@ -477,7 +476,7 @@ acl_rule_matches({node_regexp, {UR, SR}}, #{usr := {U, S, _}}, _Host) ->
|
||||
acl_rule_matches({user_glob, {UR, S}}, #{usr := {U, S, _}}, _Host) ->
|
||||
is_glob_match(U, UR);
|
||||
acl_rule_matches({user_glob, UR}, #{usr := {U, S, _}}, _Host) ->
|
||||
lists:member(S, ?MYHOSTS) andalso is_glob_match(U, UR);
|
||||
lists:member(S, ejabberd_config:get_myhosts()) andalso is_glob_match(U, UR);
|
||||
acl_rule_matches({server_glob, SR}, #{usr := {_, S, _}}, _Host) ->
|
||||
is_glob_match(S, SR);
|
||||
acl_rule_matches({resource_glob, RR}, #{usr := {_, _, R}}, _Host) ->
|
||||
|
@ -14,7 +14,6 @@
|
||||
%% 3. tls-sni-01: https://tools.ietf.org/html/draft-ietf-acme-acme-05#section-7.4
|
||||
%% 4. (?) oob-01: https://tools.ietf.org/html/draft-ietf-acme-acme-05#section-7.5
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("xmpp.hrl").
|
||||
-include("ejabberd_http.hrl").
|
||||
|
@ -35,7 +35,6 @@
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
terminate/2, code_change/3]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-record(state, {}).
|
||||
|
@ -32,7 +32,6 @@
|
||||
-export([start/1, stop/0, mech_new/4, mech_step/2,
|
||||
parse/1, format_error/1, opt_type/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-behaviour(cyrsasl).
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
-export([start/1, stop/0, mech_new/4, mech_step/2, format_error/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("scram.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-behaviour(cyrsasl).
|
||||
|
@ -19,7 +19,6 @@
|
||||
terminate/2, code_change/3]).
|
||||
-export([start_link/0, opt_type/1, register_certfiles/0]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("xmpp.hrl").
|
||||
-include("ejabberd_commands.hrl").
|
||||
|
@ -22,7 +22,6 @@
|
||||
%% delete_authz/3
|
||||
]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("xmpp.hrl").
|
||||
|
||||
|
@ -61,7 +61,6 @@
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
terminate/2, code_change/3]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("ejabberd_commands.hrl").
|
||||
|
||||
@ -412,7 +411,7 @@ stop_kindly(DelaySeconds, AnnouncementTextString) ->
|
||||
ejabberd_listener, stop_listeners, []},
|
||||
{"Sending announcement to connected users",
|
||||
mod_announce, send_announcement_to_all,
|
||||
[?MYNAME, Subject, AnnouncementText]},
|
||||
[ejabberd_config:get_myname(), Subject, AnnouncementText]},
|
||||
{"Sending service message to MUC rooms",
|
||||
ejabberd_admin, send_service_message_all_mucs,
|
||||
[Subject, AnnouncementText]},
|
||||
@ -446,7 +445,7 @@ send_service_message_all_mucs(Subject, AnnouncementText) ->
|
||||
ServerHost, mod_muc, <<"conference.@HOST@">>),
|
||||
mod_muc:broadcast_service_message(ServerHost, MUCHost, Message)
|
||||
end,
|
||||
?MYHOSTS).
|
||||
ejabberd_config:get_myhosts()).
|
||||
|
||||
%%%
|
||||
%%% ejabberd_update
|
||||
@ -499,7 +498,7 @@ registered_users(Host) ->
|
||||
lists:map(fun({U, _S}) -> U end, SUsers).
|
||||
|
||||
registered_vhosts() ->
|
||||
?MYHOSTS.
|
||||
ejabberd_config:get_myhosts().
|
||||
|
||||
reload_config() ->
|
||||
ejabberd_config:reload_file().
|
||||
@ -549,13 +548,13 @@ delete_expired_messages() ->
|
||||
lists:foreach(
|
||||
fun(Host) ->
|
||||
{atomic, ok} = mod_offline:remove_expired_messages(Host)
|
||||
end, ?MYHOSTS).
|
||||
end, ejabberd_config:get_myhosts()).
|
||||
|
||||
delete_old_messages(Days) ->
|
||||
lists:foreach(
|
||||
fun(Host) ->
|
||||
{atomic, _} = mod_offline:remove_old_messages(Days, Host)
|
||||
end, ?MYHOSTS).
|
||||
end, ejabberd_config:get_myhosts()).
|
||||
|
||||
%%%
|
||||
%%% Mnesia management
|
||||
@ -622,7 +621,7 @@ keep_tables() ->
|
||||
%% loaded modules
|
||||
keep_modules_tables() ->
|
||||
lists:map(fun(Module) -> module_tables(Module) end,
|
||||
gen_mod:loaded_modules(?MYNAME)).
|
||||
gen_mod:loaded_modules(ejabberd_config:get_myname())).
|
||||
|
||||
%% TODO: This mapping should probably be moved to a callback function in each
|
||||
%% module.
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
-export([start/2, prep_stop/1, stop/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
%%%
|
||||
@ -58,7 +57,8 @@ start(normal, _Args) ->
|
||||
ejabberd_cluster:wait_for_sync(infinity),
|
||||
{T2, _} = statistics(wall_clock),
|
||||
?INFO_MSG("ejabberd ~s is started in the node ~p in ~.2fs",
|
||||
[?VERSION, node(), (T2-T1)/1000]),
|
||||
[ejabberd_config:get_version(),
|
||||
node(), (T2-T1)/1000]),
|
||||
lists:foreach(fun erlang:garbage_collect/1, processes()),
|
||||
{ok, SupPid};
|
||||
Err ->
|
||||
@ -83,7 +83,8 @@ prep_stop(State) ->
|
||||
|
||||
%% All the processes were killed when this function is called
|
||||
stop(_State) ->
|
||||
?INFO_MSG("ejabberd ~s is stopped in the node ~p", [?VERSION, node()]),
|
||||
?INFO_MSG("ejabberd ~s is stopped in the node ~p",
|
||||
[ejabberd_config:get_version(), node()]),
|
||||
delete_pid_file(),
|
||||
%%ejabberd_debug:stop(),
|
||||
ok.
|
||||
|
@ -48,7 +48,7 @@
|
||||
|
||||
-export([auth_modules/1, opt_type/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("scram.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-define(AUTH_CACHE, auth_cache).
|
||||
@ -107,7 +107,7 @@ init([]) ->
|
||||
fun(Host, Acc) ->
|
||||
Modules = auth_modules(Host),
|
||||
maps:put(Host, Modules, Acc)
|
||||
end, #{}, ?MYHOSTS),
|
||||
end, #{}, ejabberd_config:get_myhosts()),
|
||||
lists:foreach(
|
||||
fun({Host, Modules}) ->
|
||||
start(Host, Modules)
|
||||
@ -141,7 +141,7 @@ handle_cast(config_reloaded, #state{host_modules = HostModules} = State) ->
|
||||
stop(Host, OldModules -- NewModules),
|
||||
reload(Host, lists_intersection(OldModules, NewModules)),
|
||||
maps:put(Host, NewModules, Acc)
|
||||
end, HostModules, ?MYHOSTS),
|
||||
end, HostModules, ejabberd_config:get_myhosts()),
|
||||
init_cache(NewHostModules),
|
||||
{noreply, State#state{host_modules = NewHostModules}};
|
||||
handle_cast(Msg, State) ->
|
||||
@ -764,7 +764,7 @@ auth_modules() ->
|
||||
lists:flatmap(
|
||||
fun(Host) ->
|
||||
[{Host, Mod} || Mod <- auth_modules(Host)]
|
||||
end, ?MYHOSTS).
|
||||
end, ejabberd_config:get_myhosts()).
|
||||
|
||||
-spec auth_modules(binary()) -> [module()].
|
||||
auth_modules(Server) ->
|
||||
|
@ -44,7 +44,6 @@
|
||||
get_users/2, count_users/2, store_type/1,
|
||||
plain_password_required/1, opt_type/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("jid.hrl").
|
||||
|
||||
|
@ -35,7 +35,6 @@
|
||||
try_register/3, user_exists/2, remove_user/2,
|
||||
store_type/1, plain_password_required/1, opt_type/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
%%%----------------------------------------------------------------------
|
||||
|
@ -42,7 +42,6 @@
|
||||
store_type/1, plain_password_required/1,
|
||||
opt_type/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-include("eldap.hrl").
|
||||
|
@ -38,8 +38,8 @@
|
||||
plain_password_required/1, use_cache/1]).
|
||||
-export([need_transform/1, transform/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("scram.hrl").
|
||||
-include("ejabberd_auth.hrl").
|
||||
|
||||
-record(reg_users_counter, {vhost = <<"">> :: binary(),
|
||||
|
@ -38,8 +38,8 @@
|
||||
plain_password_required/1]).
|
||||
-export([passwd_schema/0]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("ejabberd_sql_pt.hrl").
|
||||
-include("scram.hrl").
|
||||
-include("ejabberd_auth.hrl").
|
||||
|
||||
start(_Host) ->
|
||||
|
@ -37,7 +37,7 @@
|
||||
remove_user/2, store_type/1, plain_password_required/1,
|
||||
convert_to_scram/1, opt_type/1, export/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("scram.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("ejabberd_sql_pt.hrl").
|
||||
-include("ejabberd_auth.hrl").
|
||||
|
@ -44,13 +44,10 @@
|
||||
handle_sync_event/4, handle_info/3, terminate/3,
|
||||
code_change/4]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("type_compat.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-include("xmpp.hrl").
|
||||
|
||||
-include("ejabberd_http.hrl").
|
||||
|
||||
-include("bosh.hrl").
|
||||
|
||||
%%-define(DBGFSM, true).
|
||||
|
@ -51,7 +51,6 @@
|
||||
reply/2, copy_state/2, set_timeout/2, route/2,
|
||||
host_up/1, host_down/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("xmpp.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("mod_roster.hrl").
|
||||
@ -415,7 +414,7 @@ bind(R, #{user := U, server := S, access := Access, lang := Lang,
|
||||
handle_stream_start(StreamStart, #{lserver := LServer} = State) ->
|
||||
case ejabberd_router:is_my_host(LServer) of
|
||||
false ->
|
||||
send(State#{lserver => ?MYNAME}, xmpp:serr_host_unknown());
|
||||
send(State#{lserver => ejabberd_config:get_myname()}, xmpp:serr_host_unknown());
|
||||
true ->
|
||||
State1 = change_shaper(State),
|
||||
Opts = ejabberd_config:codec_options(LServer),
|
||||
@ -526,9 +525,9 @@ init([State, Opts]) ->
|
||||
tls_verify => TLSVerify,
|
||||
pres_a => ?SETS:new(),
|
||||
zlib => Zlib,
|
||||
lang => ?MYLANG,
|
||||
server => ?MYNAME,
|
||||
lserver => ?MYNAME,
|
||||
lang => ejabberd_config:get_mylang(),
|
||||
server => ejabberd_config:get_myname(),
|
||||
lserver => ejabberd_config:get_myname(),
|
||||
access => Access,
|
||||
shaper => Shaper},
|
||||
State2 = xmpp_stream_in:set_timeout(State1, Timeout),
|
||||
@ -1041,7 +1040,7 @@ listen_opt_type(backlog) ->
|
||||
listen_opt_type(accept_interval) ->
|
||||
fun(I) when is_integer(I), I>=0 -> I end;
|
||||
listen_opt_type(O) ->
|
||||
StreamOpts = mod_stream_mgmt:mod_options(?MYNAME),
|
||||
StreamOpts = mod_stream_mgmt:mod_options(ejabberd_config:get_myname()),
|
||||
case lists:keyfind(O, 1, StreamOpts) of
|
||||
false ->
|
||||
[access, shaper, certfile, ciphers, dhfile, cafile,
|
||||
|
@ -45,7 +45,6 @@
|
||||
config_reloaded/0, process_iq/1]).
|
||||
|
||||
-include("xmpp.hrl").
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("ejabberd_http.hrl").
|
||||
|
||||
@ -365,12 +364,12 @@ terminate(_Reason, #state{enabled = Enabled}) ->
|
||||
register_handlers() ->
|
||||
ejabberd_hooks:add(host_up, ?MODULE, host_up, 50),
|
||||
ejabberd_hooks:add(host_down, ?MODULE, host_down, 50),
|
||||
lists:foreach(fun host_up/1, ?MYHOSTS).
|
||||
lists:foreach(fun host_up/1, ejabberd_config:get_myhosts()).
|
||||
|
||||
unregister_handlers() ->
|
||||
ejabberd_hooks:delete(host_up, ?MODULE, host_up, 50),
|
||||
ejabberd_hooks:delete(host_down, ?MODULE, host_down, 50),
|
||||
lists:foreach(fun host_down/1, ?MYHOSTS).
|
||||
lists:foreach(fun host_down/1, ejabberd_config:get_myhosts()).
|
||||
|
||||
code_change(_OldVsn, State, _Extra) -> {ok, State}.
|
||||
|
||||
@ -445,7 +444,7 @@ get_url(Str) ->
|
||||
<<TransferProt/binary, ":", Host/binary, ":",
|
||||
PortString/binary, "/captcha/", Str/binary>>;
|
||||
_ ->
|
||||
<<"http://", (?MYNAME)/binary, "/captcha/", Str/binary>>
|
||||
<<"http://", (ejabberd_config:get_myname())/binary, "/captcha/", Str/binary>>
|
||||
end.
|
||||
|
||||
get_transfer_protocol(PortString) ->
|
||||
|
@ -31,7 +31,6 @@
|
||||
get_known_nodes/0, node_id/0, get_node_by_id/1,
|
||||
send/2, wait_for_sync/1, subscribe/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-spec init() -> ok.
|
||||
|
@ -240,7 +240,6 @@
|
||||
terminate/2, code_change/3]).
|
||||
|
||||
-include("ejabberd_commands.hrl").
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include_lib("stdlib/include/ms_transform.hrl").
|
||||
|
||||
|
@ -30,7 +30,6 @@
|
||||
-export([generate_md_output/3]).
|
||||
|
||||
-include("ejabberd_commands.hrl").
|
||||
-include("ejabberd.hrl").
|
||||
|
||||
-define(RAW(V), if HTMLOutput -> fxml:crypt(iolist_to_binary(V)); true -> iolist_to_binary(V) end).
|
||||
-define(TAG(N), if HTMLOutput -> [<<"<", ??N, "/>">>]; true -> md_tag(N, <<"">>) end).
|
||||
|
@ -28,7 +28,8 @@
|
||||
|
||||
-export([start/0, load_file/1, reload_file/0, read_file/1,
|
||||
get_option/1, get_option/2, add_option/2, has_option/1,
|
||||
get_version/0, get_myhosts/0, get_mylang/0, get_lang/1,
|
||||
get_version/0, get_myhosts/0, get_myname/0,
|
||||
get_mylang/0, get_lang/1, get_uri/0, get_copyright/0,
|
||||
get_ejabberd_config_path/0, is_using_elixir_config/0,
|
||||
prepare_opt_val/4, transform_options/1, collect_options/1,
|
||||
convert_to_yaml/1, convert_to_yaml/2, v_db/2,
|
||||
@ -53,7 +54,6 @@
|
||||
{get_global_option, 3}, {get_local_option, 3},
|
||||
{get_option, 3}, {is_file_readable, 1}]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("ejabberd_config.hrl").
|
||||
-include_lib("kernel/include/file.hrl").
|
||||
@ -136,7 +136,7 @@ get_ejabberd_config_path() ->
|
||||
undefined ->
|
||||
case os:getenv("EJABBERD_CONFIG_PATH") of
|
||||
false ->
|
||||
?CONFIG_PATH;
|
||||
"ejabberd.yml";
|
||||
Path ->
|
||||
Path
|
||||
end
|
||||
@ -1087,6 +1087,11 @@ get_version() ->
|
||||
get_myhosts() ->
|
||||
get_option(hosts).
|
||||
|
||||
-spec get_myname() -> binary().
|
||||
|
||||
get_myname() ->
|
||||
hd(get_myhosts()).
|
||||
|
||||
-spec get_mylang() -> binary().
|
||||
|
||||
get_mylang() ->
|
||||
@ -1096,6 +1101,14 @@ get_mylang() ->
|
||||
get_lang(Host) ->
|
||||
get_option({language, Host}, <<"en">>).
|
||||
|
||||
-spec get_uri() -> binary().
|
||||
get_uri() ->
|
||||
<<"http://www.process-one.net/en/ejabberd/">>.
|
||||
|
||||
-spec get_copyright() -> binary().
|
||||
get_copyright() ->
|
||||
<<"Copyright (c) ProcessOne">>.
|
||||
|
||||
replace_module(mod_announce_odbc) -> {mod_announce, sql};
|
||||
replace_module(mod_blocking_odbc) -> {mod_blocking, sql};
|
||||
replace_module(mod_caps_odbc) -> {mod_caps, sql};
|
||||
|
@ -58,7 +58,6 @@
|
||||
|
||||
-include("ejabberd_ctl.hrl").
|
||||
-include("ejabberd_commands.hrl").
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-define(DEFAULT_VERSION, 1000000).
|
||||
|
@ -36,7 +36,6 @@
|
||||
|
||||
-export([init/2, opt_type/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("xmpp.hrl").
|
||||
-include("ejabberd_http.hrl").
|
||||
@ -787,7 +786,8 @@ rest_dir(N, Path, <<_H, T/binary>>) -> rest_dir(N, Path, T).
|
||||
|
||||
expand_custom_headers(Headers) ->
|
||||
lists:map(fun({K, V}) ->
|
||||
{K, misc:expand_keyword(<<"@VERSION@">>, V, ?VERSION)}
|
||||
{K, misc:expand_keyword(<<"@VERSION@">>, V,
|
||||
ejabberd_config:get_version())}
|
||||
end, Headers).
|
||||
|
||||
code_to_phrase(100) -> <<"Continue">>;
|
||||
@ -917,11 +917,11 @@ get_certfile(Opts) ->
|
||||
{_, CertFile} ->
|
||||
CertFile;
|
||||
false ->
|
||||
case ejabberd_pkix:get_certfile(?MYNAME) of
|
||||
case ejabberd_pkix:get_certfile(ejabberd_config:get_myname()) of
|
||||
{ok, CertFile} ->
|
||||
CertFile;
|
||||
error ->
|
||||
ejabberd_config:get_option({domain_certfile, ?MYNAME})
|
||||
ejabberd_config:get_option({domain_certfile, ejabberd_config:get_myname()})
|
||||
end
|
||||
end.
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
monitor/1, reset_stream/1, close/1, change_shaper/2,
|
||||
socket_handoff/3, opt_type/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-include("xmpp.hrl").
|
||||
@ -138,10 +137,10 @@ init([{#ws{ip = IP, http_opts = HOpts}, _} = WS]) ->
|
||||
end, HOpts),
|
||||
Opts = ejabberd_c2s_config:get_c2s_limits() ++ SOpts,
|
||||
PingInterval = ejabberd_config:get_option(
|
||||
{websocket_ping_interval, ?MYNAME},
|
||||
{websocket_ping_interval, ejabberd_config:get_myname()},
|
||||
?PING_INTERVAL) * 1000,
|
||||
WSTimeout = ejabberd_config:get_option(
|
||||
{websocket_timeout, ?MYNAME},
|
||||
{websocket_timeout, ejabberd_config:get_myname()},
|
||||
?WEBSOCKET_TIMEOUT) * 1000,
|
||||
Socket = {http_ws, self(), IP},
|
||||
?DEBUG("Client connected through websocket ~p",
|
||||
|
@ -34,7 +34,6 @@
|
||||
add_listener/3, delete_listener/2, transform_options/1,
|
||||
validate_cfg/1, opt_type/1, config_reloaded/0]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
%% We do not block on send anymore.
|
||||
|
@ -45,7 +45,6 @@
|
||||
-export([route_iq/2, route_iq/3]).
|
||||
-deprecated([{route_iq, 2}, {route_iq, 3}]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include_lib("stdlib/include/ms_transform.hrl").
|
||||
-include("xmpp.hrl").
|
||||
@ -106,7 +105,7 @@ get_features(Host) ->
|
||||
|
||||
init([]) ->
|
||||
process_flag(trap_exit, true),
|
||||
lists:foreach(fun host_up/1, ?MYHOSTS),
|
||||
lists:foreach(fun host_up/1, ejabberd_config:get_myhosts()),
|
||||
ejabberd_hooks:add(host_up, ?MODULE, host_up, 10),
|
||||
ejabberd_hooks:add(host_down, ?MODULE, host_down, 100),
|
||||
gen_iq_handler:start(?MODULE),
|
||||
@ -126,7 +125,7 @@ handle_info(Info, State) ->
|
||||
{noreply, State}.
|
||||
|
||||
terminate(_Reason, _State) ->
|
||||
lists:foreach(fun host_down/1, ?MYHOSTS),
|
||||
lists:foreach(fun host_down/1, ejabberd_config:get_myhosts()),
|
||||
ejabberd_hooks:delete(host_up, ?MODULE, host_up, 10),
|
||||
ejabberd_hooks:delete(host_down, ?MODULE, host_down, 100),
|
||||
ok.
|
||||
|
@ -30,7 +30,6 @@
|
||||
-export([start/0, restart/0, reopen_log/0, rotate_log/0, get/0, set/1,
|
||||
get_log_path/0, opt_type/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
|
||||
-type loglevel() :: 0 | 1 | 2 | 3 | 4 | 5.
|
||||
|
||||
@ -59,7 +58,7 @@ get_log_path() ->
|
||||
undefined ->
|
||||
case os:getenv("EJABBERD_LOG_PATH") of
|
||||
false ->
|
||||
?LOG_PATH;
|
||||
"ejabberd.log";
|
||||
Path ->
|
||||
Path
|
||||
end
|
||||
|
@ -54,7 +54,6 @@
|
||||
|
||||
-include("xmpp.hrl").
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-include("ejabberd_http.hrl").
|
||||
|
@ -34,13 +34,12 @@
|
||||
clean/1,
|
||||
opt_type/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("ejabberd_oauth.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("jid.hrl").
|
||||
|
||||
init() ->
|
||||
rest:start(?MYNAME),
|
||||
rest:start(ejabberd_config:get_myname()),
|
||||
ok.
|
||||
|
||||
store(R) ->
|
||||
@ -50,7 +49,7 @@ store(R) ->
|
||||
SJID = jid:encode({User, Server, <<"">>}),
|
||||
case rest:with_retry(
|
||||
post,
|
||||
[?MYNAME, Path, [],
|
||||
[ejabberd_config:get_myname(), Path, [],
|
||||
{[{<<"token">>, R#oauth_token.token},
|
||||
{<<"user">>, SJID},
|
||||
{<<"scope">>, R#oauth_token.scope},
|
||||
@ -65,7 +64,7 @@ store(R) ->
|
||||
|
||||
lookup(Token) ->
|
||||
Path = path(<<"lookup">>),
|
||||
case rest:with_retry(post, [?MYNAME, Path, [],
|
||||
case rest:with_retry(post, [ejabberd_config:get_myname(), Path, [],
|
||||
{[{<<"token">>, Token}]}],
|
||||
2, 500) of
|
||||
{ok, 200, {Data}} ->
|
||||
|
@ -34,7 +34,6 @@
|
||||
clean/1]).
|
||||
|
||||
-include("ejabberd_oauth.hrl").
|
||||
-include("ejabberd.hrl").
|
||||
-include("ejabberd_sql_pt.hrl").
|
||||
-include("jid.hrl").
|
||||
-include("logger.hrl").
|
||||
@ -49,7 +48,7 @@ store(R) ->
|
||||
Scope = str:join(R#oauth_token.scope, <<" ">>),
|
||||
Expire = R#oauth_token.expire,
|
||||
case ?SQL_UPSERT(
|
||||
?MYNAME,
|
||||
ejabberd_config:get_myname(),
|
||||
"oauth_token",
|
||||
["!token=%(Token)s",
|
||||
"jid=%(SJID)s",
|
||||
@ -63,7 +62,7 @@ store(R) ->
|
||||
|
||||
lookup(Token) ->
|
||||
case ejabberd_sql:sql_query(
|
||||
?MYNAME,
|
||||
ejabberd_config:get_myname(),
|
||||
?SQL("select @(jid)s, @(scope)s, @(expire)d"
|
||||
" from oauth_token where token=%(Token)s")) of
|
||||
{selected, [{SJID, Scope, Expire}]} ->
|
||||
@ -79,6 +78,6 @@ lookup(Token) ->
|
||||
|
||||
clean(TS) ->
|
||||
ejabberd_sql:sql_query(
|
||||
?MYNAME,
|
||||
ejabberd_config:get_myname(),
|
||||
?SQL("delete from oauth_token where expire < %(TS)d")).
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
-define(CHUNK_SIZE, 1024*20). %20k
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("scram.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("xmpp.hrl").
|
||||
-include("mod_privacy.hrl").
|
||||
@ -92,7 +92,7 @@ import_file(FileName, State) ->
|
||||
|
||||
-spec export_server(binary()) -> any().
|
||||
export_server(Dir) ->
|
||||
export_hosts(?MYHOSTS, Dir).
|
||||
export_hosts(ejabberd_config:get_myhosts(), Dir).
|
||||
|
||||
-spec export_host(binary(), binary()) -> any().
|
||||
export_host(Dir, Host) ->
|
||||
|
@ -33,7 +33,6 @@
|
||||
-export([start_link/0, init/1, opt_type/1,
|
||||
config_reloaded/0, start_host/1, stop_host/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
start_link() ->
|
||||
@ -56,7 +55,7 @@ get_specs() ->
|
||||
{ok, Spec} -> [Spec];
|
||||
undefined -> []
|
||||
end
|
||||
end, ?MYHOSTS).
|
||||
end, ejabberd_config:get_myhosts()).
|
||||
|
||||
-spec get_spec(binary()) -> {ok, supervisor:child_spec()} | undefined.
|
||||
get_spec(Host) ->
|
||||
@ -72,7 +71,7 @@ get_spec(Host) ->
|
||||
|
||||
-spec config_reloaded() -> ok.
|
||||
config_reloaded() ->
|
||||
lists:foreach(fun start_host/1, ?MYHOSTS).
|
||||
lists:foreach(fun start_host/1, ejabberd_config:get_myhosts()).
|
||||
|
||||
-spec start_host(binary()) -> ok.
|
||||
start_host(Host) ->
|
||||
|
@ -50,7 +50,6 @@
|
||||
-define(CALL_TIMEOUT, 60*1000). %% 60 seconds
|
||||
|
||||
-include("logger.hrl").
|
||||
-include("ejabberd.hrl").
|
||||
|
||||
-record(state, {connection :: pid() | undefined,
|
||||
num :: pos_integer(),
|
||||
|
@ -32,7 +32,6 @@
|
||||
%% Supervisor callbacks
|
||||
-export([init/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-define(DEFAULT_POOL_SIZE, 10).
|
||||
@ -98,7 +97,7 @@ init([]) ->
|
||||
%%% Internal functions
|
||||
%%%===================================================================
|
||||
is_redis_configured() ->
|
||||
lists:any(fun is_redis_configured/1, ?MYHOSTS).
|
||||
lists:any(fun is_redis_configured/1, ejabberd_config:get_myhosts()).
|
||||
|
||||
is_redis_configured(Host) ->
|
||||
ServerConfigured = ejabberd_config:has_option({redis_server, Host}),
|
||||
|
@ -41,7 +41,6 @@
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
terminate/2, code_change/3]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-record(state, {pid = self() :: pid()}).
|
||||
|
@ -33,7 +33,6 @@
|
||||
transform_options/1, get_random_pid/0,
|
||||
host_up/1, config_reloaded/0, opt_type/1]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-define(DEFAULT_POOL_SIZE, 10).
|
||||
@ -74,7 +73,7 @@ config_reloaded() ->
|
||||
end.
|
||||
|
||||
is_riak_configured() ->
|
||||
lists:any(fun is_riak_configured/1, ?MYHOSTS).
|
||||
lists:any(fun is_riak_configured/1, ejabberd_config:get_myhosts()).
|
||||
|
||||
is_riak_configured(Host) ->
|
||||
ServerConfigured = ejabberd_config:has_option({riak_server, Host}),
|
||||
|
@ -68,7 +68,6 @@
|
||||
%% This value is used in SIP and Megaco for a transaction lifetime.
|
||||
-define(IQ_TIMEOUT, 32000).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("ejabberd_router.hrl").
|
||||
-include("xmpp.hrl").
|
||||
|
@ -30,7 +30,6 @@
|
||||
-export([init/1, handle_cast/2, handle_call/3, handle_info/2,
|
||||
terminate/2, code_change/3, start_link/0]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("ejabberd_router.hrl").
|
||||
-include("logger.hrl").
|
||||
-include_lib("stdlib/include/ms_transform.hrl").
|
||||
|
@ -41,7 +41,6 @@
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||
terminate/2, code_change/3]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("xmpp.hrl").
|
||||
|
||||
|
@ -31,7 +31,6 @@
|
||||
-export([init/1, handle_cast/2, handle_call/3, handle_info/2,
|
||||
terminate/2, code_change/3, start_link/0]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("ejabberd_router.hrl").
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
-export([init/0, register_route/5, unregister_route/3, find_routes/1,
|
||||
get_all_routes/0]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
-include("ejabberd_sql_pt.hrl").
|
||||
-include("ejabberd_router.hrl").
|
||||
@ -41,7 +40,7 @@ init() ->
|
||||
Node = erlang:atom_to_binary(node(), latin1),
|
||||
?DEBUG("Cleaning SQL 'route' table...", []),
|
||||
case ejabberd_sql:sql_query(
|
||||
?MYNAME, ?SQL("delete from route where node=%(Node)s")) of
|
||||
ejabberd_config:get_myname(), ?SQL("delete from route where node=%(Node)s")) of
|
||||
{updated, _} ->
|
||||
ok;
|
||||
Err ->
|
||||
@ -53,7 +52,7 @@ register_route(Domain, ServerHost, LocalHint, _, Pid) ->
|
||||
PidS = misc:encode_pid(Pid),
|
||||
LocalHintS = enc_local_hint(LocalHint),
|
||||
Node = erlang:atom_to_binary(node(Pid), latin1),
|
||||
case ?SQL_UPSERT(?MYNAME, "route",
|
||||
case ?SQL_UPSERT(ejabberd_config:get_myname(), "route",
|
||||
["!domain=%(Domain)s",
|
||||
"!server_host=%(ServerHost)s",
|
||||
"!node=%(Node)s",
|
||||
@ -69,7 +68,7 @@ unregister_route(Domain, _, Pid) ->
|
||||
PidS = misc:encode_pid(Pid),
|
||||
Node = erlang:atom_to_binary(node(Pid), latin1),
|
||||
case ejabberd_sql:sql_query(
|
||||
?MYNAME,
|
||||
ejabberd_config:get_myname(),
|
||||
?SQL("delete from route where domain=%(Domain)s "
|
||||
"and pid=%(PidS)s and node=%(Node)s")) of
|
||||
{updated, _} ->
|
||||
@ -80,7 +79,7 @@ unregister_route(Domain, _, Pid) ->
|
||||
|
||||
find_routes(Domain) ->
|
||||
case ejabberd_sql:sql_query(
|
||||
?MYNAME,
|
||||
ejabberd_config:get_myname(),
|
||||
?SQL("select @(server_host)s, @(node)s, @(pid)s, @(local_hint)s "
|
||||
"from route where domain=%(Domain)s")) of
|
||||
{selected, Rows} ->
|
||||
@ -94,7 +93,7 @@ find_routes(Domain) ->
|
||||
|
||||
get_all_routes() ->
|
||||
case ejabberd_sql:sql_query(
|
||||
?MYNAME,
|
||||
ejabberd_config:get_myname(),
|
||||
?SQL("select @(domain)s from route where domain <> server_host")) of
|
||||