Fix ejabberd_captcha's listener parsing

If the "captcha_host" is specified without "http://" or "https://"
prefix, ejabberd_captcha tries to figure out the protocol automatically.
Fix the code that parses the listener configuration in order to do that.
This commit is contained in:
Holger Weiss 2014-12-24 00:35:22 +01:00
parent cc958f7787
commit 9dc9d75502
1 changed files with 9 additions and 9 deletions

View File

@ -549,10 +549,11 @@ get_transfer_protocol(PortString) ->
get_port_listeners(PortNumber) -> get_port_listeners(PortNumber) ->
AllListeners = ejabberd_config:get_option(listen, fun(V) -> V end), AllListeners = ejabberd_config:get_option(listen, fun(V) -> V end),
lists:filter(fun ({{Port, _Ip, _Netp}, _Module1, lists:filter(fun (Listener) when is_list(Listener) ->
_Opts1}) case proplists:get_value(port, Listener) of
when Port == PortNumber -> PortNumber -> true;
true; _ -> false
end;
(_) -> false (_) -> false
end, end,
AllListeners). AllListeners).
@ -562,12 +563,11 @@ get_captcha_transfer_protocol([]) ->
"is not a ejabberd_http listener with " "is not a ejabberd_http listener with "
"'captcha' option. Change the port number " "'captcha' option. Change the port number "
"or specify http:// in that option.">>); "or specify http:// in that option.">>);
get_captcha_transfer_protocol([{{_Port, _Ip, tcp}, get_captcha_transfer_protocol([Listener | Listeners]) when is_list(Listener) ->
ejabberd_http, Opts} case proplists:get_value(module, Listener) == ejabberd_http andalso
| Listeners]) -> proplists:get_bool(captcha, Listener) of
case lists:member(captcha, Opts) of
true -> true ->
case lists:member(tls, Opts) of case proplists:get_bool(tls, Listener) of
true -> https; true -> https;
false -> http false -> http
end; end;