-spec get_url(binary()) -> binary().
get_url(Str) ->
+ case ejabberd_option:captcha_url() of
+ undefined ->
+ URL = parse_captcha_host(),
+ <<URL/binary, "/captcha/", Str/binary>>;
+ URL ->
+ <<URL/binary, $/, Str/binary>>
+ end.
+
+-spec parse_captcha_host() -> binary().
+parse_captcha_host() ->
CaptchaHost = ejabberd_option:captcha_host(),
case str:tokens(CaptchaHost, <<":">>) of
- [Host] ->
- <<"http://", Host/binary, "/captcha/", Str/binary>>;
- [<<"http", _/binary>> = TransferProt, Host] ->
- <<TransferProt/binary, ":", Host/binary, "/captcha/",
- Str/binary>>;
- [Host, PortString] ->
- TransferProt =
- iolist_to_binary(atom_to_list(get_transfer_protocol(PortString))),
- <<TransferProt/binary, "://", Host/binary, ":",
- PortString/binary, "/captcha/", Str/binary>>;
- [TransferProt, Host, PortString] ->
- <<TransferProt/binary, ":", Host/binary, ":",
- PortString/binary, "/captcha/", Str/binary>>;
+ [Host] ->
+ <<"http://", Host/binary>>;
+ [<<"http", _/binary>> = TransferProt, Host] ->
+ <<TransferProt/binary, ":", Host/binary>>;
+ [Host, PortString] ->
+ TransferProt = atom_to_binary(get_transfer_protocol(PortString), latin1),
+ <<TransferProt/binary, "://", Host/binary, ":", PortString/binary>>;
+ [TransferProt, Host, PortString] ->
+ <<TransferProt/binary, ":", Host/binary, ":", PortString/binary>>;
_ ->
- <<"http://", (ejabberd_config:get_myname())/binary, "/captcha/", Str/binary>>
+ <<"http://", (ejabberd_config:get_myname())/binary>>
end.
get_transfer_protocol(PortString) ->
Opt == s2s_dns_timeout ->
warn_huge_timeout(Opt, Val),
true;
+filter(_Host, captcha_host, _, _) ->
+ warn_deprecated_option(captcha_host, captcha_url),
+ true;
filter(Host, modules, ModOpts, State) ->
NoDialbackHosts = maps:get(remove_s2s_dialback, State, []),
ModOpts1 = lists:filter(
"HTTP request handler: \"~s\" -> ~s. ~s",
[Opt, Path, Module, adjust_hint()]).
+warn_deprecated_option(OldOpt, NewOpt) ->
+ ?WARNING_MSG("Option '~s' is deprecated. Use option '~s' instead.",
+ [OldOpt, NewOpt]).
+
warn_replaced_option(OldOpt, NewOpt) ->
?WARNING_MSG("Option '~s' is deprecated and was automatically "
"replaced by '~s'. ~s",
-export([captcha_cmd/0]).
-export([captcha_host/0]).
-export([captcha_limit/0]).
+-export([captcha_url/0]).
-export([certfiles/0]).
-export([cluster_backend/0]).
-export([cluster_nodes/0]).
captcha_limit() ->
ejabberd_config:get_option({captcha_limit, global}).
+-spec captcha_url() -> 'undefined' | binary().
+captcha_url() ->
+ ejabberd_config:get_option({captcha_url, global}).
+
-spec certfiles() -> 'undefined' | [binary()].
certfiles() ->
ejabberd_config:get_option({certfiles, global}).
econf:binary();
opt_type(captcha_limit) ->
econf:pos_int(infinity);
+opt_type(captcha_url) ->
+ econf:url();
opt_type(certfiles) ->
econf:list(econf:binary());
opt_type(cluster_backend) ->
{captcha_cmd, undefined},
{captcha_host, <<"">>},
{captcha_limit, infinity},
+ {captcha_url, undefined},
{certfiles, undefined},
{cluster_backend, mnesia},
{cluster_nodes, []},
captcha_cmd,
captcha_host,
captcha_limit,
+ captcha_url,
certfiles,
cluster_backend,
cluster_nodes,