From c7d04a82a25c4c47fbee0caf8c7917d5a2dcc91c Mon Sep 17 00:00:00 2001 From: Evgeny Khramtsov Date: Tue, 30 Apr 2019 11:14:14 +0300 Subject: [PATCH] Deprecate some listening options Those are: captcha, register, web_admin, http_bind and xmlrpc The option `request_handlers` should be used instead, e.g.: listen: ... - module: ejabberd_http request_handlers: "/admin": ejabberd_web_admin "/bosh": mod_bosh "/captcha": ejabberd_captcha "/register": mod_register_web "/": ejabberd_xmlrpc --- ejabberd.yml.example | 9 +++++---- src/ejabberd_http.erl | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/ejabberd.yml.example b/ejabberd.yml.example index 52a9c9f66..e62dd8bc2 100644 --- a/ejabberd.yml.example +++ b/ejabberd.yml.example @@ -57,19 +57,20 @@ listen: port: 5443 ip: "::" module: ejabberd_http + tls: true request_handlers: + "/admin": ejabberd_web_admin "/api": mod_http_api "/bosh": mod_bosh + "/captcha": ejabberd_captcha "/upload": mod_http_upload "/ws": ejabberd_http_ws - web_admin: true - captcha: true - tls: true - port: 5280 ip: "::" module: ejabberd_http - web_admin: true + request_handlers: + "/admin": ejabberd_web_admin - port: 1883 ip: "::" diff --git a/src/ejabberd_http.erl b/src/ejabberd_http.erl index d9e13132e..29d23e082 100644 --- a/src/ejabberd_http.erl +++ b/src/ejabberd_http.erl @@ -983,6 +983,18 @@ prepare_request_module(Mod) when is_atom(Mod) -> erlang:error(Err) end. +emit_option_replacement(Option, Path, Handler) -> + ?WARNING_MSG( + "Listening option '~s' is deprecated, enable it via request handlers, e.g.:~n" + "listen:~n" + " ...~n" + " -~n" + " module: ~s~n" + " request_handlers:~n" + " ...~n" + " \"~s\": ~s~n", + [Option, ?MODULE, Path, Handler]). + -spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(trusted_proxies) -> fun (all) -> all; @@ -1004,15 +1016,30 @@ listen_opt_type(certfile = Opt) -> File end; listen_opt_type(captcha) -> - fun(B) when is_boolean(B) -> B end; + fun(B) when is_boolean(B) -> + emit_option_replacement(captcha, "/captcha", ejabberd_captcha), + B + end; listen_opt_type(register) -> - fun(B) when is_boolean(B) -> B end; + fun(B) when is_boolean(B) -> + emit_option_replacement(register, "/register", mod_register_web), + B + end; listen_opt_type(web_admin) -> - fun(B) when is_boolean(B) -> B end; + fun(B) when is_boolean(B) -> + emit_option_replacement(web_admin, "/admin", ejabberd_web_admin), + B + end; listen_opt_type(http_bind) -> - fun(B) when is_boolean(B) -> B end; + fun(B) when is_boolean(B) -> + emit_option_replacement(http_bind, "/bosh", mod_bosh), + B + end; listen_opt_type(xmlrpc) -> - fun(B) when is_boolean(B) -> B end; + fun(B) when is_boolean(B) -> + emit_option_replacement(xmlrpc, "/", ejabberd_xmlrpc), + B + end; listen_opt_type(tag) -> fun(B) when is_binary(B) -> B end; listen_opt_type(request_handlers) ->