Skip to content

Commit d504ed3

Browse files
committed
MB-48940: Merge remote-tracking branch 'couchbase/mad-hatter'
MB-48306 [BP] Make clusterEncryptionLevel available on pools/default MB-48046 Display cluster encryption level on servers page MB-48940: Try both address family while connecting to LDAP host Change-Id: Ibc7f3e42653df73094a1e64496b146c0b93de736
2 parents 801bd51 + 14cd8b8 commit d504ed3

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/ldap_util.erl

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,32 @@ open_ldap_connection([Host|Hosts], Port, SSL, Timeout, Settings) ->
106106
end,
107107
%% Note: timeout option sets not only connect timeout but a timeout for any
108108
%% request to ldap server
109-
case eldap:open([Host], [{port, Port}, {timeout, Timeout} | SSLOpts]) of
109+
Opts = [{port, Port}, {timeout, Timeout} | SSLOpts],
110+
case do_open_ldap_connection(Host, Opts) of
110111
{ok, Handle} -> {ok, Handle, Host};
111112
{error, _} -> open_ldap_connection(Hosts, Port, SSL, Timeout, Settings)
112113
end.
113114

115+
do_open_ldap_connection(Host, Opts) ->
116+
ToTry = case {misc:is_raw_ip(Host), misc:is_raw_ipv6(Host)} of
117+
{_, true} ->
118+
[inet6];
119+
{true, _} ->
120+
[inet];
121+
_ ->
122+
case misc:get_net_family() of
123+
inet ->
124+
[inet, inet6];
125+
inet6 ->
126+
[inet6, inet]
127+
end
128+
end,
129+
lists:foldl(fun (_Afamily, {ok, Handle}) ->
130+
{ok, Handle};
131+
(Afamily, _) ->
132+
eldap:open([Host], [{tcpopts, [Afamily]} | Opts])
133+
end, undefined, ToTry).
134+
114135
with_connection(Settings, Fun) ->
115136
Hosts = proplists:get_value(hosts, Settings),
116137
Port = proplists:get_value(port, Settings),

0 commit comments

Comments
 (0)