25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Rename 'turn_v4_ip' and 'turn_v6_ip' options

The 'turn_ipv4_address' and 'turn_ipv6_address' option names are
probably more intuitive.
This commit is contained in:
Holger Weiss 2020-05-29 18:40:19 +02:00
parent 21312c79aa
commit 7a37483307
7 changed files with 38 additions and 37 deletions

View File

@ -90,7 +90,7 @@ defmodule Ejabberd.Mixfile do
{:stringprep, "~> 1.0"},
{:fast_yaml, "~> 1.0"},
{:fast_tls, "~> 1.1"},
{:stun, git: "https://github.com/processone/stun", ref: "a96f588c8ded48cd15e99911cf7b22ca67b532db", override: true},
{:stun, git: "https://github.com/processone/stun", ref: "35cdef8b0ae35daa797a292c57dbd5ee62b45876", override: true},
{:esip, "~> 1.0.32"},
{:p1_mysql, "~> 1.0"},
{:mqtree, "~> 1.0"},

View File

@ -36,7 +36,7 @@
{mqtree, ".*", {git, "https://github.com/processone/mqtree", {tag, "1.0.7"}}},
{p1_acme, ".*", {git, "https://github.com/processone/p1_acme.git", {tag, "1.0.5"}}},
{base64url, ".*", {git, "https://github.com/dvv/base64url.git", {tag, "v1.0"}}},
{if_var_true, stun, {stun, ".*", {git, "https://github.com/processone/stun", "a96f588c8ded48cd15e99911cf7b22ca67b532db"}}},
{if_var_true, stun, {stun, ".*", {git, "https://github.com/processone/stun", "35cdef8b0ae35daa797a292c57dbd5ee62b45876"}}},
{if_var_true, sip, {esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.33"}}}},
{if_var_true, mysql, {p1_mysql, ".*", {git, "https://github.com/processone/p1_mysql",
{tag, "1.0.15"}}}},

View File

@ -334,8 +334,8 @@ remove_xmlrpc_access_commands(Opts) ->
replace_turn_ip(Opts) ->
lists:filtermap(
fun({turn_ip, Val}) ->
warn_replaced_option(turn_ip, turn_v4_ip),
{true, {turn_v4_ip, Val}};
warn_replaced_option(turn_ip, turn_ipv4_address),
{true, {turn_ipv4_address, Val}};
(_) ->
true
end, Opts).

View File

@ -101,20 +101,20 @@ prepare_turn_opts(Opts, _UseTurn = false) ->
set_certfile(Opts);
prepare_turn_opts(Opts, _UseTurn = true) ->
NumberOfMyHosts = length(ejabberd_option:hosts()),
TurnIP = case proplists:get_value(turn_v4_ip, Opts) of
TurnIP = case proplists:get_value(turn_ipv4_address, Opts) of
undefined ->
MyIP = misc:get_my_v4_ip(),
MyIP = misc:get_my_ipv4_address(),
case MyIP of
{127, _, _, _} ->
?WARNING_MSG("Option 'turn_v4_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", []);
?WARNING_MSG("Option 'turn_ipv4_address' 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,
[{turn_v4_ip, MyIP}];
[{turn_ipv4_address, MyIP}];
_ ->
[]
end,
@ -161,9 +161,9 @@ listen_opt_type(use_turn) ->
econf:bool();
listen_opt_type(ip) ->
econf:ip();
listen_opt_type(turn_v4_ip) ->
listen_opt_type(turn_ipv4_address) ->
econf:ipv4();
listen_opt_type(turn_v6_ip) ->
listen_opt_type(turn_ipv6_address) ->
econf:ipv6();
listen_opt_type(auth_type) ->
econf:enum([anonymous, user]);
@ -187,8 +187,8 @@ listen_opt_type(certfile) ->
listen_options() ->
[{shaper, none},
{use_turn, false},
{turn_v4_ip, undefined},
{turn_v6_ip, undefined},
{turn_ipv4_address, undefined},
{turn_ipv6_address, undefined},
{auth_type, user},
{auth_realm, undefined},
{tls, false},

View File

@ -40,8 +40,8 @@
read_css/1, read_img/1, read_js/1, read_lua/1, try_url/1,
intersection/2, format_val/1, cancel_timer/1, unique_timestamp/0,
is_mucsub_message/1, best_match/2, pmap/2, peach/2, format_exception/4,
get_my_v4_ip/0, get_my_v6_ip/0, parse_ip_mask/1, match_ip_mask/3,
format_hosts_list/1, format_cycle/1, delete_dir/1]).
get_my_ipv4_address/0, get_my_ipv6_address/0, parse_ip_mask/1,
match_ip_mask/3, format_hosts_list/1, format_cycle/1, delete_dir/1]).
%% Deprecated functions
-export([decode_base64/1, encode_base64/1]).
@ -509,16 +509,16 @@ format_exception(Level, Class, Reason, Stacktrace) ->
end).
-endif.
-spec get_my_v4_ip() -> inet:ip4_address().
get_my_v4_ip() ->
-spec get_my_ipv4_address() -> inet:ip4_address().
get_my_ipv4_address() ->
{ok, MyHostName} = inet:gethostname(),
case inet:getaddr(MyHostName, inet) of
{ok, Addr} -> Addr;
{error, _} -> {127, 0, 0, 1}
end.
-spec get_my_v6_ip() -> inet:ip6_address().
get_my_v6_ip() ->
-spec get_my_ipv6_address() -> inet:ip6_address().
get_my_ipv6_address() ->
{ok, MyHostName} = inet:gethostname(),
case inet:getaddr(MyHostName, inet6) of
{ok, Addr} -> Addr;

View File

@ -266,7 +266,7 @@ get_streamhost(Host, ServerHost) ->
get_endpoint(Host) ->
Port = mod_proxy65_opt:port(Host),
IP = case mod_proxy65_opt:ip(Host) of
undefined -> misc:get_my_v4_ip();
undefined -> misc:get_my_ipv4_address();
Addr -> Addr
end,
{Port, IP, tcp}.

View File

@ -596,8 +596,9 @@ parse_listener({{Port, _Addr, Transport}, ?STUN_MODULE, Opts}) ->
case get_listener_ips(Opts) of
{undefined, undefined} ->
?INFO_MSG("Won't auto-announce STUN/TURN service on port ~B (~s) "
"without public address, please specify 'turn_v4_ip' and "
"optionally 'turn_v6_ip'", [Port, Transport]),
"without public IP address, please specify "
"'turn_ipv4_address' and optionally 'turn_ipv6_address'",
[Port, Transport]),
[];
{IPv4Addr, IPv6Addr} ->
lists:flatmap(
@ -635,34 +636,34 @@ parse_listener({_EndPoint, Module, _Opts}) ->
-spec get_listener_ips(map()) -> {inet:ip4_address() | undefined,
inet:ip6_address() | undefined}.
get_listener_ips(#{ip := {0, 0, 0, 0}} = Opts) ->
{get_turn_v4_ip(Opts), undefined};
{get_turn_ipv4_addr(Opts), undefined};
get_listener_ips(#{ip := {0, 0, 0, 0, 0, 0, 0, 0}} = Opts) ->
{get_turn_v4_ip(Opts), get_turn_v6_ip(Opts)}; % Assume dual-stack socket.
{get_turn_ipv4_addr(Opts), get_turn_ipv6_addr(Opts)}; % Assume dual-stack.
get_listener_ips(#{ip := {127, _, _, _}} = Opts) ->
{get_turn_v4_ip(Opts), undefined};
{get_turn_ipv4_addr(Opts), undefined};
get_listener_ips(#{ip := {0, 0, 0, 0, 0, 0, 0, 1}} = Opts) ->
{undefined, get_turn_v6_ip(Opts)};
{undefined, get_turn_ipv6_addr(Opts)};
get_listener_ips(#{ip := {_, _, _, _} = IP}) ->
{IP, undefined};
get_listener_ips(#{ip := {_, _, _, _, _,_, _, _, _} = IP}) ->
{undefined, IP}.
-spec get_turn_v4_ip(map()) -> inet:ip4_address() | undefined.
get_turn_v4_ip(#{turn_v4_ip := {_, _, _, _} = TurnIP}) ->
-spec get_turn_ipv4_addr(map()) -> inet:ip4_address() | undefined.
get_turn_ipv4_addr(#{turn_ipv4_address := {_, _, _, _} = TurnIP}) ->
TurnIP;
get_turn_v4_ip(#{turn_v4_ip := undefined}) ->
case misc:get_my_v4_ip() of
get_turn_ipv4_addr(#{turn_ipv4_address := undefined}) ->
case misc:get_my_ipv4_address() of
{127, _, _, _} ->
undefined;
IP ->
IP
end.
-spec get_turn_v6_ip(map()) -> inet:ip6_address() | undefined.
get_turn_v6_ip(#{turn_v6_ip := {_, _, _, _, _, _, _, _} = TurnIP}) ->
-spec get_turn_ipv6_addr(map()) -> inet:ip6_address() | undefined.
get_turn_ipv6_addr(#{turn_ipv6_address := {_, _, _, _, _, _, _, _} = TurnIP}) ->
TurnIP;
get_turn_v6_ip(#{turn_v6_ip := undefined}) ->
case misc:get_my_v6_ip() of
get_turn_ipv6_addr(#{turn_ipv6_address := undefined}) ->
case misc:get_my_ipv6_address() of
{0, 0, 0, 0, 0, 0, 0, 1} ->
undefined;
IP ->