cli: error classification refactoring (#386)
* make errorx classifier less dependent on strings * adapt errorx tests * added syserror comment * localized classification of quic errors * localized classification of resolver errors * (fix) move "no such host" error to global classifier * moved x509 errors to local TLS error classifier * added qtls error classification for quicdialer * add Classifier to SafeErrWrapperBuilder * windows/unix specific files for errno constants * added errno ETIMEDOUT, tests * added TLS alert constants * added FailureSSLHandshake test, improved switch style * added more network based system error constants for future use * (fix) import style * (fix) errorx typos/style * (fix) robustness of SafeErrWrapperBuilder, added comments * (fix) reversed unnecessary changes, added comments * (fix) style and updated comment * errorx: added future re-structuring comment * (fix) typo TLS alert code 51 * added comment * alert mapping: added comment * Update errorx.go * Update internal/engine/netx/errorx/errorx.go Co-authored-by: Simone Basso <bassosimone@gmail.com>
This commit is contained in:
@@ -23,9 +23,10 @@ func (d ErrorWrapperDialer) DialContext(
|
||||
err = errorx.SafeErrWrapperBuilder{
|
||||
// ConnID does not make any sense if we've failed and the error
|
||||
// does not make any sense (and is nil) if we succeeded.
|
||||
DialID: dialID,
|
||||
Error: err,
|
||||
Operation: errorx.QUICHandshakeOperation,
|
||||
Classifier: errorx.ClassifyQUICFailure,
|
||||
DialID: dialID,
|
||||
Error: err,
|
||||
Operation: errorx.QUICHandshakeOperation,
|
||||
}.MaybeBuild()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -44,6 +44,29 @@ func errorWrapperCheckErr(t *testing.T, err error, op string) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrorWrapperInvalidCertificate(t *testing.T) {
|
||||
nextprotos := []string{"h3"}
|
||||
servername := "example.com"
|
||||
tlsConf := &tls.Config{
|
||||
NextProtos: nextprotos,
|
||||
ServerName: servername,
|
||||
}
|
||||
|
||||
dlr := quicdialer.ErrorWrapperDialer{Dialer: &quicdialer.SystemDialer{}}
|
||||
// use Google IP
|
||||
sess, err := dlr.DialContext(context.Background(), "udp",
|
||||
"216.58.212.164:443", tlsConf, &quic.Config{})
|
||||
if err == nil {
|
||||
t.Fatal("expected an error here")
|
||||
}
|
||||
if sess != nil {
|
||||
t.Fatal("expected nil sess here")
|
||||
}
|
||||
if err.Error() != errorx.FailureSSLInvalidCertificate {
|
||||
t.Fatal("unexpected failure")
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrorWrapperSuccess(t *testing.T) {
|
||||
ctx := dialid.WithDialID(context.Background())
|
||||
tlsConf := &tls.Config{
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestHandshakeSaverSuccess(t *testing.T) {
|
||||
|
||||
func TestHandshakeSaverHostNameError(t *testing.T) {
|
||||
nextprotos := []string{"h3"}
|
||||
servername := "wrong.host.badssl.com"
|
||||
servername := "example.com"
|
||||
tlsConf := &tls.Config{
|
||||
NextProtos: nextprotos,
|
||||
ServerName: servername,
|
||||
|
||||
Reference in New Issue
Block a user