From 7a1ca4b203f27ea8a1e96b4de699d9989e909668 Mon Sep 17 00:00:00 2001 From: Badlop Date: Wed, 24 Aug 2022 11:32:19 +0200 Subject: [PATCH] mod_host_meta: Complain at start if listener is not encrypted --- src/mod_host_meta.erl | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/mod_host_meta.erl b/src/mod_host_meta.erl index 77fc16058..abbca332a 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 %%%----------------------------------------------------------------------