25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01: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:
Evgeniy Khramtsov 2018-06-14 14:00:47 +03:00
parent c3c75affa9
commit fd8e07af47
148 changed files with 283 additions and 409 deletions

View File

@ -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).

View File

@ -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{}.

View File

@ -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
View 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).

View File

@ -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.

View File

@ -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) ->

View File

@ -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").

View File

@ -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, {}).

View File

@ -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).

View File

@ -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).

View File

@ -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").

View File

@ -22,7 +22,6 @@
%% delete_authz/3
]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").

View File

@ -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.

View File

@ -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.

View File

@ -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) ->

View File

@ -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").

View File

@ -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").
%%%----------------------------------------------------------------------

View File

@ -42,7 +42,6 @@
store_type/1, plain_password_required/1,
opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("eldap.hrl").

View File

@ -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(),

View File

@ -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) ->

View File

@ -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").

View File

@ -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).

View File

@ -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,

View File

@ -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) ->

View File

@ -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.

View File

@ -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").

View File

@ -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).

View File

@ -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};

View File

@ -58,7 +58,6 @@
-include("ejabberd_ctl.hrl").
-include("ejabberd_commands.hrl").
-include("ejabberd.hrl").
-include("logger.hrl").
-define(DEFAULT_VERSION, 1000000).

View File

@ -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.

View File

@ -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",

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -54,7 +54,6 @@
-include("xmpp.hrl").
-include("ejabberd.hrl").
-include("logger.hrl").
-include("ejabberd_http.hrl").

View File

@ -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}} ->

View File

@ -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")).

View File

@ -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) ->

View File

@ -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) ->

View File

@ -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(),

View File

@ -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}),

View File

@ -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()}).

View File

@ -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}),

View File

@ -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").

View File

@ -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").

View File

@ -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").

View File

@ -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").

View File

@ -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
{selected, Domains} ->
{ok, [Domain || {Domain} <- Domains]};

View File

@ -54,7 +54,6 @@
-export([get_info_s2s_connections/1,
transform_options/1, opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
@ -303,7 +302,7 @@ init([]) ->
{attributes, record_info(fields, temporarily_blocked)}]),
ejabberd_hooks:add(host_up, ?MODULE, host_up, 50),
ejabberd_hooks:add(host_down, ?MODULE, host_down, 60),
lists:foreach(fun host_up/1, ?MYHOSTS),
lists:foreach(fun host_up/1, ejabberd_config:get_myhosts()),
{ok, #state{}}.
handle_call(_Request, _From, State) ->
@ -322,7 +321,7 @@ handle_info(_Info, State) -> {noreply, State}.
terminate(_Reason, _State) ->
ejabberd_commands:unregister_commands(get_commands_spec()),
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, 50),
ejabberd_hooks:delete(host_down, ?MODULE, host_down, 60),
ok.
@ -544,7 +543,7 @@ is_service(From, To) ->
s2s -> % bypass RFC 3920 10.3
false;
local ->
Hosts = (?MYHOSTS),
Hosts = ejabberd_config:get_myhosts(),
P = fun (ParentDomain) ->
lists:member(ParentDomain, Hosts)
end,

View File

@ -44,7 +44,6 @@
-export([stop/1, close/1, close/2, send/2, update_state/2, establish/1,
host_up/1, host_down/1]).
-include("ejabberd.hrl").
-include("xmpp.hrl").
-include("logger.hrl").
@ -263,10 +262,10 @@ init([State, Opts]) ->
State1 = State#{tls_options => TLSOpts2,
auth_domains => sets:new(),
xmlns => ?NS_SERVER,
lang => ?MYLANG,
server => ?MYNAME,
lserver => ?MYNAME,
server_host => ?MYNAME,
lang => ejabberd_config:get_mylang(),
server => ejabberd_config:get_myname(),
lserver => ejabberd_config:get_myname(),
server_host => ejabberd_config:get_myname(),
established => false,
shaper => Shaper},
State2 = xmpp_stream_in:set_timeout(State1, Timeout),

View File

@ -42,7 +42,6 @@
-export([start/3, start_link/3, connect/1, close/1, close/2, stop/1, send/2,
route/2, establish/1, update_state/2, host_up/1, host_down/1]).
-include("ejabberd.hrl").
-include("xmpp.hrl").
-include("logger.hrl").
@ -274,7 +273,7 @@ init([#{server := LServer, remote_server := RServer} = State, Opts]) ->
State1 = State#{on_route => queue,
queue => p1_queue:new(QueueType, QueueLimit),
xmlns => ?NS_SERVER,
lang => ?MYLANG,
lang => ejabberd_config:get_mylang(),
server_host => ServerHost,
shaper => none},
State2 = xmpp_stream_out:set_timeout(State1, Timeout),

View File

@ -36,7 +36,6 @@
%% API
-export([send/2]).
-include("ejabberd.hrl").
-include("xmpp.hrl").
-include("logger.hrl").
@ -106,8 +105,8 @@ init([State, Opts]) ->
State2 = xmpp_stream_in:set_timeout(State1, Timeout),
State3 = State2#{access => Access,
xmlns => ?NS_COMPONENT,
lang => ?MYLANG,
server => ?MYNAME,
lang => ejabberd_config:get_mylang(),
server => ejabberd_config:get_myname(),
host_opts => dict:from_list(HostOpts1),
stream_version => undefined,
tls_options => TLSOpts,
@ -170,7 +169,7 @@ handle_auth_success(_, Mech, _,
end,
lists:foreach(
fun(H) ->
ejabberd_router:register_route(H, ?MYNAME),
ejabberd_router:register_route(H, ejabberd_config:get_myname()),
ejabberd_hooks:run(component_connected, [H])
end, Routes),
State.

View File

@ -44,7 +44,6 @@ start(_, _) ->
-export([tcp_init/2, udp_init/2, udp_recv/5, start/2,
socket_type/0, listen_opt_type/1]).
-include("ejabberd.hrl").
%%%===================================================================
%%% API
@ -71,11 +70,11 @@ set_certfile(Opts) ->
true ->
Opts;
false ->
case ejabberd_pkix:get_certfile(?MYNAME) of
case ejabberd_pkix:get_certfile(ejabberd_config:get_myname()) of
{ok, CertFile} ->
[{certfile, CertFile}|Opts];
error ->
case ejabberd_config:get_option({domain_certfile, ?MYNAME}) of
case ejabberd_config:get_option({domain_certfile, ejabberd_config:get_myname()}) of
undefined ->
Opts;
CertFile ->

View File

@ -85,7 +85,6 @@
-export([init/1, handle_call/3, handle_cast/2,
handle_info/2, terminate/2, code_change/3, opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
@ -428,7 +427,7 @@ init([]) ->
ejabberd_hooks:add(host_up, ?MODULE, host_up, 50),
ejabberd_hooks:add(host_down, ?MODULE, host_down, 60),
ejabberd_hooks:add(config_reloaded, ?MODULE, config_reloaded, 50),
lists:foreach(fun host_up/1, ?MYHOSTS),
lists:foreach(fun host_up/1, ejabberd_config:get_myhosts()),
ejabberd_commands:register_commands(get_commands_spec()),
{ok, #state{}}.
@ -445,7 +444,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, 50),
ejabberd_hooks:delete(host_down, ?MODULE, host_down, 60),
ejabberd_hooks:delete(config_reloaded, ?MODULE, config_reloaded, 50),
@ -848,7 +847,7 @@ get_sm_backend(Host) ->
-spec get_sm_backends() -> [module()].
get_sm_backends() ->
lists:usort([get_sm_backend(Host) || Host <- ?MYHOSTS]).
lists:usort([get_sm_backend(Host) || Host <- ejabberd_config:get_myhosts()]).
-spec get_vh_by_backend(module()) -> [binary()].
@ -856,7 +855,7 @@ get_vh_by_backend(Mod) ->
lists:filter(
fun(Host) ->
get_sm_backend(Host) == Mod
end, ?MYHOSTS).
end, ejabberd_config:get_myhosts()).
%%--------------------------------------------------------------------
%%% Cache stuff
@ -919,7 +918,7 @@ use_cache() ->
fun(Host) ->
Mod = get_sm_backend(Host),
use_cache(Mod, Host)
end, ?MYHOSTS).
end, ejabberd_config:get_myhosts()).
-spec cache_nodes(module(), binary()) -> [node()].
cache_nodes(Mod, LServer) ->

View File

@ -40,7 +40,6 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3, start_link/0]).
-include("ejabberd.hrl").
-include("ejabberd_sm.hrl").
-include_lib("stdlib/include/ms_transform.hrl").

View File

@ -37,7 +37,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_sm.hrl").
-include("logger.hrl").

View File

@ -36,7 +36,6 @@
get_sessions/1,
get_sessions/2]).
-include("ejabberd.hrl").
-include("ejabberd_sm.hrl").
-include("logger.hrl").
-include("ejabberd_sql_pt.hrl").

View File

@ -66,7 +66,6 @@
session_established/2, session_established/3,
opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("ejabberd_sql_pt.hrl").

View File

@ -33,7 +33,6 @@
get_pids/1, get_random_pid/1, transform_options/1,
opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-define(PGSQL_PORT, 5432).
@ -172,12 +171,7 @@ check_sqlite_db(Host) ->
end.
create_sqlite_tables(DB) ->
SqlDir = case code:priv_dir(ejabberd) of
{error, _} ->
?SQL_DIR;
PrivDir ->
filename:join(PrivDir, "sql")
end,
SqlDir = misc:sql_dir(),
File = filename:join(SqlDir, "lite.sql"),
case file:open(File, [read, binary]) of
{ok, Fd} ->

View File

@ -46,7 +46,6 @@ start(_, _) ->
-export([tcp_init/2, udp_init/2, udp_recv/5, start/2,
socket_type/0, listen_opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
%%%===================================================================
@ -79,7 +78,7 @@ prepare_turn_opts(Opts) ->
prepare_turn_opts(Opts, _UseTurn = false) ->
set_certfile(Opts);
prepare_turn_opts(Opts, _UseTurn = true) ->
NumberOfMyHosts = length(?MYHOSTS),
NumberOfMyHosts = length(ejabberd_config:get_myhosts()),
case proplists:get_value(turn_ip, Opts) of
undefined ->
?WARNING_MSG("option 'turn_ip' is undefined, "
@ -100,11 +99,11 @@ prepare_turn_opts(Opts, _UseTurn = true) ->
"'auth_type' is set to 'user', "
"more likely the TURN relay won't "
"be working properly. Using ~s as "
"a fallback", [?MYNAME]);
"a fallback", [ejabberd_config:get_myname()]);
true ->
ok
end,
[{auth_realm, ?MYNAME}];
[{auth_realm, ejabberd_config:get_myname()}];
_ ->
[]
end,
@ -118,7 +117,7 @@ set_certfile(Opts) ->
true ->
Opts;
false ->
Realm = proplists:get_value(auth_realm, Opts, ?MYNAME),
Realm = proplists:get_value(auth_realm, Opts, ejabberd_config:get_myname()),
case ejabberd_pkix:get_certfile(Realm) of
{ok, CertFile} ->
[{certfile, CertFile}|Opts];

View File

@ -29,7 +29,6 @@
%% API
-export([update/0, update/1, update_info/0]).
-include("ejabberd.hrl").
-include("logger.hrl").
%%====================================================================

View File

@ -31,7 +31,6 @@
%% External exports
-export([make_xhtml/1, make_xhtml/2, error/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").

View File

@ -35,7 +35,6 @@
list_users_in_diapason/4, pretty_print_xml/1,
term_to_id/1, opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
@ -1062,7 +1061,7 @@ parse_access_rule(Text) ->
%%%% list_vhosts
list_vhosts(Lang, JID) ->
Hosts = (?MYHOSTS),
Hosts = ejabberd_config:get_myhosts(),
HostsAllowed = lists:filter(fun (Host) ->
acl:any_rules_allowed(Host,
[configure, webadmin_view],
@ -1282,7 +1281,7 @@ get_stats(global, Lang) ->
ejabberd_auth:count_users(Host)
+ Total
end,
0, ?MYHOSTS),
0, ejabberd_config:get_myhosts()),
OutS2SNumber = ejabberd_s2s:outgoing_s2s_number(),
InS2SNumber = ejabberd_s2s:incoming_s2s_number(),
[?XAE(<<"table">>, [],
@ -1784,7 +1783,7 @@ get_node(global, Node, [<<"backup">>], Query, Lang) ->
?C(<<" ">>),
?INPUT(<<"text">>,
<<"export_piefxis_host_dirhost">>,
(?MYNAME))]),
(ejabberd_config:get_myname()))]),
?XE(<<"td">>,
[?INPUT(<<"text">>,
<<"export_piefxis_host_dirpath">>,
@ -1800,7 +1799,7 @@ get_node(global, Node, [<<"backup">>], Query, Lang) ->
?C(<<" ">>),
?INPUT(<<"text">>,
<<"export_sql_filehost">>,
(?MYNAME))]),
(ejabberd_config:get_myname()))]),
?XE(<<"td">>,
[?INPUT(<<"text">>,
<<"export_sql_filepath">>,

View File

@ -44,7 +44,6 @@
-export([check/2, socket_handoff/5]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").

View File

@ -37,7 +37,6 @@
-export([start/2, handler/2, process/2, socket_type/0,
transform_listen_option/2, listen_opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("ejabberd_http.hrl").
-include("mod_roster.hrl").

View File

@ -65,7 +65,7 @@
-behaviour(p1_fsm).
-include("ejabberd.hrl").
-include("type_compat.hrl").
-include("logger.hrl").
%% External exports

View File

@ -31,7 +31,6 @@
-export([start_link/7, bind/3, search/2,
modify_passwd/3]).
-include("ejabberd.hrl").
-include("logger.hrl").
%%====================================================================

View File

@ -34,7 +34,6 @@
decode_octet_string/3, uids_domain_subst/2, opt_type/1,
options/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("eldap.hrl").

View File

@ -37,7 +37,6 @@
-export([add_iq_handler/6, handle/5, iqdisc/1]).
-deprecated([{add_iq_handler, 6}, {handle, 5}, {iqdisc, 1}]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").

View File

@ -56,7 +56,6 @@
{ram_db_type, 2},
{ram_db_type, 3}]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include_lib("stdlib/include/ms_transform.hrl").
@ -127,7 +126,7 @@ stop_child(Proc) ->
%% Start all the modules in all the hosts
start_modules() ->
Hosts = ?MYHOSTS,
Hosts = ejabberd_config:get_myhosts(),
?INFO_MSG("Loading modules for ~s", [format_hosts_list(Hosts)]),
lists:foreach(fun start_modules/1, Hosts).
@ -327,7 +326,7 @@ stop_modules() ->
lists:foreach(
fun(Host) ->
stop_modules(Host)
end, ?MYHOSTS).
end, ejabberd_config:get_myhosts()).
-spec stop_modules(binary()) -> ok.
@ -418,7 +417,7 @@ get_module_opt(Host, Module, Opt) ->
get_module_opt(Host, Module, Opt, F) when is_function(F) ->
get_module_opt(Host, Module, Opt, undefined);
get_module_opt(global, Module, Opt, Default) ->
Hosts = (?MYHOSTS),
Hosts = ejabberd_config:get_myhosts(),
[Value | Values] = lists:map(fun (Host) ->
get_module_opt(Host, Module, Opt,
Default)
@ -867,7 +866,7 @@ get_hosts(Opts, Prefix) ->
undefined ->
case get_opt(host, Opts) of
undefined ->
[<<Prefix/binary, Host/binary>> || Host <- ?MYHOSTS];
[<<Prefix/binary, Host/binary>> || Host <- ejabberd_config:get_myhosts()];
Host ->
[Host]
end;
@ -902,7 +901,7 @@ config_reloaded() ->
lists:foreach(
fun(Host) ->
reload_modules(Host)
end, ?MYHOSTS).
end, ejabberd_config:get_myhosts()).
-spec is_equal_opt(atom(), opts(), opts()) ->
true | {false, any(), any()}.

View File

@ -30,7 +30,6 @@
%% External exports
-export([import_file/1, import_dir/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").

View File

@ -131,7 +131,6 @@
{expr_to_term, 1},
{term_to_expr, 1}]).
-include("ejabberd.hrl").
-include("jlib.hrl").
%send_iq(From, To, ID, SubTags) ->

View File

@ -33,8 +33,9 @@
atom_to_binary/1, binary_to_atom/1, tuple_to_binary/1,
l2i/1, i2l/1, i2l/2, expr_to_term/1, term_to_expr/1,
now_to_usec/1, usec_to_now/1, encode_pid/1, decode_pid/2,
compile_exprs/2, join_atoms/2, try_read_file/1,
css_dir/0, img_dir/0, js_dir/0, read_css/1, read_img/1, read_js/1]).
compile_exprs/2, join_atoms/2, try_read_file/1, get_descr/2,
css_dir/0, img_dir/0, js_dir/0, msgs_dir/0, sql_dir/0,
read_css/1, read_img/1, read_js/1]).
%% Deprecated functions
-export([decode_base64/1, encode_base64/1]).
@ -220,36 +221,23 @@ try_read_file(Path) ->
-spec css_dir() -> file:filename().
css_dir() ->
case os:getenv("EJABBERD_CSS_PATH") of
false ->
case code:priv_dir(ejabberd) of
{error, _} -> filename:join(["priv", "css"]);
Path -> filename:join([Path, "css"])
end;
Path -> Path
end.
get_dir("css").
-spec img_dir() -> file:filename().
img_dir() ->
case os:getenv("EJABBERD_IMG_PATH") of
false ->
case code:priv_dir(ejabberd) of
{error, _} -> filename:join(["priv", "img"]);
Path -> filename:join([Path, "img"])
end;
Path -> Path
end.
get_dir("img").
-spec js_dir() -> file:filename().
js_dir() ->
case os:getenv("EJABBERD_JS_PATH") of
false ->
case code:priv_dir(ejabberd) of
{error, _} -> filename:join(["priv", "js"]);
Path -> filename:join([Path, "js"])
end;
Path -> Path
end.
get_dir("js").
-spec msgs_dir() -> file:filename().
msgs_dir() ->
get_dir("msgs").
-spec sql_dir() -> file:filename().
sql_dir() ->
get_dir("sql").
-spec read_css(file:filename()) -> {ok, binary()} | {error, file:posix()}.
read_css(File) ->
@ -263,6 +251,12 @@ read_img(File) ->
read_js(File) ->
read_file(filename:join(js_dir(), File)).
-spec get_descr(binary(), binary()) -> binary().
get_descr(Lang, Text) ->
Desc = translate:translate(Lang, Text),
Copyright = ejabberd_config:get_copyright(),
<<Desc/binary, $\n, Copyright/binary>>.
%%%===================================================================
%%% Internal functions
%%%===================================================================
@ -304,3 +298,16 @@ read_file(Path) ->
[Path, file:format_error(Why)]),
Err
end.
-spec get_dir(string()) -> file:filename().
get_dir(Type) ->
Env = "EJABBERD_" ++ string:to_upper(Type) ++ "_PATH",
case os:getenv(Env) of
false ->
case code:priv_dir(ejabberd) of
{error, _} -> filename:join(["priv", Type]);
Path -> filename:join([Path, Type])
end;
Path ->
Path
end.

View File

@ -38,7 +38,6 @@
ping_item/4, ping_command/4, mod_opt_type/1, depends/2,
mod_options/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").

View File

@ -80,7 +80,6 @@
]).
-include("ejabberd.hrl").
-include("ejabberd_commands.hrl").
-include("mod_roster.hrl").
-include("mod_privacy.hrl").
@ -1594,7 +1593,7 @@ stats(Name) ->
case Name of
<<"uptimeseconds">> -> trunc(element(1, erlang:statistics(wall_clock))/1000);
<<"processes">> -> length(erlang:processes());
<<"registeredusers">> -> lists:foldl(fun(Host, Sum) -> ejabberd_auth:count_users(Host) + Sum end, 0, ?MYHOSTS);
<<"registeredusers">> -> lists:foldl(fun(Host, Sum) -> ejabberd_auth:count_users(Host) + Sum end, 0, ejabberd_config:get_myhosts());
<<"onlineusersnode">> -> length(ejabberd_sm:dirty_get_my_sessions_list());
<<"onlineusers">> -> length(ejabberd_sm:dirty_get_sessions_list())
end.

View File

@ -36,7 +36,6 @@
-include("logger.hrl").
-include("ejabberd.hrl").
-include("ejabberd_commands.hrl").
-include("xmpp.hrl").
-include("ejabberd_sql_pt.hrl").
@ -82,7 +81,7 @@ update_sql() ->
_ ->
update_sql(Host)
end
end, ?MYHOSTS),
end, ejabberd_config:get_myhosts()),
ok.
-record(state, {host :: binary(),

View File

@ -50,7 +50,6 @@
announce_motd_delete/1,
announce_all_hosts_motd_delete/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
-include("mod_announce.hrl").
@ -670,7 +669,7 @@ announce_motd(#message{to = To} = Packet) ->
announce_motd(To#jid.lserver, Packet).
announce_all_hosts_motd(Packet) ->
Hosts = ?MYHOSTS,
Hosts = ejabberd_config:get_myhosts(),
[announce_motd(Host, Packet) || Host <- Hosts].
announce_motd(Host, Packet) ->
@ -685,7 +684,7 @@ announce_motd_update(#message{to = To} = Packet) ->
announce_motd_update(To#jid.lserver, Packet).
announce_all_hosts_motd_update(Packet) ->
Hosts = ?MYHOSTS,
Hosts = ejabberd_config:get_myhosts(),
[announce_motd_update(Host, Packet) || Host <- Hosts].
announce_motd_update(LServer, Packet) ->
@ -703,7 +702,7 @@ announce_all_hosts_motd_delete(_Packet) ->
fun(Host) ->
Mod = gen_mod:db_mod(Host, ?MODULE),
delete_motd(Mod, Host)
end, ?MYHOSTS).
end, ejabberd_config:get_myhosts()).
-spec send_motd({presence(), ejabberd_c2s:state()}) -> {presence(), ejabberd_c2s:state()}.
send_motd({_, #{pres_last := _}} = Acc) ->

View File

@ -35,7 +35,6 @@
-export([filter_packet/1, filter_offline_msg/1, filter_subscription/2]).
-include("xmpp.hrl").
-include("ejabberd.hrl").
-include("logger.hrl").
-define(SETS, gb_sets).

View File

@ -32,7 +32,6 @@
-export([start/2, stop/1, reload/3, process_iq/1, depends/2,
disco_features/5, mod_options/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").

View File

@ -38,7 +38,6 @@
-export([depends/2, mod_opt_type/1, mod_options/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include_lib("stdlib/include/ms_transform.hrl").
-include("xmpp.hrl").

View File

@ -34,7 +34,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("bosh.hrl").

View File

@ -31,7 +31,6 @@
%% API
-export([init/0, open_session/2, close_session/1, find_session/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("ejabberd_sql_pt.hrl").
@ -42,7 +41,7 @@ init() ->
Node = erlang:atom_to_binary(node(), latin1),
?DEBUG("Cleaning SQL 'bosh' table...", []),
case ejabberd_sql:sql_query(
?MYNAME, ?SQL("delete from bosh where node=%(Node)s")) of
ejabberd_config:get_myname(), ?SQL("delete from bosh where node=%(Node)s")) of
{updated, _} ->
ok;
Err ->
@ -53,7 +52,7 @@ init() ->
open_session(SID, Pid) ->
PidS = misc:encode_pid(Pid),
Node = erlang:atom_to_binary(node(Pid), latin1),
case ?SQL_UPSERT(?MYNAME, "bosh",
case ?SQL_UPSERT(ejabberd_config:get_myname(), "bosh",
["!sid=%(SID)s",
"node=%(Node)s",
"pid=%(PidS)s"]) of
@ -65,7 +64,7 @@ open_session(SID, Pid) ->
close_session(SID) ->
case ejabberd_sql:sql_query(
?MYNAME, ?SQL("delete from bosh where sid=%(SID)s")) of
ejabberd_config:get_myname(), ?SQL("delete from bosh where sid=%(SID)s")) of
{updated, _} ->
ok;
_Err ->
@ -74,7 +73,7 @@ close_session(SID) ->
find_session(SID) ->
case ejabberd_sql:sql_query(
?MYNAME,
ejabberd_config:get_myname(),
?SQL("select @(pid)s, @(node)s from bosh where sid=%(SID)s")) of
{selected, [{Pid, Node}]} ->
try {ok, misc:decode_pid(Pid, Node)}

View File

@ -51,7 +51,6 @@
-export([user_send_packet/1, user_receive_packet/1,
c2s_presence_in/2, mod_opt_type/1, mod_options/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
@ -162,7 +161,7 @@ caps_stream_features(Acc, MyHost) ->
<<"">> ->
Acc;
Hash ->
[#caps{hash = <<"sha-1">>, node = ?EJABBERD_URI,
[#caps{hash = <<"sha-1">>, node = ejabberd_config:get_uri(),
version = Hash} | Acc]
end;
false ->
@ -476,9 +475,9 @@ concat_xdata_fields(#xdata{fields = Fields} = X) ->
-spec is_valid_node(binary()) -> boolean().
is_valid_node(Node) ->
case str:tokens(Node, <<"#">>) of
[?EJABBERD_URI|_] ->
true;
_ ->
[H|_] ->
H == ejabberd_config:get_uri();
[] ->
false
end.

View File

@ -39,7 +39,6 @@
is_carbon_copy/1, mod_opt_type/1, depends/2, clean_cache/1,
mod_options/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
-include("mod_carboncopy.hrl").

View File

@ -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("logger.hrl").
-include("mod_carboncopy.hrl").

View File

@ -28,7 +28,6 @@
%% API
-export([init/2, enable/4, disable/3, list/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("ejabberd_sql_pt.hrl").

View File

@ -40,7 +40,6 @@
c2s_authenticated_packet/2, csi_activity/2,
c2s_copy_session/2, c2s_session_resumed/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").

View File

@ -38,7 +38,6 @@
adhoc_sm_items/4, adhoc_sm_commands/4, mod_options/1,
depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
-include("ejabberd_sm.hrl").
@ -753,7 +752,7 @@ get_stopped_nodes(_Lang) ->
lists:map(
fun (N) ->
S = iolist_to_binary(atom_to_list(N)),
#disco_item{jid = jid:make(?MYNAME),
#disco_item{jid = jid:make(ejabberd_config:get_myname()),
node = <<"stopped nodes/", S/binary>>,
name = S}
end,
@ -1525,7 +1524,7 @@ set_form(From, Host, ?NS_ADMINL(<<"add-user">>), _Lang,
AccountJID = jid:decode(AccountString),
User = AccountJID#jid.luser,
Server = AccountJID#jid.lserver,
true = lists:member(Server, ?MYHOSTS),
true = lists:member(Server, ejabberd_config:get_myhosts()),
true = Server == Host orelse
get_permission_level(From) == global,
case ejabberd_auth:try_register(User, Server, Password) of

View File

@ -40,7 +40,7 @@
disco_local_features/5, disco_sm_features/5,
disco_local_identity/5, disco_sm_identity/5]).
-include("ejabberd.hrl").
-include("type_compat.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
@ -88,7 +88,7 @@ component_connected(Host) ->
fun(ServerHost) ->
Proc = gen_mod:get_module_proc(ServerHost, ?MODULE),
gen_server:cast(Proc, {component_connected, Host})
end, ?MYHOSTS).
end, ejabberd_config:get_myhosts()).
-spec component_disconnected(binary(), binary()) -> ok.
component_disconnected(Host, _Reason) ->
@ -96,7 +96,7 @@ component_disconnected(Host, _Reason) ->
fun(ServerHost) ->
Proc = gen_mod:get_module_proc(ServerHost, ?MODULE),
gen_server:cast(Proc, {component_disconnected, Host})
end, ?MYHOSTS).
end, ejabberd_config:get_myhosts()).
-spec ejabberd_local(iq()) -> iq().
ejabberd_local(IQ) ->

View File

@ -40,7 +40,6 @@
get_info/5, transform_module_options/1, mod_opt_type/1,
mod_options/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("translate.hrl").
-include("xmpp.hrl").
@ -239,7 +238,7 @@ get_vh_services(Host) ->
Hosts = lists:sort(fun (H1, H2) ->
byte_size(H1) >= byte_size(H2)
end,
?MYHOSTS),
ejabberd_config:get_myhosts()),
lists:filter(fun (H) ->
case lists:dropwhile(fun (VH) ->
not

View File

@ -38,7 +38,6 @@
handle_info/2, terminate/2, code_change/3,
mod_opt_type/1, depends/2, mod_options/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").

View File

@ -37,7 +37,6 @@
mod_opt_type/1, mod_options/1, depends/2]).
-include_lib("stdlib/include/ms_transform.hrl").
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").

View File

@ -77,7 +77,6 @@
-export([start/2, stop/1, reload/3, process/2, mod_opt_type/1, depends/2,
mod_options/1]).
-include("ejabberd.hrl").
-include("xmpp.hrl").
-include("logger.hrl").
-include("ejabberd_http.hrl").

View File

@ -45,7 +45,6 @@
-export([reopen_log/0, mod_opt_type/1, mod_options/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("ejabberd_http.hrl").
-include_lib("kernel/include/file.hrl").
@ -277,7 +276,7 @@ process(LocalPath, #request{host = Host, auth = Auth, headers = RHeaders} = Requ
"but couldn't find the related "
"ejabberd virtual host", [Host]),
{FileSize1, Code1, Headers1, Contents1} = ?HTTP_ERR_HOST_UNKNOWN,
add_to_log(FileSize1, Code1, Request#request{host = ?MYNAME}),
add_to_log(FileSize1, Code1, Request#request{host = ejabberd_config:get_myname()}),
{Code1, Headers1, Contents1}
end.
@ -383,7 +382,7 @@ reopen_log() ->
lists:foreach(
fun(Host) ->
gen_server:cast(get_proc_name(Host), reopen_log)
end, ?MYHOSTS).
end, ejabberd_config:get_myhosts()).
add_to_log(FileSize, Code, Request) ->
gen_server:cast(get_proc_name(Request#request.host),

View File

@ -89,7 +89,6 @@
expand_home/1,
expand_host/2]).
-include("ejabberd.hrl").
-include("ejabberd_http.hrl").
-include("xmpp.hrl").
-include("logger.hrl").

View File

@ -41,7 +41,6 @@
handle_info/2, terminate/2, code_change/3,
mod_opt_type/1, mod_options/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
-include("mod_irc.hrl").
@ -437,10 +436,9 @@ iq_disco(ServerHost, Node, Lang) ->
end.
iq_get_vcard(Lang) ->
Desc = translate:translate(Lang, <<"ejabberd IRC module">>),
#vcard_temp{fn = <<"ejabberd/mod_irc">>,
url = ?EJABBERD_URI,
desc = <<Desc/binary, $\n, ?COPYRIGHT>>}.
url = ejabberd_config:get_uri(),
desc = misc:get_descr(Lang, <<"ejabberd IRC module">>)}.
command_items(ServerHost, Host, Lang) ->
lists:map(fun({Node, Name, _Function}) ->

View File

@ -39,7 +39,7 @@
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").
@ -645,7 +645,7 @@ terminate(_Reason, _StateName, FullStateData) ->
{error, SError, SStateData} -> {SError, SStateData};
_ ->
{xmpp:err_internal_server_error(
<<"Server Connect Failed">>, ?MYLANG),
<<"Server Connect Failed">>, ejabberd_config:get_mylang()),
FullStateData}
end,
(StateData#state.mod):closed_connection(StateData#state.host,
@ -804,7 +804,7 @@ error_nick_in_use(_StateData, String) ->
Msg = ejabberd_regexp:replace(String,
<<".*433 +[^ ]* +">>, <<"">>),
Msg1 = filter_message(Msg),
xmpp:err_conflict(Msg1, ?MYLANG).
xmpp:err_conflict(Msg1, ejabberd_config:get_mylang()).
process_nick_in_use(StateData, String) ->
Error = error_nick_in_use(StateData, String),
@ -950,7 +950,7 @@ process_version(StateData, _Nick, From) ->
send_text(StateData,
io_lib:format("NOTICE ~s :\001VERSION ejabberd IRC "
"transport ~s (c) Alexey Shchepin\001\r\n",
[FromUser, ?VERSION])
[FromUser, ejabberd_config:get_version()])
++
io_lib:format("NOTICE ~s :\001VERSION http://ejabberd.jabber"
"studio.org/\001\r\n",
@ -1128,14 +1128,14 @@ process_error(StateData, String) ->
StateData#state.nick),
to = StateData#state.user,
type = error,
sub_els = [xmpp:err_internal_server_error(String, ?MYLANG)]})
sub_els = [xmpp:err_internal_server_error(String, ejabberd_config:get_mylang())]})
end, dict:fetch_keys(StateData#state.channels)).
error_unknown_num(_StateData, String, Type) ->
Msg = ejabberd_regexp:replace(String,
<<".*[45][0-9][0-9] +[^ ]* +">>, <<"">>),
Msg1 = filter_message(Msg),
xmpp:err_undefined_condition(Type, Msg1, ?MYLANG).
xmpp:err_undefined_condition(Type, Msg1, ejabberd_config:get_mylang()).
remove_element(E, Set) ->
case (?SETS):is_element(E, Set) of

View File

@ -37,7 +37,6 @@
remove_user/2, mod_opt_type/1, mod_options/1,
register_user/2, depends/2, privacy_check_packet/4]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").

View File

@ -520,7 +520,7 @@ delete_old_messages(TypeBin, Days) when TypeBin == <<"chat">>;
sql -> {sql, Host};
Other -> {Other, global}
end
end, ?MYHOSTS)),
end, ejabberd_config:get_myhosts())),
Results = lists:map(
fun({DBType, ServerHost}) ->
Mod = gen_mod:db_mod(DBType, ?MODULE),

View File

@ -28,7 +28,6 @@
-author('christophe.romain@process-one.net').
-behaviour(gen_mod).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").

Some files were not shown because too many files have changed in this diff Show More