diff options
Diffstat (limited to 'lib/eldap/src/eldap.erl')
-rw-r--r-- | lib/eldap/src/eldap.erl | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/eldap/src/eldap.erl b/lib/eldap/src/eldap.erl index af5bf94c97..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 @@ -743,7 +756,7 @@ request(S, Data, ID, Request) -> send_request(S, Data, ID, Request) -> Message = #'LDAPMessage'{messageID = ID, protocolOp = Request}, - {ok,Bytes} = asn1rt:encode('ELDAPv3', 'LDAPMessage', Message), + {ok,Bytes} = 'ELDAPv3':encode('LDAPMessage', Message), case do_send(S, Data, Bytes) of {error,Reason} -> throw({gen_tcp_error,Reason}); Else -> Else @@ -762,7 +775,7 @@ do_recv(S, #eldap{using_tls=true, timeout=Timeout}, Len) -> recv_response(S, Data) -> case do_recv(S, Data, 0) of {ok, Packet} -> - case asn1rt:decode('ELDAPv3', 'LDAPMessage', Packet) of + case 'ELDAPv3':decode('LDAPMessage', Packet) of {ok,Resp} -> {ok,Resp}; Error -> throw(Error) end; |