summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2022-08-24 11:32:19 +0200
committerBadlop <badlop@process-one.net>2022-09-01 13:02:49 +0200
commit7a1ca4b203f27ea8a1e96b4de699d9989e909668 (patch)
treedd69c5fa7fbe92a8746ba01e5e828393a4516ffe
parentmod_pubsub: Don't crash on command failures (diff)
mod_host_meta: Complain at start if listener is not encrypted
-rw-r--r--src/mod_host_meta.erl21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/mod_host_meta.erl b/src/mod_host_meta.erl
index 77fc1605..abbca332 100644
--- a/src/mod_host_meta.erl
+++ b/src/mod_host_meta.erl
@@ -51,12 +51,14 @@
%%%----------------------------------------------------------------------
start(_Host, _Opts) ->
+ report_hostmeta_listener(),
ok.
stop(_Host) ->
ok.
reload(_Host, _NewOpts, _OldOpts) ->
+ report_hostmeta_listener(),
ok.
depends(_Host, _Opts) ->
@@ -66,7 +68,7 @@ depends(_Host, _Opts) ->
%%% HTTP handlers
%%%----------------------------------------------------------------------
-process([], #request{method = 'GET', tp = https, host = Host, path = Path}) ->
+process([], #request{method = 'GET', host = Host, path = Path}) ->
case lists:last(Path) of
<<"host-meta">> ->
file_xml(Host);
@@ -174,6 +176,23 @@ find_handler_port_path(Tls, Module) ->
(_) -> false
end, ets:tab2list(ejabberd_listener)).
+report_hostmeta_listener() ->
+ case {find_handler_port_path(false, ?MODULE),
+ find_handler_port_path(true, ?MODULE)} of
+ {[], []} ->
+ ?CRITICAL_MSG("It seems you enabled ~p in 'modules' but forgot to "
+ "add it as a request_handler in an ejabberd_http "
+ "listener.", [?MODULE]);
+ {[_|_], _} ->
+ ?WARNING_MSG("Apparently ~p is enabled in a request_handler in a "
+ "non-encrypted ejabberd_http listener. This is "
+ "disallowed by XEP-0156. Please enable 'tls' in that "
+ "listener, or setup a proxy encryption mechanism.",
+ [?MODULE]);
+ {[], [_|_]} ->
+ ok
+ end.
+
%%%----------------------------------------------------------------------
%%% Options and Doc
%%%----------------------------------------------------------------------