dialer

package
v3.9.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextExperimentByteCounter

func ContextExperimentByteCounter(ctx context.Context) *bytecounter.Counter

ContextExperimentByteCounter retrieves the experiment byte counter from the context

func ContextProxyURL

func ContextProxyURL(ctx context.Context) *url.URL

ContextProxyURL retrieves the proxy URL from the context. This is mainly used to force a tunnel when we fail contacting OONI probe services otherwise.

func ContextSessionByteCounter

func ContextSessionByteCounter(ctx context.Context) *bytecounter.Counter

ContextSessionByteCounter retrieves the session byte counter from the context

func ReduceErrors

func ReduceErrors(errorslist []error) error

ReduceErrors finds a known error in a list of errors since it's probably most relevant

func WithExperimentByteCounter

func WithExperimentByteCounter(ctx context.Context, counter *bytecounter.Counter) context.Context

WithExperimentByteCounter assigns the experiment byte counter to the context

func WithProxyURL

func WithProxyURL(ctx context.Context, url *url.URL) context.Context

WithProxyURL assigns the proxy URL to the context

func WithSessionByteCounter

func WithSessionByteCounter(ctx context.Context, counter *bytecounter.Counter) context.Context

WithSessionByteCounter assigns the session byte counter to the context

Types

type ByteCounterDialer

type ByteCounterDialer struct {
	Dialer
}

ByteCounterDialer is a byte-counting-aware dialer. To perform byte counting, you should make sure that you insert this dialer in the dialing chain.

Bug

This implementation cannot properly account for the bytes that are sent by persistent connections, because they strick to the counters set when the connection was established. This typically means we miss the bytes sent and received when submitting a measurement. Such bytes are specifically not see by the experiment specific byte counter.

For this reason, this implementation may be heavily changed/removed.

func (ByteCounterDialer) DialContext

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

DialContext implements Dialer.DialContext

type DNSDialer

type DNSDialer struct {
	Dialer
	Resolver Resolver
}

DNSDialer is a dialer that uses the configured Resolver to resolver a domain name to IP addresses, and the configured Dialer to connect.

func (DNSDialer) DialContext

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

DialContext implements Dialer.DialContext.

func (DNSDialer) LookupHost

func (d DNSDialer) LookupHost(ctx context.Context, hostname string) ([]string, error)

LookupHost implements Resolver.LookupHost

type Dialer

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

Dialer is the interface we expect from a dialer

type EmitterConn

type EmitterConn struct {
	net.Conn
	Beginning time.Time
	Handler   modelx.Handler
	ID        int64
}

EmitterConn is a net.Conn used to emit events

func (EmitterConn) Close

func (c EmitterConn) Close() (err error)

Close implements net.Conn.Close

func (EmitterConn) Read

func (c EmitterConn) Read(b []byte) (n int, err error)

Read implements net.Conn.Read

func (EmitterConn) Write

func (c EmitterConn) Write(b []byte) (n int, err error)

Write implements net.Conn.Write

type EmitterDialer

type EmitterDialer struct {
	Dialer
}

EmitterDialer is a Dialer that emits events

func (EmitterDialer) DialContext

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

DialContext implements Dialer.DialContext

type EmitterTLSHandshaker

type EmitterTLSHandshaker struct {
	TLSHandshaker
}

EmitterTLSHandshaker emits events using the MeasurementRoot

func (EmitterTLSHandshaker) Handshake

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

Handshake implements Handshaker.Handshake

type ErrorWrapperConn

type ErrorWrapperConn struct {
	net.Conn
	ConnID int64
	DialID int64
}

ErrorWrapperConn is a net.Conn that performs error wrapping.

func (ErrorWrapperConn) Close

func (c ErrorWrapperConn) Close() (err error)

Close implements net.Conn.Close

func (ErrorWrapperConn) Read

func (c ErrorWrapperConn) Read(b []byte) (n int, err error)

Read implements net.Conn.Read

func (ErrorWrapperConn) Write

func (c ErrorWrapperConn) Write(b []byte) (n int, err error)

Write implements net.Conn.Write

type ErrorWrapperDialer

type ErrorWrapperDialer struct {
	Dialer
}

ErrorWrapperDialer is a dialer that performs err wrapping

func (ErrorWrapperDialer) DialContext

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

DialContext implements Dialer.DialContext

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 Handshaker.Handshake

type Logger

type Logger interface {
	Debugf(format string, v ...interface{})
	Debug(message string)
}

Logger is the logger assumed by this package

type LoggingDialer

type LoggingDialer struct {
	Dialer
	Logger Logger
}

LoggingDialer is a Dialer with logging

func (LoggingDialer) DialContext

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

DialContext implements Dialer.DialContext

type LoggingTLSHandshaker

type LoggingTLSHandshaker struct {
	TLSHandshaker
	Logger Logger
}

LoggingTLSHandshaker is a TLSHandshaker with logging

func (LoggingTLSHandshaker) Handshake

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

Handshake implements Handshaker.Handshake

type ProxyDialer

type ProxyDialer struct {
	Dialer
	ProxyURL *url.URL
}

ProxyDialer is a dialer that uses a proxy. If the ProxyURL is not configured, this dialer is a passthrough for the next Dialer in chain. Otherwise, it will internally create a SOCKS5 dialer that will connect to the proxy using the underlying Dialer.

As a special case, you can force a proxy to be used only extemporarily. To this end, you can use the WithProxyURL function, to store the proxy URL in the context. This will take precedence over any otherwise configured proxy. The use case for this functionality is when you need a tunnel to contact OONI probe services.

func (ProxyDialer) DialContext

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

DialContext implements Dialer.DialContext

type Resolver

type Resolver interface {
	LookupHost(ctx context.Context, hostname string) (addrs []string, err error)
}

Resolver is the interface we expect from a resolver

type SaverConnDialer

type SaverConnDialer struct {
	Dialer
	Saver *trace.Saver
}

SaverConnDialer wraps the returned connection such that we collect all the read/write events that occur.

func (SaverConnDialer) DialContext

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

DialContext implements Dialer.DialContext

type SaverDialer

type SaverDialer struct {
	Dialer
	Saver *trace.Saver
}

SaverDialer saves events occurring during the dial

func (SaverDialer) DialContext

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

DialContext implements Dialer.DialContext

type SaverTLSHandshaker

type SaverTLSHandshaker struct {
	TLSHandshaker
	Saver *trace.Saver
}

SaverTLSHandshaker saves events occurring during the handshake

func (SaverTLSHandshaker) Handshake

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

Handshake implements TLSHandshaker.Handshake

type ShapingDialer

type ShapingDialer struct {
	Dialer
}

ShapingDialer ensures we don't use too much bandwidth when using integration tests at GitHub. To select the implementation with shaping use `-tags shaping`.

func (ShapingDialer) DialContext

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

DialContext implements Dialer.DialContext

type SystemTLSHandshaker

type SystemTLSHandshaker struct{}

SystemTLSHandshaker is the system TLS handshaker.

func (SystemTLSHandshaker) Handshake

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

Handshake implements Handshaker.Handshake

type TLSDialer

type TLSDialer struct {
	Config        *tls.Config
	Dialer        Dialer
	TLSHandshaker TLSHandshaker
}

TLSDialer is the TLS dialer

func (TLSDialer) DialTLSContext

func (d TLSDialer) DialTLSContext(ctx context.Context, network, address string) (net.Conn, error)

DialTLSContext is like tls.DialTLS but with the signature of net.Dialer.DialContext

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

type TimeoutDialer

type TimeoutDialer struct {
	Dialer
	ConnectTimeout time.Duration // default: 30 seconds
}

TimeoutDialer is a Dialer that enforces a timeout

func (TimeoutDialer) DialContext

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

DialContext implements Dialer.DialContext

type TimeoutTLSHandshaker

type TimeoutTLSHandshaker struct {
	TLSHandshaker
	HandshakeTimeout time.Duration // default: 10 second
}

TimeoutTLSHandshaker is a TLSHandshaker with timeout

func (TimeoutTLSHandshaker) Handshake

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

Handshake implements Handshaker.Handshake

Jump to

Keyboard shortcuts

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