errorsx

package
v3.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package errorsx contains error extensions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialer

type Dialer interface {
	// DialContext behaves like net.Dialer.DialContext.
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

Dialer establishes network connections.

type ErrorWrapperDialer

type ErrorWrapperDialer struct {
	// Dialer is the underlying dialer.
	Dialer
}

ErrorWrapperDialer is a dialer that performs error wrapping. The connection returned by the DialContext function will also perform error wrapping.

func (*ErrorWrapperDialer) DialContext

func (d *ErrorWrapperDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext implements Dialer.DialContext.

type ErrorWrapperQUICDialer

type ErrorWrapperQUICDialer struct {
	Dialer QUICContextDialer
}

ErrorWrapperQUICDialer is a dialer that performs quic err wrapping

func (*ErrorWrapperQUICDialer) DialContext

func (d *ErrorWrapperQUICDialer) DialContext(
	ctx context.Context, network string, host string,
	tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlySession, error)

DialContext implements ContextDialer.DialContext

type ErrorWrapperQUICListener

type ErrorWrapperQUICListener struct {
	// QUICListener is the underlying listener.
	QUICListener QUICListener
}

ErrorWrapperQUICListener is a QUICListener that wraps errors.

func (*ErrorWrapperQUICListener) Listen

Listen implements QUICListener.Listen.

type ErrorWrapperResolver

type ErrorWrapperResolver struct {
	Resolver
}

ErrorWrapperResolver is a Resolver that knows about wrapping errors.

func (*ErrorWrapperResolver) Address

func (r *ErrorWrapperResolver) Address() string

Address implements Resolver.Address.

func (*ErrorWrapperResolver) LookupHost

func (r *ErrorWrapperResolver) LookupHost(ctx context.Context, hostname string) ([]string, error)

LookupHost implements Resolver.LookupHost

func (*ErrorWrapperResolver) Network

func (r *ErrorWrapperResolver) Network() string

Network implements Resolver.Network.

type ErrorWrapperTLSHandshaker

type ErrorWrapperTLSHandshaker struct {
	TLSHandshaker
}

ErrorWrapperTLSHandshaker wraps the returned error to be an OONI error

func (*ErrorWrapperTLSHandshaker) Handshake

func (h *ErrorWrapperTLSHandshaker) Handshake(
	ctx context.Context, conn net.Conn, config *tls.Config,
) (net.Conn, tls.ConnectionState, error)

Handshake implements TLSHandshaker.Handshake

type QUICContextDialer

type QUICContextDialer interface {
	// DialContext establishes a new QUIC session using the given
	// network and address. The tlsConfig and the quicConfig arguments
	// MUST NOT be nil. Returns either the session or an error.
	DialContext(ctx context.Context, network, address string,
		tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error)
}

QUICContextDialer is a dialer for QUIC using Context.

type QUICListener

type QUICListener interface {
	// Listen creates a new listening UDPConn.
	Listen(addr *net.UDPAddr) (quicx.UDPLikeConn, error)
}

QUICListener listens for QUIC connections.

type Resolver

type Resolver interface {
	// LookupHost resolves a hostname to a list of IP addresses.
	LookupHost(ctx context.Context, hostname string) (addrs []string, err error)
}

Resolver is a DNS resolver. The *net.Resolver used by Go implements this interface, but other implementations are possible.

type SafeErrWrapperBuilder

type SafeErrWrapperBuilder struct {
	// Error is the error, if any
	Error error

	// Classifier is the local error to string classifier. When there is no
	// configured classifier we will use the generic classifier.
	Classifier func(err error) string

	// Operation is the operation that failed
	Operation string
}

SafeErrWrapperBuilder contains a builder for ErrWrapper that is safe, i.e., behaves correctly when the error is nil.

func (SafeErrWrapperBuilder) MaybeBuild

func (b SafeErrWrapperBuilder) MaybeBuild() (err error)

MaybeBuild builds a new ErrWrapper, if b.Error is not nil, and returns a nil error value, instead, if b.Error is nil.

type TLSHandshaker

type TLSHandshaker interface {
	Handshake(ctx context.Context, conn net.Conn, config *tls.Config) (
		net.Conn, tls.ConnectionState, error)
}

TLSHandshaker is the generic TLS handshaker

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL