fix(netxlite): improve TLS auto-configuration (#409)
Auto-configure every relevant TLS field as close as possible to where it's actually used. As a side effect, add support for mocking the creation of a TLS connection, which should possibly be useful for uTLS? Work that is part of https://github.com/ooni/probe/issues/1505
This commit is contained in:
parent
f1f5ed342e
commit
b07890af4d
16 changed files with 360 additions and 89 deletions
25
internal/netxmocks/tlsconn.go
Normal file
25
internal/netxmocks/tlsconn.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package netxmocks
|
||||
|
||||
import "crypto/tls"
|
||||
|
||||
// TLSConn allows to mock netxlite.TLSConn.
|
||||
type TLSConn struct {
|
||||
// Conn is the embedded mockable Conn.
|
||||
Conn
|
||||
|
||||
// MockConnectionState allows to mock the ConnectionState method.
|
||||
MockConnectionState func() tls.ConnectionState
|
||||
|
||||
// MockHandshake allows to mock the Handshake method.
|
||||
MockHandshake func() error
|
||||
}
|
||||
|
||||
// ConnectionState calls MockConnectionState.
|
||||
func (c *TLSConn) ConnectionState() tls.ConnectionState {
|
||||
return c.MockConnectionState()
|
||||
}
|
||||
|
||||
// Handshake calls MockHandshake.
|
||||
func (c *TLSConn) Handshake() error {
|
||||
return c.MockHandshake()
|
||||
}
|
||||
Loading…
Reference in a new issue