From 99d93ea7773fd0f7cdb325749bcc10f6552eda68 Mon Sep 17 00:00:00 2001 From: Christoffer Hamberg Date: Tue, 15 Mar 2016 13:58:31 +0200 Subject: [PATCH 1/2] feat (LDAP) expose connection socket class --- lib/net/ldap.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/net/ldap.rb b/lib/net/ldap.rb index 4ba27339..bff101b7 100644 --- a/lib/net/ldap.rb +++ b/lib/net/ldap.rb @@ -541,6 +541,7 @@ def initialize(args = {}) @force_no_page = args[:force_no_page] || DefaultForceNoPage @encryption = normalize_encryption(args[:encryption]) # may be nil @connect_timeout = args[:connect_timeout] + @socket_class = args[:socket_class] if pr = @auth[:password] and pr.respond_to?(:call) @auth[:password] = pr.call @@ -1305,7 +1306,8 @@ def new_connection :hosts => @hosts, :encryption => @encryption, :instrumentation_service => @instrumentation_service, - :connect_timeout => @connect_timeout + :connect_timeout => @connect_timeout, + :socket_class => @socket_class # Force connect to see if there's a connection error connection.socket From 45ac34d66ddc411f2967e8d2cb736cdbfcec657c Mon Sep 17 00:00:00 2001 From: Juha Suuraho Date: Wed, 1 Nov 2017 12:33:35 +0200 Subject: [PATCH 2/2] fix (socket) Use default socketclass if server has nil socketclass. --- lib/net/ldap/connection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/net/ldap/connection.rb b/lib/net/ldap/connection.rb index f8ba0b61..a1e55bf7 100644 --- a/lib/net/ldap/connection.rb +++ b/lib/net/ldap/connection.rb @@ -22,7 +22,7 @@ def initialize(server = {}) @instrumentation_service = server[:instrumentation_service] # Allows tests to parameterize what socket class to use - @socket_class = server.fetch(:socket_class, DefaultSocket) + @socket_class = server.fetch(:socket_class, DefaultSocket) || DefaultSocket yield self if block_given? end