fix(netxlite): prefer composition over embedding (#733)
This diff has been extracted and adapted from 8848c8c516
The reason to prefer composition over embedding is that we want the
build to break if we add new methods to interfaces we define. If the build
does not break, we may forget about wrapping methods we should
actually be wrapping. I noticed this issue inside netxlite when I was working
on websteps-illustrated and I added support for NS and PTR queries.
See https://github.com/ooni/probe/issues/2096
While there, perform comprehensive netxlite code review
and apply minor changes and improve the docs.
This commit is contained in:
parent
9d2301cae2
commit
c1b06a2d09
31 changed files with 328 additions and 92 deletions
|
|
@ -1,5 +1,9 @@
|
|||
package netxlite
|
||||
|
||||
//
|
||||
// Mapping Go errors to OONI errors
|
||||
//
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/x509"
|
||||
|
|
@ -38,8 +42,7 @@ func classifyGenericError(err error) string {
|
|||
// The list returned here matches the values used by MK unless
|
||||
// explicitly noted otherwise with a comment.
|
||||
|
||||
// QUIRK: we cannot remove this check as long as this function
|
||||
// is exported and used independently from NewErrWrapper.
|
||||
// Robustness: handle the case where we're passed a wrapped error.
|
||||
var errwrapper *ErrWrapper
|
||||
if errors.As(err, &errwrapper) {
|
||||
return errwrapper.Error() // we've already wrapped it
|
||||
|
|
@ -146,8 +149,7 @@ const (
|
|||
// and returns to the caller its return value.
|
||||
func classifyQUICHandshakeError(err error) string {
|
||||
|
||||
// QUIRK: we cannot remove this check as long as this function
|
||||
// is exported and used independently from NewErrWrapper.
|
||||
// Robustness: handle the case where we're passed a wrapped error.
|
||||
var errwrapper *ErrWrapper
|
||||
if errors.As(err, &errwrapper) {
|
||||
return errwrapper.Error() // we've already wrapped it
|
||||
|
|
@ -269,8 +271,7 @@ var (
|
|||
// returns to the caller its return value.
|
||||
func classifyResolverError(err error) string {
|
||||
|
||||
// QUIRK: we cannot remove this check as long as this function
|
||||
// is exported and used independently from NewErrWrapper.
|
||||
// Robustness: handle the case where we're passed a wrapped error.
|
||||
var errwrapper *ErrWrapper
|
||||
if errors.As(err, &errwrapper) {
|
||||
return errwrapper.Error() // we've already wrapped it
|
||||
|
|
@ -303,8 +304,7 @@ func classifyResolverError(err error) string {
|
|||
// returns to the caller its return value.
|
||||
func classifyTLSHandshakeError(err error) string {
|
||||
|
||||
// QUIRK: we cannot remove this check as long as this function
|
||||
// is exported and used independently from NewErrWrapper.
|
||||
// Robustness: handle the case where we're passed a wrapped error.
|
||||
var errwrapper *ErrWrapper
|
||||
if errors.As(err, &errwrapper) {
|
||||
return errwrapper.Error() // we've already wrapped it
|
||||
|
|
|
|||
Loading…
Reference in a new issue