aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2015-06-03 16:05:17 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2015-06-03 16:05:17 +0300
commitc1119b1f3945a37f656934ef530f8c7bf158530f (patch)
tree0097cc1e23dbf9e02aa06e9d5592b3bbe80b5b6d /src
parentMove opt_type/1 function out of if-else block (diff)
Remove unused validation code
Diffstat (limited to '')
-rw-r--r--src/ejabberd_auth_ldap.erl67
-rw-r--r--src/ejabberd_http.erl10
-rw-r--r--src/ejabberd_riak_sup.erl5
-rw-r--r--src/ejabberd_service.erl6
-rw-r--r--src/ejabberd_stun.erl11
-rw-r--r--src/ejabberd_xmlrpc.erl13
-rw-r--r--src/ejd2odbc.erl5
-rw-r--r--src/eldap.erl23
-rw-r--r--src/mod_proxy65.erl32
-rw-r--r--src/mod_proxy65_service.erl19
-rw-r--r--src/mod_proxy65_sm.erl9
-rw-r--r--src/mod_proxy65_stream.erl14
12 files changed, 42 insertions, 172 deletions
diff --git a/src/ejabberd_auth_ldap.erl b/src/ejabberd_auth_ldap.erl
index f2122805a..4fdb87b20 100644
--- a/src/ejabberd_auth_ldap.erl
+++ b/src/ejabberd_auth_ldap.erl
@@ -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
diff --git a/src/ejabberd_http.erl b/src/ejabberd_http.erl
index b4de38c02..5f98063bb 100644
--- a/src/ejabberd_http.erl
+++ b/src/ejabberd_http.erl
@@ -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].
diff --git a/src/ejabberd_riak_sup.erl b/src/ejabberd_riak_sup.erl
index 8b6a8064d..a971a4a32 100644
--- a/src/ejabberd_riak_sup.erl
+++ b/src/ejabberd_riak_sup.erl
@@ -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;
diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl
index 3e283a0a2..febede8d9 100644
--- a/src/ejabberd_service.erl
+++ b/src/ejabberd_service.erl
@@ -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].
diff --git a/src/ejabberd_stun.erl b/src/ejabberd_stun.erl
index 3d5ab6bd7..a69b731c5 100644
--- a/src/ejabberd_stun.erl
+++ b/src/ejabberd_stun.erl
@@ -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].
diff --git a/src/ejabberd_xmlrpc.erl b/src/ejabberd_xmlrpc.erl
index 0a74fd47b..c85211450 100644
--- a/src/ejabberd_xmlrpc.erl
+++ b/src/ejabberd_xmlrpc.erl
@@ -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].
diff --git a/src/ejd2odbc.erl b/src/ejd2odbc.erl
index 81c4b0fde..8e83fb5b0 100644
--- a/src/ejd2odbc.erl
+++ b/src/ejd2odbc.erl
@@ -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].
diff --git a/src/eldap.erl b/src/eldap.erl
index f8f6d04a9..20a5b6139 100644
--- a/src/eldap.erl
+++ b/src/eldap.erl
@@ -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].
diff --git a/src/mod_proxy65.erl b/src/mod_proxy65.erl
index 621189db2..8d58c8918 100644
--- a/src/mod_proxy65.erl
+++ b/src/mod_proxy65.erl
@@ -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].
diff --git a/src/mod_proxy65_service.erl b/src/mod_proxy65_service.erl
index 32cd4443d..3c360942a 100644
--- a/src/mod_proxy65_service.erl
+++ b/src/mod_proxy65_service.erl
@@ -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].
diff --git a/src/mod_proxy65_sm.erl b/src/mod_proxy65_sm.erl
index 895dd7d57..ce997154e 100644
--- a/src/mod_proxy65_sm.erl
+++ b/src/mod_proxy65_sm.erl
@@ -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].
diff --git a/src/mod_proxy65_stream.erl b/src/mod_proxy65_stream.erl
index 972faa76b..722a782c5 100644
--- a/src/mod_proxy65_stream.erl
+++ b/src/mod_proxy65_stream.erl
@@ -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].