From a10e112e2286ceebd2fa3399ba916b6df61fa4dd Mon Sep 17 00:00:00 2001 From: Christopher Puschmann Date: Sun, 15 Aug 2021 05:37:15 +0200 Subject: [PATCH] add wrapper function `DialWithTLSDialer` to allow use of custom `net.Dialer` (#336) Co-authored-by: John Weldon --- conn.go | 9 +++++++++ v3/conn.go | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/conn.go b/conn.go index 64e4bab4..ae5e19af 100644 --- a/conn.go +++ b/conn.go @@ -130,6 +130,15 @@ func DialWithTLSConfig(tc *tls.Config) DialOpt { } } +// DialWithTLSDialer is a wrapper for DialWithTLSConfig with the option to +// specify a net.Dialer to for example define a timeout or a custom resolver. +func DialWithTLSDialer(tlsConfig *tls.Config, dialer *net.Dialer) DialOpt { + return func(dc *DialContext) { + dc.tc = tlsConfig + dc.d = dialer + } +} + // DialContext contains necessary parameters to dial the given ldap URL. type DialContext struct { d *net.Dialer diff --git a/v3/conn.go b/v3/conn.go index 64e4bab4..ae5e19af 100644 --- a/v3/conn.go +++ b/v3/conn.go @@ -130,6 +130,15 @@ func DialWithTLSConfig(tc *tls.Config) DialOpt { } } +// DialWithTLSDialer is a wrapper for DialWithTLSConfig with the option to +// specify a net.Dialer to for example define a timeout or a custom resolver. +func DialWithTLSDialer(tlsConfig *tls.Config, dialer *net.Dialer) DialOpt { + return func(dc *DialContext) { + dc.tc = tlsConfig + dc.d = dialer + } +} + // DialContext contains necessary parameters to dial the given ldap URL. type DialContext struct { d *net.Dialer