fix(quic): properly unwrap OONI errors from TransportError (#495)

Noticed while playing around with QUIC code.

Part of https://github.com/ooni/probe/issues/1544.
This commit is contained in:
Simone Basso 2021-09-09 00:07:38 +02:00 committed by GitHub
commit 00a85cb7f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 128 additions and 27 deletions

View file

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// Generated: 2021-09-07 20:42:20.172357 +0200 CEST m=+0.135433792
// Generated: 2021-09-08 23:09:33.336763 +0200 CEST m=+0.192836793
package errorsx
@ -60,6 +60,49 @@ const (
FailureJSONParseError = "json_parse_error"
)
// failureMap lists all failures so we can match them
// when they are wrapped by quic.TransportError.
var failuresMap = map[string]string{
"operation_canceled": "operation_canceled",
"connection_refused": "connection_refused",
"connection_reset": "connection_reset",
"host_unreachable": "host_unreachable",
"timed_out": "timed_out",
"address_family_not_supported": "address_family_not_supported",
"address_in_use": "address_in_use",
"address_not_available": "address_not_available",
"already_connected": "already_connected",
"bad_address": "bad_address",
"bad_file_descriptor": "bad_file_descriptor",
"connection_aborted": "connection_aborted",
"connection_already_in_progress": "connection_already_in_progress",
"destination_address_required": "destination_address_required",
"interrupted": "interrupted",
"invalid_argument": "invalid_argument",
"message_size": "message_size",
"network_down": "network_down",
"network_reset": "network_reset",
"network_unreachable": "network_unreachable",
"no_buffer_space": "no_buffer_space",
"no_protocol_option": "no_protocol_option",
"not_a_socket": "not_a_socket",
"not_connected": "not_connected",
"operation_would_block": "operation_would_block",
"permission_denied": "permission_denied",
"protocol_not_supported": "protocol_not_supported",
"wrong_protocol_type": "wrong_protocol_type",
"dns_bogon_error": "dns_bogon_error",
"dns_nxdomain_error": "dns_nxdomain_error",
"eof_error": "eof_error",
"generic_timeout_error": "generic_timeout_error",
"quic_incompatible_version": "quic_incompatible_version",
"ssl_failed_handshake": "ssl_failed_handshake",
"ssl_invalid_hostname": "ssl_invalid_hostname",
"ssl_unknown_authority": "ssl_unknown_authority",
"ssl_invalid_certificate": "ssl_invalid_certificate",
"json_parse_error": "json_parse_error",
}
// classifySyscallError converts a syscall error to the
// proper OONI error. Returns the OONI error string
// on success, an empty string otherwise.