refactor: i/errorsx is now i/legacy/errorsx (#479)

We need still to add similar wrappers to internal/netxlite but we
will adopt a saner approach to error wrapping this time.

See https://github.com/ooni/probe/issues/1591
This commit is contained in:
Simone Basso 2021-09-07 17:52:42 +02:00 committed by GitHub
commit ee78c76085
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 16 additions and 16 deletions

View file

@ -1,33 +0,0 @@
package errorsx
import (
"context"
"crypto/tls"
"net"
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
)
// TLSHandshaker is the generic TLS handshaker
type TLSHandshaker interface {
Handshake(ctx context.Context, conn net.Conn, config *tls.Config) (
net.Conn, tls.ConnectionState, error)
}
// ErrorWrapperTLSHandshaker wraps the returned error to be an OONI error
type ErrorWrapperTLSHandshaker struct {
TLSHandshaker
}
// Handshake implements TLSHandshaker.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 = SafeErrWrapperBuilder{
Classifier: errorsx.ClassifyTLSHandshakeError,
Error: err,
Operation: errorsx.TLSHandshakeOperation,
}.MaybeBuild()
return tlsconn, state, err
}