25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

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
This commit is contained in:
Evgeny Khramtsov 2019-04-30 11:14:14 +03:00
parent 268750e3b7
commit c7d04a82a2
2 changed files with 37 additions and 9 deletions

View File

@ -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: "::"

View File

@ -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) ->