diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2020-04-20 08:42:32 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2020-04-20 08:42:32 +0200 |
commit | c836dc66a8a10ba88d985ba07511b89d181c6b81 (patch) | |
tree | 7de8b66feaca6e4c17fea42114b69f61a3bd3629 /src/ejabberd_stun.erl | |
parent | Travis 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.erl | 14 |
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}, |