mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
ejabberd_stun: Fix 'turn_ip' fallback
The 'turn_ip' option validator doesn't accept an inet:ip4_address() tuple. While at it, change the logic to only perform the fallback address lookup if no 'turn_ip' is configured (analogous to the fallback mechanism for the case where the 'auth_realm' is undefined).
This commit is contained in:
parent
1f7ca91670
commit
c55e7b8499
@ -101,16 +101,23 @@ prepare_turn_opts(Opts, _UseTurn = false) ->
|
|||||||
set_certfile(Opts);
|
set_certfile(Opts);
|
||||||
prepare_turn_opts(Opts, _UseTurn = true) ->
|
prepare_turn_opts(Opts, _UseTurn = true) ->
|
||||||
NumberOfMyHosts = length(ejabberd_option:hosts()),
|
NumberOfMyHosts = length(ejabberd_option:hosts()),
|
||||||
case {proplists:get_value(turn_ip, Opts),
|
TurnIP = case proplists:get_value(turn_ip, Opts) of
|
||||||
proplists:get_value(turn_ip, listen_options())} of
|
undefined ->
|
||||||
{undefined, {127, _, _, _}} ->
|
MyIP = misc:get_my_ip(),
|
||||||
?WARNING_MSG("Option 'turn_ip' is undefined and the server's "
|
case MyIP of
|
||||||
"hostname doesn't resolve to a public IPv4 address, "
|
{127, _, _, _} ->
|
||||||
"most likely the TURN relay won't be working properly",
|
?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
|
ok
|
||||||
end,
|
end,
|
||||||
|
[{turn_ip, MyIP}];
|
||||||
|
_ ->
|
||||||
|
[]
|
||||||
|
end,
|
||||||
AuthFun = fun ejabberd_stun:get_password/2,
|
AuthFun = fun ejabberd_stun:get_password/2,
|
||||||
Shaper = proplists:get_value(shaper, Opts, none),
|
Shaper = proplists:get_value(shaper, Opts, none),
|
||||||
AuthType = proplists:get_value(auth_type, Opts, user),
|
AuthType = proplists:get_value(auth_type, Opts, user),
|
||||||
@ -132,7 +139,7 @@ prepare_turn_opts(Opts, _UseTurn = true) ->
|
|||||||
[]
|
[]
|
||||||
end,
|
end,
|
||||||
MaxRate = ejabberd_shaper:get_max_rate(Shaper),
|
MaxRate = ejabberd_shaper:get_max_rate(Shaper),
|
||||||
Opts1 = Realm ++ [{auth_fun, AuthFun},{shaper, MaxRate} |
|
Opts1 = TurnIP ++ Realm ++ [{auth_fun, AuthFun},{shaper, MaxRate} |
|
||||||
lists:keydelete(shaper, 1, Opts)],
|
lists:keydelete(shaper, 1, Opts)],
|
||||||
set_certfile(Opts1).
|
set_certfile(Opts1).
|
||||||
|
|
||||||
@ -176,7 +183,7 @@ listen_opt_type(certfile) ->
|
|||||||
listen_options() ->
|
listen_options() ->
|
||||||
[{shaper, none},
|
[{shaper, none},
|
||||||
{use_turn, false},
|
{use_turn, false},
|
||||||
{turn_ip, misc:get_my_ip()},
|
{turn_ip, undefined},
|
||||||
{auth_type, user},
|
{auth_type, user},
|
||||||
{auth_realm, undefined},
|
{auth_realm, undefined},
|
||||||
{tls, false},
|
{tls, false},
|
||||||
|
Loading…
Reference in New Issue
Block a user