refactor: move ErrorWrapperTLSHandshaker to errorsx (#418)

Part of https://github.com/ooni/probe/issues/1505
This commit is contained in:
Simone Basso 2021-07-01 18:00:09 +02:00 committed by GitHub
commit 863899469e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 84 additions and 50 deletions

View file

@ -8,7 +8,6 @@ import (
"time"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx"
"github.com/ooni/probe-cli/v3/internal/errorsx"
)
// UnderlyingDialer is the underlying dialer type.
@ -22,24 +21,6 @@ type TLSHandshaker interface {
net.Conn, tls.ConnectionState, error)
}
// ErrorWrapperTLSHandshaker wraps the returned error to be an OONI error
type ErrorWrapperTLSHandshaker struct {
TLSHandshaker
}
// Handshake implements Handshaker.Handshake
func (h ErrorWrapperTLSHandshaker) Handshake(
ctx context.Context, conn net.Conn, config *tls.Config,
) (net.Conn, tls.ConnectionState, error) {
tlsconn, state, err := h.TLSHandshaker.Handshake(ctx, conn, config)
err = errorsx.SafeErrWrapperBuilder{
Classifier: errorsx.ClassifyTLSFailure,
Error: err,
Operation: errorsx.TLSHandshakeOperation,
}.MaybeBuild()
return tlsconn, state, err
}
// EmitterTLSHandshaker emits events using the MeasurementRoot
type EmitterTLSHandshaker struct {
TLSHandshaker