25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +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"}, {:stringprep, "~> 1.0"},
{:fast_yaml, "~> 1.0"}, {:fast_yaml, "~> 1.0"},
{:fast_tls, "~> 1.1"}, {: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"}, {:esip, "~> 1.0.32"},
{:p1_mysql, "~> 1.0"}, {:p1_mysql, "~> 1.0"},
{:mqtree, "~> 1.0"}, {:mqtree, "~> 1.0"},

View File

@ -36,7 +36,7 @@
{mqtree, ".*", {git, "https://github.com/processone/mqtree", {tag, "1.0.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"}}}, {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"}}}, {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, 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", {if_var_true, mysql, {p1_mysql, ".*", {git, "https://github.com/processone/p1_mysql",
{tag, "1.0.15"}}}}, {tag, "1.0.15"}}}},

View File

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

View File

@ -101,20 +101,20 @@ 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()),
TurnIP = case proplists:get_value(turn_v4_ip, Opts) of TurnIP = case proplists:get_value(turn_ipv4_address, Opts) of
undefined -> undefined ->
MyIP = misc:get_my_v4_ip(), MyIP = misc:get_my_ipv4_address(),
case MyIP of case MyIP of
{127, _, _, _} -> {127, _, _, _} ->
?WARNING_MSG("Option 'turn_v4_ip' is undefined " ?WARNING_MSG("Option 'turn_ipv4_address' is "
"and the server's hostname doesn't " "undefined and the server's hostname "
"resolve to a public IPv4 address, " "doesn't resolve to a public IPv4 "
"most likely the TURN relay won't be " "address, most likely the TURN relay "
"working properly", []); "won't be working properly", []);
_ -> _ ->
ok ok
end, end,
[{turn_v4_ip, MyIP}]; [{turn_ipv4_address, MyIP}];
_ -> _ ->
[] []
end, end,
@ -161,9 +161,9 @@ listen_opt_type(use_turn) ->
econf:bool(); econf:bool();
listen_opt_type(ip) -> listen_opt_type(ip) ->
econf:ip(); econf:ip();
listen_opt_type(turn_v4_ip) -> listen_opt_type(turn_ipv4_address) ->
econf:ipv4(); econf:ipv4();
listen_opt_type(turn_v6_ip) -> listen_opt_type(turn_ipv6_address) ->
econf:ipv6(); econf:ipv6();
listen_opt_type(auth_type) -> listen_opt_type(auth_type) ->
econf:enum([anonymous, user]); econf:enum([anonymous, user]);
@ -187,8 +187,8 @@ listen_opt_type(certfile) ->
listen_options() -> listen_options() ->
[{shaper, none}, [{shaper, none},
{use_turn, false}, {use_turn, false},
{turn_v4_ip, undefined}, {turn_ipv4_address, undefined},
{turn_v6_ip, undefined}, {turn_ipv6_address, undefined},
{auth_type, user}, {auth_type, user},
{auth_realm, undefined}, {auth_realm, undefined},
{tls, false}, {tls, false},

View File

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

View File

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

View File

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