aboutsummaryrefslogtreecommitdiff
path: root/src/ejabberd_stun.erl
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2020-04-20 08:42:32 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2020-04-20 08:42:32 +0200
commitc836dc66a8a10ba88d985ba07511b89d181c6b81 (patch)
tree7de8b66feaca6e4c17fea42114b69f61a3bd3629 /src/ejabberd_stun.erl
parentTravis CI: Test against Erlang/OTP 22.3 (diff)
ejabberd_stun: Set a default 'turn_ip'
Try to resolve the local hostname, use the result as the default 'turn_ip', and only log a warning if that fails. Using the local hostname's address by default is analogous to mod_proxy65's behavior.
Diffstat (limited to 'src/ejabberd_stun.erl')
-rw-r--r--src/ejabberd_stun.erl14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/ejabberd_stun.erl b/src/ejabberd_stun.erl
index 347598e6d..89fc830dd 100644
--- a/src/ejabberd_stun.erl
+++ b/src/ejabberd_stun.erl
@@ -85,11 +85,13 @@ prepare_turn_opts(Opts, _UseTurn = false) ->
set_certfile(Opts);
prepare_turn_opts(Opts, _UseTurn = true) ->
NumberOfMyHosts = length(ejabberd_option:hosts()),
- case proplists:get_value(turn_ip, Opts) of
- undefined ->
- ?WARNING_MSG("Option 'turn_ip' is undefined, "
- "most likely the TURN relay won't be working "
- "properly", []);
+ case {proplists:get_value(turn_ip, Opts),
+ proplists:get_value(turn_ip, listen_options())} of
+ {undefined, {127, _, _, _}} ->
+ ?WARNING_MSG("Option 'turn_ip' is undefined and the server's "
+ "hostname doesn't resolve to a public IPv4 address, "
+ "most likely the TURN relay won't be working properly",
+ []);
_ ->
ok
end,
@@ -158,7 +160,7 @@ listen_opt_type(certfile) ->
listen_options() ->
[{shaper, none},
{use_turn, false},
- {turn_ip, undefined},
+ {turn_ip, misc:get_my_ip()},
{auth_type, user},
{auth_realm, undefined},
{tls, false},