mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +01:00
If the port number isn't listener, then specify the protocol (EJAB-1418)
This commit is contained in:
parent
6cc950d76f
commit
4caf2c8674
@ -1709,11 +1709,14 @@ The configurable options are:
|
|||||||
\titem{\{captcha\_cmd, Path\}}
|
\titem{\{captcha\_cmd, Path\}}
|
||||||
Full path to a script that generates the image.
|
Full path to a script that generates the image.
|
||||||
The default value is an empty string: \term{""}
|
The default value is an empty string: \term{""}
|
||||||
\titem{\{captcha\_host, HostPort\}}
|
\titem{\{captcha\_host, ProtocolHostPort\}}
|
||||||
Host part of the URL sent to the user,
|
Host part of the URL sent to the user,
|
||||||
and the port number where ejabberd listens for CAPTCHA requests.
|
and the port number where ejabberd listens for CAPTCHA requests.
|
||||||
The URL sent to the user is formed by: \term{http://Host:Port/captcha/}
|
The URL sent to the user is formed by: \term{http://Host:Port/captcha/}
|
||||||
The default value is: the first hostname configured, and port 5280.
|
The default value is: the first hostname configured, and port 5280.
|
||||||
|
If the port number you specify does not match exactly an ejabberd listener
|
||||||
|
(because you are using a reverse proxy or other port-forwarding tool),
|
||||||
|
then specify also the transfer protocol, as seen in the example below.
|
||||||
\end{description}
|
\end{description}
|
||||||
|
|
||||||
Additionally, an \term{ejabberd\_http} listener must be enabled with the \term{captcha} option.
|
Additionally, an \term{ejabberd\_http} listener must be enabled with the \term{captcha} option.
|
||||||
@ -1725,6 +1728,7 @@ Example configuration:
|
|||||||
|
|
||||||
{captcha_cmd, "/lib/ejabberd/priv/bin/captcha.sh"}.
|
{captcha_cmd, "/lib/ejabberd/priv/bin/captcha.sh"}.
|
||||||
{captcha_host, "example.org:5280"}.
|
{captcha_host, "example.org:5280"}.
|
||||||
|
%% {captcha_host, "https://example.org:443"}.
|
||||||
|
|
||||||
{listen,
|
{listen,
|
||||||
[
|
[
|
||||||
|
@ -626,23 +626,21 @@ get_prog_name() ->
|
|||||||
%% @doc (Str::string()) -> string()
|
%% @doc (Str::string()) -> string()
|
||||||
get_url(Str) ->
|
get_url(Str) ->
|
||||||
CaptchaHost = ejabberd_config:get_local_option(captcha_host),
|
CaptchaHost = ejabberd_config:get_local_option(captcha_host),
|
||||||
case CaptchaHost of
|
case string:tokens(CaptchaHost, ":") of
|
||||||
Host when is_list(Host) ->
|
[TransferProt, Host, PortString] ->
|
||||||
TransferProt = atom_to_list(get_transfer_protocol(CaptchaHost)),
|
TransferProt ++ ":" ++ Host ++ ":" ++ PortString ++ "/captcha/" ++ Str;
|
||||||
TransferProt ++ "://" ++ Host ++ "/captcha/" ++ Str;
|
[Host, PortString] ->
|
||||||
|
TransferProt = atom_to_list(get_transfer_protocol(PortString)),
|
||||||
|
TransferProt ++ "://" ++ Host ++ ":" ++ PortString ++ "/captcha/" ++ Str;
|
||||||
_ ->
|
_ ->
|
||||||
"http://" ++ ?MYNAME ++ ":5280/captcha/" ++ Str
|
"http://" ++ ?MYNAME ++ ":5280/captcha/" ++ Str
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_transfer_protocol(CaptchaHost) ->
|
get_transfer_protocol(PortString) ->
|
||||||
PortNumber = get_port_number_from_captcha_host_option(CaptchaHost),
|
PortNumber = list_to_integer(PortString),
|
||||||
PortListeners = get_port_listeners(PortNumber),
|
PortListeners = get_port_listeners(PortNumber),
|
||||||
get_captcha_transfer_protocol(PortListeners).
|
get_captcha_transfer_protocol(PortListeners).
|
||||||
|
|
||||||
get_port_number_from_captcha_host_option(CaptchaHost) ->
|
|
||||||
[_Host, PortString] = string:tokens(CaptchaHost, ":"),
|
|
||||||
list_to_integer(PortString).
|
|
||||||
|
|
||||||
get_port_listeners(PortNumber) ->
|
get_port_listeners(PortNumber) ->
|
||||||
AllListeners = ejabberd_config:get_local_option(listen),
|
AllListeners = ejabberd_config:get_local_option(listen),
|
||||||
lists:filter(
|
lists:filter(
|
||||||
@ -655,7 +653,8 @@ get_port_listeners(PortNumber) ->
|
|||||||
|
|
||||||
get_captcha_transfer_protocol([]) ->
|
get_captcha_transfer_protocol([]) ->
|
||||||
throw("The port number mentioned in captcha_host is not "
|
throw("The port number mentioned in captcha_host is not "
|
||||||
"a ejabberd_http listener with 'captcha' option.");
|
"a ejabberd_http listener with 'captcha' option. "
|
||||||
|
"Change the port number or specify http:// in that option.");
|
||||||
get_captcha_transfer_protocol([{{_Port, _Ip, tcp}, ejabberd_http, Opts}
|
get_captcha_transfer_protocol([{{_Port, _Ip, tcp}, ejabberd_http, Opts}
|
||||||
| Listeners]) ->
|
| Listeners]) ->
|
||||||
case lists:member(captcha, Opts) of
|
case lists:member(captcha, Opts) of
|
||||||
|
Loading…
Reference in New Issue
Block a user