|
|
@@ -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.
|