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,
(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).
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, []}].
-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) ->
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@">>},
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
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) ->
[].
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)
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) ->
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