25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Remove unused validation code

This commit is contained in:
Evgeniy Khramtsov 2015-06-03 16:05:17 +03:00
parent ab196b4b02
commit c1119b1f39
12 changed files with 42 additions and 172 deletions

View File

@ -44,7 +44,7 @@
get_vh_registered_users_number/2, get_password/2,
get_password_s/2, is_user_exists/2, remove_user/2,
remove_user/3, store_type/0, plain_password_required/0,
mod_opt_type/1, opt_type/1]).
opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
@ -420,71 +420,6 @@ check_filter(F) ->
{ok, _} = eldap_filter:parse(NewF),
NewF.
mod_opt_type(deref_aliases) ->
fun (never) -> never;
(searching) -> searching;
(finding) -> finding;
(always) -> always
end;
mod_opt_type(ldap_backups) ->
fun (L) -> [iolist_to_binary(H) || H <- L] end;
mod_opt_type(ldap_base) -> fun iolist_to_binary/1;
mod_opt_type(ldap_deref_aliases) ->
fun (never) -> never;
(searching) -> searching;
(finding) -> finding;
(always) -> always
end;
mod_opt_type(ldap_encrypt) ->
fun (tls) -> tls;
(starttls) -> starttls;
(none) -> none
end;
mod_opt_type(ldap_password) -> fun iolist_to_binary/1;
mod_opt_type(ldap_port) ->
fun (I) when is_integer(I), I > 0 -> I end;
mod_opt_type(ldap_rootdn) -> fun iolist_to_binary/1;
mod_opt_type(ldap_servers) ->
fun (L) -> [iolist_to_binary(H) || H <- L] end;
mod_opt_type(ldap_tls_cacertfile) ->
fun iolist_to_binary/1;
mod_opt_type(ldap_tls_certfile) ->
fun iolist_to_binary/1;
mod_opt_type(ldap_tls_depth) ->
fun (I) when is_integer(I), I >= 0 -> I end;
mod_opt_type(ldap_tls_verify) ->
fun (hard) -> hard;
(soft) -> soft;
(false) -> false
end;
mod_opt_type(ldap_dn_filter) ->
fun ([{DNF, DNFA}]) ->
NewDNFA = case DNFA of
undefined -> [];
_ -> [iolist_to_binary(A) || A <- DNFA]
end,
NewDNF = check_filter(DNF),
{NewDNF, NewDNFA}
end;
mod_opt_type(ldap_filter) -> fun check_filter/1;
mod_opt_type(ldap_local_filter) -> fun (V) -> V end;
mod_opt_type(ldap_uids) ->
fun (Us) ->
lists:map(fun ({U, P}) ->
{iolist_to_binary(U), iolist_to_binary(P)};
({U}) -> {iolist_to_binary(U)};
(U) -> {iolist_to_binary(U)}
end,
lists:flatten(Us))
end;
mod_opt_type(_) ->
[ldap_dn_filter, ldap_filter, ldap_local_filter,
ldap_uids, deref_aliases, ldap_backups, ldap_base,
ldap_deref_aliases, ldap_encrypt, ldap_password,
ldap_port, ldap_rootdn, ldap_servers,
ldap_tls_cacertfile, ldap_tls_certfile, ldap_tls_depth,
ldap_tls_verify].
opt_type(ldap_dn_filter) ->
fun ([{DNF, DNFA}]) ->
NewDNFA = case DNFA of

View File

@ -34,7 +34,7 @@
socket_type/0, receive_headers/1, url_encode/1,
transform_listen_option/2]).
-export([init/2, mod_opt_type/1, opt_type/1]).
-export([init/2, opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
@ -872,14 +872,6 @@ transform_listen_option({request_handlers, Hs}, Opts) ->
transform_listen_option(Opt, Opts) ->
[Opt|Opts].
mod_opt_type(default_host) -> fun (A) -> A end;
mod_opt_type(request_handlers) ->
fun (Hs) ->
[{str:tokens(iolist_to_binary(Path), <<"/">>), Mod}
|| {Path, Mod} <- Hs]
end;
mod_opt_type(_) -> [default_host, request_handlers].
opt_type(trusted_proxies) ->
fun (TPs) -> [iolist_to_binary(TP) || TP <- TPs] end;
opt_type(_) -> [trusted_proxies].

View File

@ -30,7 +30,7 @@
-export([start/0, start_link/0, init/1, get_pids/0,
transform_options/1, get_random_pid/0, get_random_pid/1,
mod_opt_type/1, opt_type/1]).
opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
@ -155,9 +155,6 @@ transform_options({riak_server, {S, P}}, Opts) ->
transform_options(Opt, Opts) ->
[Opt|Opts].
mod_opt_type(db_type) -> fun gen_mod:v_db/1;
mod_opt_type(_) -> [db_type].
opt_type(modules) -> fun (L) when is_list(L) -> L end;
opt_type(riak_pool_size) ->
fun (N) when is_integer(N), N >= 1 -> N end;

View File

@ -42,8 +42,7 @@
-export([init/1, wait_for_stream/2,
wait_for_handshake/2, stream_established/2,
handle_event/3, handle_sync_event/4, code_change/4,
handle_info/3, terminate/3, print_state/1,
mod_opt_type/1, opt_type/1]).
handle_info/3, terminate/3, print_state/1, opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
@ -407,9 +406,6 @@ fsm_limit_opts(Opts) ->
end
end.
mod_opt_type(password) -> fun iolist_to_binary/1;
mod_opt_type(_) -> [password].
opt_type(max_fsm_queue) ->
fun (I) when is_integer(I), I > 0 -> I end;
opt_type(_) -> [max_fsm_queue].

View File

@ -28,7 +28,7 @@
-protocol({rfc, 5766}).
-export([tcp_init/2, udp_init/2, udp_recv/5, start/2,
socket_type/0, mod_opt_type/1]).
socket_type/0]).
-include("ejabberd.hrl").
-include("logger.hrl").
@ -100,12 +100,3 @@ prepare_turn_opts(Opts, _UseTurn = true) ->
MaxRate = shaper:get_max_rate(Shaper),
Realm ++ [{auth_fun, AuthFun},{shaper, MaxRate} |
lists:keydelete(shaper, 1, Opts)].
mod_opt_type(auth_realm) -> fun iolist_to_binary/1;
mod_opt_type(auth_type) ->
fun (anonymous) -> anonymous;
(user) -> user
end;
mod_opt_type(shaper) ->
fun (S) when is_atom(S) -> S end;
mod_opt_type(_) -> [auth_realm, auth_type, shaper].

View File

@ -36,7 +36,7 @@
-author('badlop@process-one.net').
-export([start/2, handler/2, process/2, socket_type/0,
transform_listen_option/2, mod_opt_type/1]).
transform_listen_option/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
@ -541,14 +541,3 @@ transform_listen_option({access_commands, ACOpts}, Opts) ->
[{access_commands, NewACOpts}|Opts];
transform_listen_option(Opt, Opts) ->
[Opt|Opts].
mod_opt_type(access_commands) ->
fun (L) when is_list(L) -> L end;
mod_opt_type(commands) ->
fun (A) when is_atom(A) -> A;
(L) when is_list(L) ->
true = lists:all(fun is_atom/1, L), L
end;
mod_opt_type(options) ->
fun (L) when is_list(L) -> L end;
mod_opt_type(_) -> [access_commands, commands, options].

View File

@ -30,7 +30,7 @@
-include("logger.hrl").
-export([export/2, export/3, import_file/2, import/2,
import/3, mod_opt_type/1]).
import/3]).
-define(MAX_RECORDS_PER_TRANSACTION, 100).
@ -280,6 +280,3 @@ flatten1([H|T], Acc) ->
flatten1(T, [[H, $\n]|Acc]);
flatten1([], Acc) ->
Acc.
mod_opt_type(db_type) -> fun gen_mod:v_db/1;
mod_opt_type(_) -> [db_type].

View File

@ -83,7 +83,7 @@
-export([init/1, connecting/2, connecting/3,
wait_bind_response/3, active/3, active_bind/3,
handle_event/3, handle_sync_event/4, handle_info/3,
terminate/3, code_change/4, mod_opt_type/1]).
terminate/3, code_change/4]).
-export_type([filter/0]).
@ -1193,24 +1193,3 @@ bump_id(#eldap{id = Id})
when Id > (?MAX_TRANSACTION_ID) ->
?MIN_TRANSACTION_ID;
bump_id(#eldap{id = Id}) -> Id + 1.
mod_opt_type(encrypt) ->
fun (tls) -> tls;
(starttls) -> starttls;
(none) -> none
end;
mod_opt_type(tls_cacertfile) ->
fun (S) when is_binary(S) -> binary_to_list(S);
(undefined) -> undefined
end;
mod_opt_type(tls_depth) ->
fun (I) when is_integer(I), I >= 0 -> I;
(undefined) -> undefined
end;
mod_opt_type(tls_verify) ->
fun (hard) -> hard;
(soft) -> soft;
(false) -> false
end;
mod_opt_type(_) ->
[encrypt, tls_cacertfile, tls_depth, tls_verify].

View File

@ -84,4 +84,34 @@ init([Host, Opts]) ->
{{one_for_one, 10, 1},
[StreamManager, StreamSupervisor, Service]}}.
mod_opt_type(_) -> [].
mod_opt_type(auth_type) ->
fun (plain) -> plain;
(anonymous) -> anonymous
end;
mod_opt_type(recbuf) ->
fun (I) when is_integer(I), I > 0 -> I end;
mod_opt_type(shaper) ->
fun (A) when is_atom(A) -> A end;
mod_opt_type(sndbuf) ->
fun (I) when is_integer(I), I > 0 -> I end;
mod_opt_type(access) ->
fun (A) when is_atom(A) -> A end;
mod_opt_type(host) -> fun iolist_to_binary/1;
mod_opt_type(hostname) -> fun iolist_to_binary/1;
mod_opt_type(ip) ->
fun (S) ->
{ok, Addr} =
inet_parse:address(binary_to_list(iolist_to_binary(S))),
Addr
end;
mod_opt_type(name) -> fun iolist_to_binary/1;
mod_opt_type(port) ->
fun (P) when is_integer(P), P > 0, P < 65536 -> P end;
mod_opt_type(max_connections) ->
fun (I) when is_integer(I), I > 0 -> I;
(infinity) -> infinity
end;
mod_opt_type(_) ->
[auth_type, recbuf, shaper, sndbuf,
access, host, hostname, ip, name, port,
max_connections].

View File

@ -34,8 +34,7 @@
handle_cast/2, terminate/2, code_change/3]).
-export([start_link/2, add_listener/2,
transform_module_options/1, delete_listener/1,
mod_opt_type/1]).
transform_module_options/1, delete_listener/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
@ -292,19 +291,3 @@ get_my_ip() ->
{ok, Addr} -> Addr;
{error, _} -> {127, 0, 0, 1}
end.
mod_opt_type(access) ->
fun (A) when is_atom(A) -> A end;
mod_opt_type(host) -> fun iolist_to_binary/1;
mod_opt_type(hostname) -> fun iolist_to_binary/1;
mod_opt_type(ip) ->
fun (S) ->
{ok, Addr} =
inet_parse:address(binary_to_list(iolist_to_binary(S))),
Addr
end;
mod_opt_type(name) -> fun iolist_to_binary/1;
mod_opt_type(port) ->
fun (P) when is_integer(P), P > 0, P < 65536 -> P end;
mod_opt_type(_) ->
[access, host, hostname, ip, name, port].

View File

@ -34,8 +34,7 @@
handle_cast/2, terminate/2, code_change/3]).
-export([start_link/2, register_stream/1,
unregister_stream/1, activate_stream/4,
mod_opt_type/1]).
unregister_stream/1, activate_stream/4]).
-record(state, {max_connections = infinity :: non_neg_integer() | infinity}).
@ -171,9 +170,3 @@ activate_stream(SHA1, IJid, TJid, Host)
{atomic, false} -> false;
_ -> error
end.
mod_opt_type(max_connections) ->
fun (I) when is_integer(I), I > 0 -> I;
(infinity) -> infinity
end;
mod_opt_type(_) -> [max_connections].

View File

@ -38,7 +38,7 @@
stream_established/2]).
-export([start/2, stop/1, start_link/3, activate/2,
relay/3, socket_type/0, mod_opt_type/1]).
relay/3, socket_type/0]).
-include("mod_proxy65.hrl").
@ -288,15 +288,3 @@ find_maxrate(Shaper, JID1, JID2, Host) ->
if MaxRate1 == none; MaxRate2 == none -> none;
true -> lists:max([MaxRate1, MaxRate2])
end.
mod_opt_type(auth_type) ->
fun (plain) -> plain;
(anonymous) -> anonymous
end;
mod_opt_type(recbuf) ->
fun (I) when is_integer(I), I > 0 -> I end;
mod_opt_type(shaper) ->
fun (A) when is_atom(A) -> A end;
mod_opt_type(sndbuf) ->
fun (I) when is_integer(I), I > 0 -> I end;
mod_opt_type(_) -> [auth_type, recbuf, shaper, sndbuf].