mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Better detection of duplicated routes/hosts
This commit is contained in:
parent
491993d401
commit
68d12017cc
@ -34,7 +34,7 @@
|
||||
prepare_opt_val/4, transform_options/1, collect_options/1,
|
||||
convert_to_yaml/1, convert_to_yaml/2, v_db/2,
|
||||
env_binary_to_list/2, opt_type/1, may_hide_data/1,
|
||||
is_elixir_enabled/0, v_dbs/1, v_dbs_mods/1,
|
||||
is_elixir_enabled/0, v_dbs/1, v_dbs_mods/1, v_host/1, v_hosts/1,
|
||||
default_db/1, default_db/2, default_ram_db/1, default_ram_db/2,
|
||||
default_queue_type/1, queue_dir/0, fsm_limit_opts/1,
|
||||
use_cache/1, cache_size/1, cache_missed/1, cache_life_time/1,
|
||||
@ -971,6 +971,33 @@ v_dbs_mods(Mod) ->
|
||||
(atom_to_binary(M, utf8))/binary>>, utf8)
|
||||
end, v_dbs(Mod)).
|
||||
|
||||
-spec v_host(binary()) -> binary().
|
||||
v_host(Host) ->
|
||||
hd(v_hosts([Host])).
|
||||
|
||||
-spec v_hosts([binary()]) -> [binary()].
|
||||
v_hosts(Hosts) ->
|
||||
ServerHosts = get_myhosts(),
|
||||
lists:foldr(
|
||||
fun(Host, Acc) ->
|
||||
case lists:member(Host, ServerHosts) of
|
||||
true ->
|
||||
?ERROR_MSG("Failed to reuse route ~s because it's "
|
||||
"already registered on a virtual host",
|
||||
[Host]),
|
||||
erlang:error(badarg);
|
||||
false ->
|
||||
case lists:member(Host, Acc) of
|
||||
true ->
|
||||
?ERROR_MSG("Host ~s is defined multiple times",
|
||||
[Host]),
|
||||
erlang:error(badarg);
|
||||
false ->
|
||||
[Host|Acc]
|
||||
end
|
||||
end
|
||||
end, [], Hosts).
|
||||
|
||||
-spec default_db(module()) -> atom().
|
||||
default_db(Module) ->
|
||||
default_db(global, Module).
|
||||
|
@ -60,9 +60,8 @@ reload(Host, NewOpts, OldOpts) ->
|
||||
depends(_Host, _Opts) ->
|
||||
[].
|
||||
|
||||
mod_opt_type(host) -> fun iolist_to_binary/1;
|
||||
mod_opt_type(hosts) ->
|
||||
fun(L) -> lists:map(fun iolist_to_binary/1, L) end.
|
||||
mod_opt_type(host) -> fun ejabberd_config:v_host/1;
|
||||
mod_opt_type(hosts) -> fun ejabberd_config:v_hosts/1.
|
||||
|
||||
mod_options(_Host) ->
|
||||
[{host, <<"echo.@HOST@">>}, {hosts, []}].
|
||||
|
@ -151,9 +151,9 @@ stop(ServerHost) ->
|
||||
|
||||
-spec mod_opt_type(atom()) -> fun((term()) -> term()) | [atom()].
|
||||
mod_opt_type(host) ->
|
||||
fun iolist_to_binary/1;
|
||||
fun ejabberd_config:v_host/1;
|
||||
mod_opt_type(hosts) ->
|
||||
fun (L) -> lists:map(fun iolist_to_binary/1, L) end;
|
||||
fun ejabberd_config:v_hosts/1;
|
||||
mod_opt_type(name) ->
|
||||
fun iolist_to_binary/1;
|
||||
mod_opt_type(access) ->
|
||||
|
@ -315,9 +315,8 @@ is_not_subscribed({error, StanzaError}) ->
|
||||
depends(_Host, _Opts) ->
|
||||
[{mod_pubsub, hard}].
|
||||
|
||||
mod_opt_type(host) -> fun iolist_to_binary/1;
|
||||
mod_opt_type(hosts) ->
|
||||
fun (L) -> lists:map(fun iolist_to_binary/1, L) end.
|
||||
mod_opt_type(host) -> fun ejabberd_config:v_host/1;
|
||||
mod_opt_type(hosts) -> fun ejabberd_config:v_hosts/1.
|
||||
|
||||
mod_options(_Host) ->
|
||||
[{host, <<"mix.@HOST@">>},
|
||||
|
@ -889,10 +889,9 @@ mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
||||
mod_opt_type(ram_db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
||||
mod_opt_type(history_size) ->
|
||||
fun (I) when is_integer(I), I >= 0 -> I end;
|
||||
mod_opt_type(host) -> fun iolist_to_binary/1;
|
||||
mod_opt_type(host) -> fun ejabberd_config:v_host/1;
|
||||
mod_opt_type(name) -> fun iolist_to_binary/1;
|
||||
mod_opt_type(hosts) ->
|
||||
fun (L) -> lists:map(fun iolist_to_binary/1, L) end;
|
||||
mod_opt_type(hosts) -> fun ejabberd_config:v_hosts/1;
|
||||
mod_opt_type(max_room_desc) ->
|
||||
fun (infinity) -> infinity;
|
||||
(I) when is_integer(I), I > 0 -> I
|
||||
|
@ -1083,9 +1083,8 @@ depends(_Host, _Opts) ->
|
||||
|
||||
mod_opt_type(access) ->
|
||||
fun acl:access_rules_validator/1;
|
||||
mod_opt_type(host) -> fun iolist_to_binary/1;
|
||||
mod_opt_type(hosts) ->
|
||||
fun(L) -> lists:map(fun iolist_to_binary/1, L) end;
|
||||
mod_opt_type(host) -> fun ejabberd_config:v_host/1;
|
||||
mod_opt_type(hosts) -> fun ejabberd_config:v_hosts/1;
|
||||
mod_opt_type(name) -> fun iolist_to_binary/1;
|
||||
mod_opt_type({limits, Type}) when (Type == local) or (Type == remote) ->
|
||||
fun(L) ->
|
||||
|
@ -113,9 +113,8 @@ depends(_Host, _Opts) ->
|
||||
[].
|
||||
|
||||
mod_opt_type(access) -> fun acl:access_rules_validator/1;
|
||||
mod_opt_type(host) -> fun iolist_to_binary/1;
|
||||
mod_opt_type(hosts) ->
|
||||
fun(L) -> lists:map(fun iolist_to_binary/1, L) end;
|
||||
mod_opt_type(host) -> fun ejabberd_config:v_host/1;
|
||||
mod_opt_type(hosts) -> fun ejabberd_config:v_hosts/1;
|
||||
mod_opt_type(hostname) ->
|
||||
fun(undefined) -> undefined;
|
||||
(H) -> iolist_to_binary(H)
|
||||
|
@ -3847,9 +3847,8 @@ purge_offline(Host, LJID, Node) ->
|
||||
mod_opt_type(access_createnode) -> fun acl:access_rules_validator/1;
|
||||
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
||||
mod_opt_type(name) -> fun iolist_to_binary/1;
|
||||
mod_opt_type(host) -> fun iolist_to_binary/1;
|
||||
mod_opt_type(hosts) ->
|
||||
fun (L) -> lists:map(fun iolist_to_binary/1, L) end;
|
||||
mod_opt_type(host) -> fun ejabberd_config:v_host/1;
|
||||
mod_opt_type(hosts) -> fun ejabberd_config:v_hosts/1;
|
||||
mod_opt_type(ignore_pep_from_offline) ->
|
||||
fun (A) when is_boolean(A) -> A end;
|
||||
mod_opt_type(last_item_cache) ->
|
||||
|
@ -531,9 +531,8 @@ mod_opt_type(allow_return_all) ->
|
||||
fun (B) when is_boolean(B) -> B end;
|
||||
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
|
||||
mod_opt_type(name) -> fun iolist_to_binary/1;
|
||||
mod_opt_type(host) -> fun iolist_to_binary/1;
|
||||
mod_opt_type(hosts) ->
|
||||
fun (L) -> lists:map(fun iolist_to_binary/1, L) end;
|
||||
mod_opt_type(host) -> fun ejabberd_config:v_host/1;
|
||||
mod_opt_type(hosts) -> fun ejabberd_config:v_hosts/1;
|
||||
mod_opt_type(matches) ->
|
||||
fun (infinity) -> infinity;
|
||||
(I) when is_integer(I), I > 0 -> I
|
||||
|
Loading…
Reference in New Issue
Block a user