fix(ipv6): add ipv6_probe socket option only when supported
ipv6_probe is a socket option supported in EMQ's otp.git fork. If the target hostname has a ipv6 DNS resolution, gen_tcp tries to establish a connection on ipv6. If it fails, then a fallback to default gen_tcp:connection
This commit is contained in:
parent
d9c7c72612
commit
a37f47887a
|
@ -60,7 +60,7 @@ translate_env(EnvName) ->
|
|||
Path = path(Path0),
|
||||
MoreOpts = case Scheme of
|
||||
http ->
|
||||
[{transport_opts, [ipv6_probe]}];
|
||||
[{transport_opts, emqx_misc:ipv6_probe([])}];
|
||||
https ->
|
||||
CACertFile = application:get_env(?APP, cacertfile, undefined),
|
||||
CertFile = application:get_env(?APP, certfile, undefined),
|
||||
|
@ -85,7 +85,7 @@ translate_env(EnvName) ->
|
|||
, {ciphers, emqx_tls_lib:default_ciphers()}
|
||||
| TLSOpts
|
||||
],
|
||||
[{transport, ssl}, {transport_opts, [ipv6_probe | NTLSOpts]}]
|
||||
[{transport, ssl}, {transport_opts, emqx_misc:ipv6_probe(NTLSOpts)}]
|
||||
end,
|
||||
PoolOpts = [{host, Host},
|
||||
{port, Port},
|
||||
|
|
|
@ -331,10 +331,12 @@ pool_opts(Params = #{<<"url">> := URL}, ResId) ->
|
|||
PoolSize = maps:get(<<"pool_size">>, Params, 32),
|
||||
ConnectTimeout =
|
||||
cuttlefish_duration:parse(str(maps:get(<<"connect_timeout">>, Params, <<"5s">>))),
|
||||
TransportOpts = case Scheme =:= https of
|
||||
true -> [ipv6_probe | get_ssl_opts(Params, ResId)];
|
||||
false -> [ipv6_probe]
|
||||
end,
|
||||
TransportOpts0 =
|
||||
case Scheme =:= https of
|
||||
true -> [get_ssl_opts(Params, ResId)];
|
||||
false -> []
|
||||
end,
|
||||
TransportOpts = emqx_misc:ipv6_probe(TransportOpts0),
|
||||
Opts = case Scheme =:= https of
|
||||
true -> [{transport_opts, TransportOpts}, {transport, ssl}];
|
||||
false -> [{transport_opts, TransportOpts}]
|
||||
|
|
|
@ -49,7 +49,7 @@ translate_env() ->
|
|||
PoolSize = application:get_env(?APP, pool_size, 32),
|
||||
MoreOpts = case Scheme of
|
||||
http ->
|
||||
[{transport_opts, [ipv6_probe]}];
|
||||
[{transport_opts, emqx_misc:ipv6_probe([])}];
|
||||
https ->
|
||||
CACertFile = application:get_env(?APP, cacertfile, undefined),
|
||||
CertFile = application:get_env(?APP, certfile, undefined),
|
||||
|
@ -74,7 +74,7 @@ translate_env() ->
|
|||
, {ciphers, emqx_tls_lib:default_ciphers()}
|
||||
| TLSOpts
|
||||
],
|
||||
[{transport, ssl}, {transport_opts, [ipv6_probe | NTLSOpts]}]
|
||||
[{transport, ssl}, {transport_opts, emqx_misc:ipv6_probe(NTLSOpts)}]
|
||||
end,
|
||||
PoolOpts = [{host, Host},
|
||||
{port, Port},
|
||||
|
|
Loading…
Reference in New Issue