Merge branch 'dev/v4.3.0' into fix/webhook_certs

This commit is contained in:
JianBo He 2021-01-25 19:22:14 +08:00 committed by GitHub
commit 8d56371465
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 52 deletions

View File

@ -61,20 +61,7 @@ translate_env(EnvName) ->
_ -> 80
end),
Path = path(Path0),
Host = case inet:parse_address(Host0) of
{ok, {_,_,_,_} = Addr} -> Addr;
{ok, {_,_,_,_,_,_,_,_} = Addr} -> Addr;
{error, einval} -> Host0
end,
Inet = case Host of
{_,_,_,_} -> inet;
{_,_,_,_,_,_,_,_} -> inet6;
_ ->
case inet:getaddr(Host, inet6) of
{error, _} -> inet;
{ok, _} -> inet6
end
end,
{Inet, Host} = parse_host(Host0),
MoreOpts = case Scheme of
"http" ->
[{transport_opts, [Inet]}];
@ -152,6 +139,17 @@ unload_hooks() ->
ehttpc_sup:stop_pool('emqx_auth_http/acl_req'),
ok.
parse_host(Host) ->
case inet:parse_address(Host) of
{ok, Addr} when size(Addr) =:= 4 -> {inet, Addr};
{ok, Addr} when size(Addr) =:= 8 -> {inet6, Addr};
{error, einval} ->
case inet:getaddr(Host, inet6) of
{ok, _} -> {inet6, Host};
{error, _} -> {inet, Host}
end
end.
to_lower(Headers) ->
[{string:to_lower(K), V} || {K, V} <- Headers].

View File

@ -1,5 +1,5 @@
{deps,
[{eredis_cluster, {git, "https://github.com/emqx/eredis_cluster", {tag, "0.6.3"}}}
[{eredis_cluster, {git, "https://github.com/emqx/eredis_cluster", {tag, "0.6.4"}}}
]}.
{erl_opts, [warn_unused_vars,

View File

@ -1,5 +1,5 @@
{deps, [
{recon, {git, "https://github.com/ferd/recon", {tag, "2.5.0"}}}
%% recon "https://github.com/ferd/recon" at root rebar.config
]}.
{edoc_opts, [{preprocess, true}]}.

View File

@ -340,20 +340,7 @@ pool_opts(Params = #{<<"url">> := URL}) ->
end),
PoolSize = maps:get(<<"pool_size">>, Params, 32),
ConnectTimeout = timer:seconds(maps:get(<<"connect_timeout">>, Params, 5)),
Host = case inet:parse_address(Host0) of
{ok, {_,_,_,_} = Addr} -> Addr;
{ok, {_,_,_,_,_,_,_,_} = Addr} -> Addr;
{error, einval} -> Host0
end,
Inet = case Host of
{_,_,_,_} -> inet;
{_,_,_,_,_,_,_,_} -> inet6;
_ ->
case inet:getaddr(Host, inet6) of
{error, _} -> inet;
{ok, _} -> inet6
end
end,
{Inet, Host} = parse_host(Host0),
MoreOpts = case Scheme of
"http" ->
[{transport_opts, [Inet]}];
@ -388,3 +375,14 @@ pool_opts(Params = #{<<"url">> := URL}) ->
pool_name(ResId) ->
list_to_atom("webhook:" ++ str(ResId)).
parse_host(Host) ->
case inet:parse_address(Host) of
{ok, Addr} when size(Addr) =:= 4 -> {inet, Addr};
{ok, Addr} when size(Addr) =:= 8 -> {inet6, Addr};
{error, einval} ->
case inet:getaddr(Host, inet6) of
{ok, _} -> {inet6, Host};
{error, _} -> {inet, Host}
end
end.

View File

@ -58,20 +58,7 @@ translate_env() ->
_ -> 80
end),
Path = path(Path0),
Host = case inet:parse_address(Host0) of
{ok, {_,_,_,_} = Addr} -> Addr;
{ok, {_,_,_,_,_,_,_,_} = Addr} -> Addr;
{error, einval} -> Host0
end,
Inet = case Host of
{_,_,_,_} -> inet;
{_,_,_,_,_,_,_,_} -> inet6;
_ ->
case inet:getaddr(Host, inet6) of
{error, _} -> inet;
{ok, _} -> inet6
end
end,
{Inet, Host} = parse_host(Host0),
PoolSize = application:get_env(?APP, pool_size, 32),
MoreOpts = case Scheme of
"http" ->
@ -117,3 +104,14 @@ path(Path) ->
set_content_type(Headers) ->
NHeaders = proplists:delete(<<"Content-Type">>, proplists:delete(<<"content-type">>, Headers)),
[{<<"content-type">>, <<"application/json">>} | NHeaders].
parse_host(Host) ->
case inet:parse_address(Host) of
{ok, Addr} when size(Addr) =:= 4 -> {inet, Addr};
{ok, Addr} when size(Addr) =:= 8 -> {inet6, Addr};
{error, einval} ->
case inet:getaddr(Host, inet6) of
{ok, _} -> {inet6, Host};
{error, _} -> {inet, Host}
end
end.

View File

@ -54,6 +54,7 @@
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.4"}}}
, {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.2.3"}}}
, {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.2"}}}
, {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}}
, {getopt, "1.0.1"}
]}.

View File

@ -275,14 +275,8 @@ util_alloc()->
alloc(?UTIL_ALLOCATORS).
alloc(Type) ->
[{{T, Instance}, Props} || {{T, Instance}, Props} <- allocators(), lists:member(T, Type)].
allocators() ->
UtilAllocators = erlang:system_info(alloc_util_allocators),
Allocators = [sys_alloc, mseg_alloc|UtilAllocators],
[{{A, N}, lists:sort(proplists:delete(versions, Props))} ||
A <- Allocators, Allocs <- [erlang:system_info({allocator, A})],
Allocs =/= false, {_, N, Props} <- Allocs].
[{{T, Instance}, Props} ||
{{T, Instance}, Props} <- recon_alloc:allocators(), lists:member(T, Type)].
container_size(Prop, Keyword, Container) ->
Sbcs = container_value(Prop, Keyword, sbcs, Container),