]> granicus.if.org Git - ejabberd/commitdiff
Remove unused validation code
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Wed, 3 Jun 2015 13:05:17 +0000 (16:05 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Wed, 3 Jun 2015 13:05:17 +0000 (16:05 +0300)
12 files changed:
src/ejabberd_auth_ldap.erl
src/ejabberd_http.erl
src/ejabberd_riak_sup.erl
src/ejabberd_service.erl
src/ejabberd_stun.erl
src/ejabberd_xmlrpc.erl
src/ejd2odbc.erl
src/eldap.erl
src/mod_proxy65.erl
src/mod_proxy65_service.erl
src/mod_proxy65_sm.erl
src/mod_proxy65_stream.erl

index f2122805aeaabdb62105e16c4776fd3d7c01ecdc..4fdb87b2079b5f62f073b54d9427f56f64e4f5eb 100644 (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
index b4de38c02ee0450e497dcb457a4696a21839026d..5f98063bbd6baa7a655cb9e263a91ffa6c09911d 100644 (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].
index 8b6a8064ddb6725878febf1a662aef21498af579..a971a4a3276bd84b83620310ab93c349d2b3e90f 100644 (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;
index 3e283a0a211a8f8120d1b345d5f00b50eefdf219..febede8d97e3f4f50287f5a95dd74b80cf33d441 100644 (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].
index 3d5ab6bd71caddaf8a29199605c33f13b2f721b1..a69b731c5f2c788bee6e0cf990bea43c85294e1a 100644 (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].
index 0a74fd47b69c4b2b8ac65e7a006cac137e514631..c852114506d91e1ec24db69500f0cd113775d4ea 100644 (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].
index 81c4b0fded4b65f60109ccdf07224cc157d514c1..8e83fb5b0b38e0abc4b595a16dbcb17143f8d8cd 100644 (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].
index f8f6d04a99e8198411f722369ae540c965878174..20a5b6139b3e817e5d22e1c14caaf12eb550cd6b 100644 (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].
index 621189db216e021b8d47221c019879991d269b32..8d58c891868f0914113b21778327ecaee0b26485 100644 (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].
index 32cd4443d49e3f99fb5e71a065810a667197d4d2..3c360942a4a7414c813e3141d72b05f316a5ae0d 100644 (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].
index 895dd7d57dd6020a8ae9ae5933e915163bf064be..ce997154e9168dcfb63aef8eacfc13c63d3e19e5 100644 (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].
index 972faa76b608f9c2560ee2b5b8af4c45428afa07..722a782c56b7777c801c0ce06bccee91156e3f94 100644 (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].