summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Khramtsov <ekhramtsov@process-one.net>2019-07-15 09:59:07 +0300
committerEvgeny Khramtsov <ekhramtsov@process-one.net>2019-07-15 09:59:07 +0300
commit1fe1322bc12552dd6125e4bf96b412fea32607a6 (patch)
tree246af329b357485de880ac60e807f1569434492a
parentmod_http_fileserver: Unregister 'reopen_log_hook' (diff)
Improve some validators
-rw-r--r--src/ejabberd_http.erl27
-rw-r--r--src/mod_sip.erl2
-rw-r--r--src/mod_sip_opt.erl2
3 files changed, 13 insertions, 18 deletions
diff --git a/src/ejabberd_http.erl b/src/ejabberd_http.erl
index 368a5227..12ee51d6 100644
--- a/src/ejabberd_http.erl
+++ b/src/ejabberd_http.erl
@@ -774,12 +774,6 @@ rest_dir(0, Path, <<H, T/binary>>) ->
rest_dir(0, <<H, Path/binary>>, T);
rest_dir(N, Path, <<_H, T/binary>>) -> rest_dir(N, Path, T).
-expand_custom_headers(Headers) ->
- lists:map(fun({K, V}) ->
- {K, misc:expand_keyword(<<"@VERSION@">>, V,
- ejabberd_option:version())}
- end, Headers).
-
code_to_phrase(100) -> <<"Continue">>;
code_to_phrase(101) -> <<"Switching Protocols ">>;
code_to_phrase(200) -> <<"OK">>;
@@ -904,21 +898,22 @@ normalize_path([Part | Path], Norm) ->
listen_opt_type(tag) ->
econf:binary();
listen_opt_type(request_handlers) ->
- econf:and_then(
- econf:map(
+ econf:map(
+ econf:and_then(
econf:binary(),
- econf:beam([[{socket_handoff, 3}, {process, 2}]])),
- fun(L) ->
- [{str:tokens(Path, <<"/">>), Mod} || {Path, Mod} <- L]
- end);
+ fun(Path) -> str:tokens(Path, <<"/">>) end),
+ econf:beam([[{socket_handoff, 3}, {process, 2}]]));
listen_opt_type(default_host) ->
econf:domain();
listen_opt_type(custom_headers) ->
- econf:and_then(
- econf:map(
+ econf:map(
+ econf:binary(),
+ econf:and_then(
econf:binary(),
- econf:binary()),
- fun expand_custom_headers/1).
+ fun(V) ->
+ misc:expand_keyword(<<"@VERSION@">>, V,
+ ejabberd_option:version())
+ end)).
listen_options() ->
[{ciphers, undefined},
diff --git a/src/mod_sip.erl b/src/mod_sip.erl
index 54d8ac25..a939b17b 100644
--- a/src/mod_sip.erl
+++ b/src/mod_sip.erl
@@ -349,7 +349,7 @@ mod_opt_type(via) ->
{Type, {Host, Port}}
end)).
--spec mod_options(binary()) -> [{via, [{tcp | tls | udp, {binary(), 1..65535}}]} |
+-spec mod_options(binary()) -> [{via, [{tcp | tls | udp, {binary(), 1..65535 | undefined}}]} |
{atom(), term()}].
mod_options(Host) ->
Route = #uri{scheme = <<"sip">>,
diff --git a/src/mod_sip_opt.erl b/src/mod_sip_opt.erl
index e160d2e1..500e6a94 100644
--- a/src/mod_sip_opt.erl
+++ b/src/mod_sip_opt.erl
@@ -40,7 +40,7 @@ routes(Opts) when is_map(Opts) ->
routes(Host) ->
gen_mod:get_module_opt(Host, mod_sip, routes).
--spec via(gen_mod:opts() | global | binary()) -> [{'tcp' | 'tls' | 'udp',{binary(),1..65535}}].
+-spec via(gen_mod:opts() | global | binary()) -> [{'tcp' | 'tls' | 'udp',{binary(),1..65535 | 'undefined'}}].
via(Opts) when is_map(Opts) ->
gen_mod:get_opt(via, Opts);
via(Host) ->