diff options
author | Badlop <badlop@process-one.net> | 2011-03-03 11:35:47 +0100 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2011-03-03 11:38:00 +0100 |
commit | a1f20a5bc0729095feef96b3d021df169392e580 (patch) | |
tree | 43224bc923a7a08583f72f8d2f02c067e4cc0d8a /src | |
parent | captcha_host must have the port number to get protocol (EJAB-1418) (diff) |
If the port number isn't listener, then specify the protocol (EJAB-1418)
Diffstat (limited to 'src')
-rw-r--r-- | src/ejabberd_captcha.erl | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/ejabberd_captcha.erl b/src/ejabberd_captcha.erl index 0f3aee76..797a6152 100644 --- a/src/ejabberd_captcha.erl +++ b/src/ejabberd_captcha.erl @@ -406,23 +406,21 @@ get_prog_name() -> get_url(Str) -> CaptchaHost = ejabberd_config:get_local_option(captcha_host), - case CaptchaHost of - Host when is_list(Host) -> - TransferProt = atom_to_list(get_transfer_protocol(CaptchaHost)), - TransferProt ++ "://" ++ Host ++ "/captcha/" ++ Str; + case string:tokens(CaptchaHost, ":") of + [TransferProt, Host, PortString] -> + TransferProt ++ ":" ++ Host ++ ":" ++ PortString ++ "/captcha/" ++ Str; + [Host, PortString] -> + TransferProt = atom_to_list(get_transfer_protocol(PortString)), + TransferProt ++ "://" ++ Host ++ ":" ++ PortString ++ "/captcha/" ++ Str; _ -> "http://" ++ ?MYNAME ++ ":5280/captcha/" ++ Str end. -get_transfer_protocol(CaptchaHost) -> - PortNumber = get_port_number_from_captcha_host_option(CaptchaHost), +get_transfer_protocol(PortString) -> + PortNumber = list_to_integer(PortString), PortListeners = get_port_listeners(PortNumber), 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) -> AllListeners = ejabberd_config:get_local_option(listen), lists:filter( @@ -435,7 +433,8 @@ get_port_listeners(PortNumber) -> get_captcha_transfer_protocol([]) -> 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} | Listeners]) -> case lists:member(captcha, Opts) of |