diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-05-08 14:34:35 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-05-08 14:34:35 +0300 |
commit | 8368a0850ab077dc9317dc3b3046a0c28c16748d (patch) | |
tree | 2eb58cda4e722bc4cb64bb2d8acdd4ca5ba3b6b4 /src/eldap_utils.erl | |
parent | Add type specs for Module:opt_type/1 (diff) |
Don't call gen_mod:get_opt() outside of modules
Diffstat (limited to 'src/eldap_utils.erl')
-rw-r--r-- | src/eldap_utils.erl | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/src/eldap_utils.erl b/src/eldap_utils.erl index 52671061d..3704d2ce5 100644 --- a/src/eldap_utils.erl +++ b/src/eldap_utils.erl @@ -173,25 +173,25 @@ uids_domain_subst(Host, UIDs) -> -spec get_config(binary(), list()) -> eldap_config(). get_config(Host, Opts) -> - Servers = gen_mod:get_opt({ldap_servers, Host}, Opts, [<<"localhost">>]), - Backups = gen_mod:get_opt({ldap_backups, Host}, Opts, []), - Encrypt = gen_mod:get_opt({ldap_encrypt, Host}, Opts, none), - TLSVerify = gen_mod:get_opt({ldap_tls_verify, Host}, Opts, false), - TLSCAFile = gen_mod:get_opt({ldap_tls_cacertfile, Host}, Opts), - TLSDepth = gen_mod:get_opt({ldap_tls_depth, Host}, Opts), - Port = gen_mod:get_opt({ldap_port, Host}, Opts, - case Encrypt of - tls -> ?LDAPS_PORT; - starttls -> ?LDAP_PORT; - _ -> ?LDAP_PORT - end), - RootDN = gen_mod:get_opt({ldap_rootdn, Host}, Opts, <<"">>), - Password = gen_mod:get_opt({ldap_password, Host}, Opts, <<"">>), - Base = gen_mod:get_opt({ldap_base, Host}, Opts, <<"">>), - OldDerefAliases = gen_mod:get_opt({deref_aliases, Host}, Opts, unspecified), + Servers = get_opt(ldap_servers, Host, Opts, [<<"localhost">>]), + Backups = get_opt(ldap_backups, Host, Opts, []), + Encrypt = get_opt(ldap_encrypt, Host, Opts, none), + TLSVerify = get_opt(ldap_tls_verify, Host, Opts, false), + TLSCAFile = get_opt(ldap_tls_cacertfile, Host, Opts), + TLSDepth = get_opt(ldap_tls_depth, Host, Opts), + Port = get_opt(ldap_port, Host, Opts, + case Encrypt of + tls -> ?LDAPS_PORT; + starttls -> ?LDAP_PORT; + _ -> ?LDAP_PORT + end), + RootDN = get_opt(ldap_rootdn, Host, Opts, <<"">>), + Password = get_opt(ldap_password, Host, Opts, <<"">>), + Base = get_opt(ldap_base, Host, Opts, <<"">>), + OldDerefAliases = get_opt(deref_aliases, Host, Opts, unspecified), DerefAliases = if OldDerefAliases == unspecified -> - gen_mod:get_opt({ldap_deref_aliases, Host}, Opts, never); + get_opt(ldap_deref_aliases, Host, Opts, never); true -> ?WARNING_MSG("Option 'deref_aliases' is deprecated. " "The option is still supported " @@ -211,6 +211,15 @@ get_config(Host, Opts) -> base = Base, deref_aliases = DerefAliases}. +get_opt(Opt, Host, Opts) -> + get_opt(Opt, Host, Opts, undefined). + +get_opt(Opt, Host, Opts, Default) -> + case proplists:get_value(Opt, Opts) of + undefined -> ejabberd_config:get_option({Opt, Host}, Default); + Value -> Value + end. + %%---------------------------------------- %% Borrowed from asn1rt_ber_bin_v2.erl %%---------------------------------------- |