...
1
2
3
4
5
6
7
8
9
10 package topology
11
12 import (
13 "context"
14 "crypto/tls"
15 "net"
16 )
17
18 type tlsConn interface {
19 net.Conn
20
21
22 HandshakeContext(ctx context.Context) error
23 ConnectionState() tls.ConnectionState
24 }
25
26 var _ tlsConn = (*tls.Conn)(nil)
27
28 type tlsConnectionSource interface {
29 Client(net.Conn, *tls.Config) tlsConn
30 }
31
32 type tlsConnectionSourceFn func(net.Conn, *tls.Config) tlsConn
33
34 var _ tlsConnectionSource = (tlsConnectionSourceFn)(nil)
35
36 func (t tlsConnectionSourceFn) Client(nc net.Conn, cfg *tls.Config) tlsConn {
37 return t(nc, cfg)
38 }
39
40 var defaultTLSConnectionSource tlsConnectionSourceFn = func(nc net.Conn, cfg *tls.Config) tlsConn {
41 return tls.Client(nc, cfg)
42 }
43
44
45 func clientHandshake(ctx context.Context, client tlsConn) error {
46 return client.HandshakeContext(ctx)
47 }
48
View as plain text