%% Option Parsing Code
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec opt_type(acme) -> fun((acme_config()) -> (acme_config()));
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(acme) ->
fun(L) ->
lists:map(
import(_LServer, {sql, _}, sql, <<"users">>, _) ->
ok.
--spec opt_type(auth_method) -> fun((atom() | [atom()]) -> [atom()]);
- (auth_password_format) -> fun((plain | scram) -> plain | scram);
- (auth_use_cache) -> fun((boolean()) -> boolean());
- (auth_cache_missed) -> fun((boolean()) -> boolean());
- (auth_cache_life_time) -> fun((timeout()) -> timeout());
- (auth_cache_size) -> fun((timeout()) -> timeout());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(auth_method) ->
fun (V) when is_list(V) ->
lists:map(fun(M) -> ejabberd_config:v_db(?MODULE, M) end, V);
store_type(_) ->
external.
--spec opt_type(allow_multiple_connection) -> fun((boolean()) -> boolean());
- (anonymous_protocol) -> fun((sasl_anon | login_anon | both) ->
- sasl_anon | login_anon | both);
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(allow_multiple_connections) ->
fun (V) when is_boolean(V) -> V end;
opt_type(anonymous_protocol) ->
sfilter = SearchFilter, lfilter = LocalFilter,
dn_filter = DNFilter, dn_filter_attrs = DNFilterAttrs}.
--spec opt_type(ldap_dn_filter) -> fun(([{binary(), binary()}]) ->
- [{binary(), binary()}]);
- (ldap_local_filter) -> fun((any()) -> any());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(ldap_dn_filter) ->
fun ([{DNF, DNFA}]) ->
NewDNFA = case DNFA of
get_pam_userinfotype(Host) ->
ejabberd_config:get_option({pam_userinfotype, Host}, username).
--spec opt_type(pam_service) -> fun((binary()) -> binary());
- (pam_userinfotype) -> fun((username | jid) -> username | jid);
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(pam_service) -> fun iolist_to_binary/1;
opt_type(pam_userinfotype) ->
fun (username) -> username;
[]
end}].
--spec opt_type(pgsql_users_number_estimate) -> fun((boolean()) -> boolean());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(pgsql_users_number_estimate) ->
fun (V) when is_boolean(V) -> V end;
opt_type(_) -> [pgsql_users_number_estimate].
set_presence(Ref, Pres) ->
call(Ref, {set_presence, Pres}, 1000).
--spec resend_presence(pid()) -> ok.
+-spec resend_presence(pid()) -> boolean().
resend_presence(Pid) ->
resend_presence(Pid, undefined).
format_reason(_, _) ->
<<"internal server error">>.
--spec get_certfile(binary()) -> file:filename_all().
+-spec get_certfile(binary()) -> file:filename_all() | undefined.
get_certfile(LServer) ->
case ejabberd_pkix:get_certfile(LServer) of
{ok, CertFile} ->
transform_listen_option(Opt, Opts) ->
[Opt|Opts].
--type resource_conflict() :: setresource | closeold | closenew | acceptnew.
--spec opt_type(c2s_ciphers) -> fun((binary()) -> binary());
- (c2s_dhfile) -> fun((binary()) -> binary());
- (c2s_cafile) -> fun((binary()) -> binary());
- (c2s_protocol_options) -> fun(([binary()]) -> binary());
- (c2s_tls_compression) -> fun((boolean()) -> boolean());
- (resource_conflict) -> fun((resource_conflict()) -> resource_conflict());
- (disable_sasl_mechanisms) -> fun((binary() | [binary()]) -> [binary()]);
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(c2s_ciphers) -> fun iolist_to_binary/1;
opt_type(c2s_dhfile) -> fun misc:try_read_file/1;
opt_type(c2s_cafile) -> fun misc:try_read_file/1;
c2s_protocol_options, c2s_tls_compression, resource_conflict,
disable_sasl_mechanisms].
--spec listen_opt_type(access) -> fun((any()) -> any());
- (shaper) -> fun((any()) -> any());
- (certfile) -> fun((binary()) -> binary());
- (ciphers) -> fun((binary()) -> binary());
- (dhfile) -> fun((binary()) -> binary());
- (cafile) -> fun((binary()) -> binary());
- (protocol_options) -> fun(([binary()]) -> binary());
- (tls_compression) -> fun((boolean()) -> boolean());
- (tls) -> fun((boolean()) -> boolean());
- (starttls) -> fun((boolean()) -> boolean());
- (tls_verify) -> fun((boolean()) -> boolean());
- (zlib) -> fun((boolean()) -> boolean());
- (supervisor) -> fun((boolean()) -> boolean());
- (max_stanza_size) -> fun((timeout()) -> timeout());
- (max_fsm_queue) -> fun((timeout()) -> timeout());
- (stream_management) -> fun((boolean()) -> boolean());
- (inet) -> fun((boolean()) -> boolean());
- (inet6) -> fun((boolean()) -> boolean());
- (backlog) -> fun((timeout()) -> timeout());
- (atom()) -> [atom()].
+-spec listen_opt_type(atom()) -> fun((any()) -> any()) | [atom()].
listen_opt_type(access) -> fun acl:access_rules_validator/1;
listen_opt_type(shaper) -> fun acl:shaper_rules_validator/1;
listen_opt_type(certfile = Opt) ->
now_priority() ->
-p1_time_compat:system_time(micro_seconds).
--spec opt_type(captcha_cmd) -> fun((binary()) -> binary());
- (captcha_host) -> fun((binary()) -> binary());
- (captcha_limit) -> fun((pos_integer()) -> pos_integer());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(captcha_cmd) ->
fun (FileName) ->
F = iolist_to_binary(FileName), if F /= <<"">> -> F end
[{access, ejabberd_config:get_option(commands_admin_access, none)}],
{get_exposed_commands(), []}}}].
--spec opt_type(commands_admin_access) -> fun((any()) -> any());
- (commands) -> fun((list()) -> list());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(commands_admin_access) -> fun acl:access_rules_validator/1;
opt_type(commands) ->
fun(V) when is_list(V) -> V end;
-include_lib("kernel/include/inet.hrl").
-include_lib("stdlib/include/ms_transform.hrl").
--callback opt_type(atom()) -> function() | [atom()].
+-callback opt_type(atom()) -> fun((any()) -> any()) | [atom()].
-type bad_option() :: invalid_option | unknown_option.
-spec start() -> ok | {error, bad_option()}.
now_to_seconds({MegaSecs, Secs, _MicroSecs}) ->
MegaSecs * 1000000 + Secs.
--spec opt_type(hide_sensitive_log_data) -> fun((boolean()) -> boolean());
- (hosts) -> fun(([binary()]) -> [binary()]);
- (language) -> fun((binary()) -> binary());
- (max_fsm_queue) -> fun((pos_integer()) -> pos_integer());
- (default_db) -> fun((atom()) -> atom());
- (default_ram_db) -> fun((atom()) -> atom());
- (loglevel) -> fun((0..5) -> 0..5);
- (queue_dir) -> fun((binary()) -> binary());
- (queue_type) -> fun((ram | file) -> ram | file);
- (use_cache) -> fun((boolean()) -> boolean());
- (cache_size) -> fun((timeout()) -> timeout());
- (cache_missed) -> fun((boolean()) -> boolean());
- (cache_life_time) -> fun((timeout()) -> timeout());
- (shared_key) -> fun((binary()) -> binary());
- (node_start) -> fun((non_neg_integer()) -> non_neg_integer());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(hide_sensitive_log_data) ->
fun (H) when is_boolean(H) -> H end;
opt_type(hosts) ->
%% ["aaaa bbb ccc"].
--spec opt_type(ejabberdctl_access_commands) -> fun((list()) -> list());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(ejabberdctl_access_commands) ->
fun (V) when is_list(V) -> V end;
opt_type(_) -> [ejabberdctl_access_commands].
transform_listen_option(Opt, Opts) ->
[Opt|Opts].
--spec opt_type(trusted_proxies) -> fun((all | [binary()]) -> all | [binary()]);
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(trusted_proxies) ->
fun (all) -> all;
(TPs) -> lists:filtermap(
end;
opt_type(_) -> [trusted_proxies].
--spec listen_opt_type(tls) -> fun((boolean()) -> boolean());
- (certfile) -> fun((binary()) -> binary());
- (ciphers) -> fun((binary()) -> binary());
- (dhfile) -> fun((binary()) -> binary());
- (protocol_options) -> fun(([binary()]) -> binary());
- (tls_compression) -> fun((boolean()) -> boolean());
- (captcha) -> fun((boolean()) -> boolean());
- (register) -> fun((boolean()) -> boolean());
- (web_admin) -> fun((boolean()) -> boolean());
- (http_bind) -> fun((boolean()) -> boolean());
- (xmlrpc) -> fun((boolean()) -> boolean());
- (request_handlers) -> fun(([{binary(), atom()}]) ->
- [{binary(), atom()}]);
- (default_host) -> fun((binary()) -> binary());
- (custom_headers) -> fun(([{binary(), binary()}]) ->
- [{binary(), binary()}]);
- (atom()) -> [atom()].
+-spec listen_opt_type(atom()) -> fun((any()) -> any()) | [atom()].
listen_opt_type(tls) ->
fun(B) when is_boolean(B) -> B end;
listen_opt_type(certfile = Opt) ->
<<>>
end.
--spec opt_type(oauth_expire) -> fun((non_neg_integer()) -> non_neg_integer());
- (oauth_access) -> fun((any()) -> any());
- (oauth_db_type) -> fun((atom()) -> atom());
- (oauth_cache_life_time) -> fun((timeout()) -> timeout());
- (oauth_cache_size) -> fun((timeout()) -> timeout());
- (oauth_use_cache) -> fun((boolean()) -> boolean());
- (oauth_cache_misse) -> fun((boolean()) -> boolean());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(oauth_expire) ->
fun(I) when is_integer(I), I >= 0 -> I end;
opt_type(oauth_access) ->
<<Base/binary, "/", Path/binary>>.
--spec opt_type(ext_api_path_oauth) -> fun((binary()) -> binary());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(ext_api_path_oauth) ->
fun (X) -> iolist_to_binary(X) end;
opt_type(_) -> [ext_api_path_oauth].
%%%===================================================================
%%% API
%%%===================================================================
--spec add_certfile(filename:filename())
+-spec add_certfile(file:filename())
-> ok | {error, cert_error() | file:posix()}.
add_certfile(Path) ->
gen_server:call(?MODULE, {add_certfile, prep_path(Path)}).
--spec try_certfile(filename:filename()) -> binary().
+-spec try_certfile(file:filename()) -> binary().
try_certfile(Path0) ->
Path = prep_path(Path0),
case load_certfile(Path) of
end, Es)
end.
--spec prep_path(filename:filename()) -> binary().
+-spec prep_path(file:filename()) -> binary().
prep_path(Path0) ->
case filename:pathtype(Path0) of
relative ->
undefined -> false
end.
--type sql_type() :: mysql | pgsql | sqlite | mssql | odbc.
--spec opt_type(sql_type) -> fun((sql_type()) -> sql_type());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(sql_type) ->
fun (mysql) -> mysql;
(pgsql) -> pgsql;
iolist_to_list(IOList) ->
binary_to_list(iolist_to_binary(IOList)).
--spec opt_type(redis_connect_timeout) -> fun((pos_integer()) -> pos_integer());
- (redis_db) -> fun((non_neg_integer()) -> non_neg_integer());
- (redis_password) -> fun((binary()) -> binary());
- (redis_port) -> fun((0..65535) -> 0..65535);
- (redis_server) -> fun((binary()) -> binary());
- (redis_pool_size) -> fun((pos_integer()) -> pos_integer());
- (redis_queue_type) -> fun((ram | file) -> ram | file);
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(redis_connect_timeout) ->
fun (I) when is_integer(I), I > 0 -> I end;
opt_type(redis_db) ->
transform_options(Opt, Opts) ->
[Opt|Opts].
--spec opt_type(riak_pool_size) -> fun((pos_integer()) -> pos_integer());
- (riak_port) -> fun((0..65535) -> 0..65535);
- (riak_server) -> fun((binary()) -> binary());
- (riak_start_interval) -> fun((pos_integer()) -> pos_integer());
- (riak_cacertfile) -> fun((binary()) -> binary());
- (riak_username) -> fun((binary()) -> binary());
- (riak_password) -> fun((binary()) -> binary());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(riak_pool_size) ->
fun (N) when is_integer(N), N >= 1 -> N end;
opt_type(riak_port) ->
end,
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
--spec clean_cache(node()) -> ok.
+-spec clean_cache(node()) -> non_neg_integer().
clean_cache(Node) ->
ets_cache:filter(
?ROUTES_CACHE,
clean_cache() ->
ejabberd_cluster:eval_everywhere(?MODULE, clean_cache, [node()]).
--type domain_balancing() :: random | source | destination |
- bare_source | bare_destination.
--spec opt_type(domain_balancing) -> fun((domain_balancing()) -> domain_balancing());
- (domain_balancing_component_number) -> fun((pos_integer()) -> pos_integer());
- (router_db_type) -> fun((atom()) -> atom());
- (router_use_cache) -> fun((boolean()) -> boolean());
- (router_cache_missed) -> fun((boolean()) -> boolean());
- (router_cache_size) -> fun((timeout()) -> timeout());
- (router_cache_life_time) -> fun((timeout()) -> timeout());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(domain_balancing) ->
fun (random) -> random;
(source) -> source;
end,
[{s2s_pid, S2sPid} | Infos].
--type use_starttls() :: boolean() | optional | required | required_trusted.
--spec opt_type(route_subdomains) -> fun((s2s | local) -> s2s | local);
- (s2s_access) -> fun((any()) -> any());
- (s2s_ciphers) -> fun((binary()) -> binary());
- (s2s_dhfile) -> fun((binary()) -> binary());
- (s2s_cafile) -> fun((binary()) -> binary());
- (s2s_protocol_options) -> fun(([binary()]) -> binary());
- (s2s_tls_compression) -> fun((boolean()) -> boolean());
- (s2s_use_starttls) -> fun((use_starttls()) -> use_starttls());
- (s2s_zlib) -> fun((boolean()) -> boolean());
- (s2s_timeout) -> fun((timeout()) -> timeout());
- (s2s_queue_type) -> fun((ram | file) -> ram | file);
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(route_subdomains) ->
fun (s2s) -> s2s;
(local) -> local
Shaper = acl:match_rule(ServerHost, ShaperName, jid:make(RServer)),
xmpp_stream_in:change_shaper(State, ejabberd_shaper:new(Shaper)).
--spec listen_opt_type(shaper) -> fun((any()) -> any());
- (certfile) -> fun((binary()) -> binary());
- (ciphers) -> fun((binary()) -> binary());
- (dhfile) -> fun((binary()) -> binary());
- (cafile) -> fun((binary()) -> binary());
- (protocol_options) -> fun(([binary()]) -> binary());
- (tls_compression) -> fun((boolean()) -> boolean());
- (tls) -> fun((boolean()) -> boolean());
- (supervisor) -> fun((boolean()) -> boolean());
- (max_stanza_type) -> fun((timeout()) -> timeout());
- (max_fsm_queue) -> fun((pos_integer()) -> pos_integer());
- (inet) -> fun((boolean()) -> boolean());
- (inet6) -> fun((boolean()) -> boolean());
- (backlog) -> fun((timeout()) -> timeout());
- (atom()) -> [atom()].
+-spec listen_opt_type(atom()) -> fun((any()) -> any()) | [atom()].
listen_opt_type(shaper) -> fun acl:shaper_rules_validator/1;
listen_opt_type(certfile = Opt) ->
fun(S) ->
maybe_report_huge_timeout(_, _) ->
ok.
--spec opt_type(outgoing_s2s_families) -> fun(([ipv4|ipv6]) -> [inet|inet6]);
- (outgoing_s2s_port) -> fun((0..65535) -> 0..65535);
- (outgoing_s2s_timeout) -> fun((timeout()) -> timeout());
- (s2s_dns_retries) -> fun((non_neg_integer()) -> non_neg_integer());
- (s2s_dns_timeout) -> fun((timeout()) -> timeout());
- (s2s_max_retry_delay) -> fun((pos_integer()) -> pos_integer());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(outgoing_s2s_families) ->
fun(Families) ->
lists:map(
transform_listen_option(Opt, Opts) ->
[Opt|Opts].
--spec listen_opt_type(access) -> fun((any()) -> any());
- (shaper_rule) -> fun((any()) -> any());
- (certfile) -> fun((binary()) -> binary());
- (ciphers) -> fun((binary()) -> binary());
- (dhfile) -> fun((binary()) -> binary());
- (cafile) -> fun((binary()) -> binary());
- (protocol_options) -> fun(([binary()]) -> binary());
- (tls_compression) -> fun((boolean()) -> boolean());
- (tls) -> fun((boolean()) -> boolean());
- (check_from) -> fun((boolean()) -> boolean());
- (password) -> fun((boolean()) -> boolean());
- (hosts) -> fun(([{binary(), [{password, binary()}]}]) ->
- [{binary(), binary() | undefined}]);
- (max_stanza_type) -> fun((timeout()) -> timeout());
- (max_fsm_queue) -> fun((pos_integer()) -> pos_integer());
- (inet) -> fun((boolean()) -> boolean());
- (inet6) -> fun((boolean()) -> boolean());
- (backlog) -> fun((timeout()) -> timeout());
- (atom()) -> [atom()].
+-spec listen_opt_type(atom()) -> fun((any()) -> any()) | [atom()].
listen_opt_type(access) -> fun acl:access_rules_validator/1;
listen_opt_type(shaper_rule) -> fun acl:shaper_rules_validator/1;
listen_opt_type(certfile) ->
transform_options(Opt, Opts) ->
[Opt | Opts].
--spec opt_type(shaper) -> fun((any()) -> any());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(shaper) -> fun(V) -> V end;
opt_type(_) -> [shaper].
end,
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
--spec clean_cache(node()) -> ok.
+-spec clean_cache(node()) -> non_neg_integer().
clean_cache(Node) ->
ets_cache:filter(
?SM_CACHE,
make_sid() ->
{p1_time_compat:unique_timestamp(), self()}.
--spec opt_type(sm_db_type) -> fun((atom()) -> atom());
- (sm_use_cache) -> fun((boolean()) -> boolean());
- (sm_cache_missed) -> fun((boolean()) -> boolean());
- (sm_cache_size) -> fun((timeout()) -> timeout());
- (sm_cache_life_time) -> fun((timeout()) -> timeout());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(sm_db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
opt_type(O) when O == sm_use_cache; O == sm_cache_missed ->
fun(B) when is_boolean(B) -> B end;
check_error(Result, _Query) ->
Result.
--spec opt_type(sql_database) -> fun((binary()) -> binary());
- (sql_keepalive_interval) -> fun((pos_integer()) -> pos_integer());
- (sql_password) -> fun((binary()) -> binary());
- (sql_port) -> fun((0..65535) -> 0..65535);
- (sql_server) -> fun((binary()) -> binary());
- (sql_username) -> fun((binary()) -> binary());
- (sql_ssl) -> fun((boolean()) -> boolean());
- (sql_ssl_verify) -> fun((boolean()) -> boolean());
- (sql_ssl_certfile) -> fun((boolean()) -> boolean());
- (sql_ssl_cafile) -> fun((boolean()) -> boolean());
- (sql_query_timeout) -> fun((pos_integer()) -> pos_integer());
- (sql_connect_timeout) -> fun((pos_integer()) -> pos_integer());
- (sql_queue_type) -> fun((ram | file) -> ram | file);
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(sql_database) -> fun iolist_to_binary/1;
opt_type(sql_keepalive_interval) ->
fun (I) when is_integer(I), I > 0 -> I end;
[]
end.
--spec opt_type(sql_pool_size) -> fun((pos_integer()) -> pos_integer());
- (sql_start_interval) -> fun((pos_integer()) -> pos_integer());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(sql_pool_size) ->
fun (I) when is_integer(I), I > 0 -> I end;
opt_type(sql_start_interval) ->
%%%==================================
--spec opt_type(access_readonly) -> fun((any()) -> any());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(access_readonly) -> fun acl:access_rules_validator/1;
opt_type(_) -> [access_readonly].
collect_parts_bit([],Acc,Uacc) ->
list_to_binary([Uacc|lists:reverse(Acc)]).
--type deref_aliases() :: never | searching | finding | always.
--type uids() :: binary() | {binary()} | {binary(), binary()}.
--spec opt_type(deref_aliases) -> fun((deref_aliases()) -> deref_aliases());
- (ldap_backups) -> fun(([binary()]) -> [binary()]);
- (ldap_base) -> fun((binary()) -> binary());
- (ldap_deref_aliases) -> fun((deref_aliases()) -> deref_aliases());
- (ldap_encrypt) -> fun((tls | starttls | none) -> tls | starttls | none);
- (ldap_password) -> fun((binary()) -> binary());
- (ldap_port) -> fun((0..65535) -> 0..65535);
- (ldap_rootdn) -> fun((binary()) -> binary());
- (ldap_servers) -> fun(([binary()]) -> [binary()]);
- (ldap_tls_certfile) -> fun((binary()) -> string());
- (ldap_tls_cacertfile) -> fun((binary()) -> string());
- (ldap_tls_depth) -> fun((non_neg_integer()) -> non_neg_integer());
- (ldap_tls_verify) -> fun((hard | soft | false) -> hard | soft | false);
- (ldap_filter) -> fun((binary()) -> binary());
- (ldap_uids) -> fun((uids()) -> uids());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(deref_aliases) ->
fun(unspecified) -> unspecified;
(never) -> never;
format({Key, Val}) -> % TODO: improve Yaml parsing
{Key, Val}.
--spec opt_type(allow_contrib_modules) -> fun((boolean()) -> boolean());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(allow_contrib_modules) ->
fun (false) -> false;
(no) -> false;
Opt
end, Opts).
--spec opt_type(iqdisc) -> fun((any()) -> no_queue);
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(iqdisc) -> fun check_type/1;
opt_type(_) -> [iqdisc].
is_opt_list(_) ->
false.
--spec opt_type(modules) -> fun(([{atom(), list()}]) -> [{atom(), list()}]);
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(modules) ->
fun(Mods) ->
lists:map(
end,
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
--spec clean_cache(node()) -> ok.
+-spec clean_cache(node()) -> non_neg_integer().
clean_cache(Node) ->
ets_cache:filter(
?BOSH_CACHE,
false -> ejabberd_cluster:get_nodes()
end.
--spec clean_cache(node()) -> ok.
+-spec clean_cache(node()) -> non_neg_integer().
clean_cache(Node) ->
ets_cache:filter(
?CARBONCOPY_CACHE,
ts :: integer()}).
-record(dest, {jid_string :: binary() | none,
- jid_jid :: xmpp:jid(),
+ jid_jid :: jid(),
type :: to | cc | bcc,
address :: address()}).
%%% Route packet
%%%-------------------------
--spec route_packet(jid(), #dest{}, xmpp:stanza(), [addresses()], [addresses()]) -> 'ok'.
+-spec route_packet(jid(), #dest{}, stanza(), [addresses()], [addresses()]) -> 'ok'.
route_packet(From, ToDest, Packet, Others, Addresses) ->
Dests = case ToDest#dest.type of
bcc -> [];
route_packet2(From, ToDest#dest.jid_string, Dests,
Packet, {Others, Addresses}).
--spec route_packet_multicast(jid(), binary(), xmpp:stanza(), [#dest{}], [address()], #limits{}) -> 'ok'.
+-spec route_packet_multicast(jid(), binary(), stanza(), [#dest{}], [address()], #limits{}) -> 'ok'.
route_packet_multicast(From, ToS, Packet, Dests,
Addresses, Limits) ->
Type_of_stanza = type_of_stanza(Packet),
Addresses)
end, Fragmented_dests).
--spec route_packet2(jid(), binary(), [#dest{}], xmpp:stanza(), {[address()], [address()]} | [address()]) -> 'ok'.
+-spec route_packet2(jid(), binary(), [#dest{}], stanza(), {[address()], [address()]} | [address()]) -> 'ok'.
route_packet2(From, ToS, Dests, Packet, Addresses) ->
Els = case append_dests(Dests, Addresses) of
[] ->
[{subject, <<"">>},
{body, <<"">>}]}].
--spec opt_type(registration_timeout) -> fun((timeout()) -> timeout());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(registration_timeout) ->
fun (TO) when is_integer(TO), TO > 0 -> TO;
(infinity) -> infinity;
url(Url, Custom++Params)
end.
--spec opt_type(ext_api_http_pool_size) -> fun((pos_integer()) -> pos_integer());
- (ext_api_url) -> fun((binary()) -> binary());
- (atom()) -> [atom()].
+-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(ext_api_http_pool_size) ->
fun (X) when is_integer(X), X > 0 -> X end;
opt_type(ext_api_url) ->