Skip to content

Commit a10e112

Browse files
Christopher Puschmannjohnweldon
Christopher Puschmann
andauthored
add wrapper function DialWithTLSDialer to allow use of custom net.Dialer (#336)
Co-authored-by: John Weldon <[email protected]>
1 parent b09d2f3 commit a10e112

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

conn.go

+9
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ func DialWithTLSConfig(tc *tls.Config) DialOpt {
130130
}
131131
}
132132

133+
// DialWithTLSDialer is a wrapper for DialWithTLSConfig with the option to
134+
// specify a net.Dialer to for example define a timeout or a custom resolver.
135+
func DialWithTLSDialer(tlsConfig *tls.Config, dialer *net.Dialer) DialOpt {
136+
return func(dc *DialContext) {
137+
dc.tc = tlsConfig
138+
dc.d = dialer
139+
}
140+
}
141+
133142
// DialContext contains necessary parameters to dial the given ldap URL.
134143
type DialContext struct {
135144
d *net.Dialer

v3/conn.go

+9
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ func DialWithTLSConfig(tc *tls.Config) DialOpt {
130130
}
131131
}
132132

133+
// DialWithTLSDialer is a wrapper for DialWithTLSConfig with the option to
134+
// specify a net.Dialer to for example define a timeout or a custom resolver.
135+
func DialWithTLSDialer(tlsConfig *tls.Config, dialer *net.Dialer) DialOpt {
136+
return func(dc *DialContext) {
137+
dc.tc = tlsConfig
138+
dc.d = dialer
139+
}
140+
}
141+
133142
// DialContext contains necessary parameters to dial the given ldap URL.
134143
type DialContext struct {
135144
d *net.Dialer

0 commit comments

Comments
 (0)