72acd175a0
Still working towards https://github.com/ooni/probe/issues/1505
31 lines
768 B
Go
31 lines
768 B
Go
package quicdialer
|
|
|
|
import (
|
|
"context"
|
|
"crypto/tls"
|
|
|
|
"github.com/lucas-clemente/quic-go"
|
|
"github.com/ooni/probe-cli/v3/internal/errorsx"
|
|
)
|
|
|
|
// ErrorWrapperDialer is a dialer that performs quic err wrapping
|
|
type ErrorWrapperDialer struct {
|
|
Dialer ContextDialer
|
|
}
|
|
|
|
// DialContext implements ContextDialer.DialContext
|
|
func (d ErrorWrapperDialer) DialContext(
|
|
ctx context.Context, network string, host string,
|
|
tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlySession, error) {
|
|
sess, err := d.Dialer.DialContext(ctx, network, host, tlsCfg, cfg)
|
|
err = errorsx.SafeErrWrapperBuilder{
|
|
Classifier: errorsx.ClassifyQUICFailure,
|
|
Error: err,
|
|
Operation: errorsx.QUICHandshakeOperation,
|
|
}.MaybeBuild()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return sess, nil
|
|
}
|