diff options
author | Henrik Nord <[email protected]> | 2014-02-24 16:16:04 +0100 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2014-02-24 16:16:04 +0100 |
commit | c09955d29b6e4322b3a8adff962ff62d9c47647e (patch) | |
tree | 00a471fabacaf253a63b1dd92b9f4bdd6a55824a /lib/eldap/src/eldap.erl | |
parent | 4203d5c2acb4e807835b85a568a3e1dff21c930a (diff) | |
parent | 02d46a1464c3bcd69b0de046c21146ccc6bf10c4 (diff) | |
download | otp-c09955d29b6e4322b3a8adff962ff62d9c47647e.tar.gz otp-c09955d29b6e4322b3a8adff962ff62d9c47647e.tar.bz2 otp-c09955d29b6e4322b3a8adff962ff62d9c47647e.zip |
Merge branch 'efine/eldap-IPv6-connections/OTP-11753'
* efine/eldap-IPv6-connections/OTP-11753:
Add support for IPv6 connections
Diffstat (limited to 'lib/eldap/src/eldap.erl')
-rw-r--r-- | lib/eldap/src/eldap.erl | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/eldap/src/eldap.erl b/lib/eldap/src/eldap.erl index a86fd39adb..1cd328cde3 100644 --- a/lib/eldap/src/eldap.erl +++ b/lib/eldap/src/eldap.erl @@ -45,9 +45,10 @@ log, % User provided log function timeout = infinity, % Request timeout anon_auth = false, % Allow anonymous authentication - ldaps = false, % LDAP/LDAPS + ldaps = false, % LDAP/LDAPS using_tls = false, % true if LDAPS or START_TLS executed - tls_opts = [] % ssl:ssloption() + tls_opts = [], % ssl:ssloption() + tcp_opts = [] % inet6 support }). %%% For debug purposes @@ -372,6 +373,8 @@ parse_args([{sslopts, Opts}|T], Cpid, Data) when is_list(Opts) -> parse_args(T, Cpid, Data#eldap{ldaps = true, using_tls=true, tls_opts = Opts ++ Data#eldap.tls_opts}); parse_args([{sslopts, _}|T], Cpid, Data) -> parse_args(T, Cpid, Data); +parse_args([{tcpopts, Opts}|T], Cpid, Data) when is_list(Opts) -> + parse_args(T, Cpid, Data#eldap{tcp_opts = inet6_opt(Opts) ++ Data#eldap.tcp_opts}); parse_args([{log, F}|T], Cpid, Data) when is_function(F) -> parse_args(T, Cpid, Data#eldap{log = F}); parse_args([{log, _}|T], Cpid, Data) -> @@ -382,6 +385,14 @@ parse_args([H|_], Cpid, _) -> parse_args([], _, Data) -> Data. +inet6_opt(Opts) -> + case proplists:get_value(inet6, Opts) of + true -> + [inet6]; + _ -> + [] + end. + %%% Try to connect to the hosts in the listed order, %%% and stop with the first one to which a successful %%% connection is made. @@ -401,9 +412,11 @@ try_connect([],_) -> {error,"connect failed"}. do_connect(Host, Data, Opts) when Data#eldap.ldaps == false -> - gen_tcp:connect(Host, Data#eldap.port, Opts, Data#eldap.timeout); + gen_tcp:connect(Host, Data#eldap.port, Opts ++ Data#eldap.tcp_opts, + Data#eldap.timeout); do_connect(Host, Data, Opts) when Data#eldap.ldaps == true -> - ssl:connect(Host, Data#eldap.port, Opts++Data#eldap.tls_opts). + ssl:connect(Host, Data#eldap.port, + Opts ++ Data#eldap.tls_opts ++ Data#eldap.tcp_opts). loop(Cpid, Data) -> receive |