mocks

package
v3.16.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package mocks contains mocks for internal/model interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr struct {
	MockString  func() string
	MockNetwork func() string
}

Addr allows mocking net.Addr.

func (*Addr) Network

func (a *Addr) Network() string

Network calls MockNetwork.

func (*Addr) String

func (a *Addr) String() string

String calls MockString.

type Conn

type Conn struct {
	MockRead             func(b []byte) (int, error)
	MockWrite            func(b []byte) (int, error)
	MockClose            func() error
	MockLocalAddr        func() net.Addr
	MockRemoteAddr       func() net.Addr
	MockSetDeadline      func(t time.Time) error
	MockSetReadDeadline  func(t time.Time) error
	MockSetWriteDeadline func(t time.Time) error
}

Conn is a mockable net.Conn.

func (*Conn) Close

func (c *Conn) Close() error

Close calls MockClose.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr calls MockLocalAddr.

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

Read calls MockRead.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr calls MockRemoteAddr.

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline calls MockSetDeadline.

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline calls MockSetReadDeadline.

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline calls MockSetWriteDeadline.

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

Write calls MockWrite.

type DNSDecoder

type DNSDecoder struct {
	MockDecodeResponse func(data []byte, query model.DNSQuery) (model.DNSResponse, error)
}

DNSDecoder allows mocking model.DNSDecoder.

func (*DNSDecoder) DecodeResponse added in v3.16.0

func (e *DNSDecoder) DecodeResponse(data []byte, query model.DNSQuery) (model.DNSResponse, error)

type DNSEncoder

type DNSEncoder struct {
	MockEncode func(domain string, qtype uint16, padding bool) model.DNSQuery
}

DNSEncoder allows mocking model.DNSEncoder.

func (*DNSEncoder) Encode

func (e *DNSEncoder) Encode(domain string, qtype uint16, padding bool) model.DNSQuery

Encode calls MockEncode.

type DNSQuery added in v3.16.0

type DNSQuery struct {
	MockDomain func() string
	MockType   func() uint16
	MockBytes  func() ([]byte, error)
	MockID     func() uint16
}

DNSQuery allocks mocking model.DNSQuery.

func (*DNSQuery) Bytes added in v3.16.0

func (q *DNSQuery) Bytes() ([]byte, error)

func (*DNSQuery) Domain added in v3.16.0

func (q *DNSQuery) Domain() string

func (*DNSQuery) ID added in v3.16.0

func (q *DNSQuery) ID() uint16

func (*DNSQuery) Type added in v3.16.0

func (q *DNSQuery) Type() uint16

type DNSResponse added in v3.16.0

type DNSResponse struct {
	MockQuery            func() model.DNSQuery
	MockBytes            func() []byte
	MockRcode            func() int
	MockDecodeHTTPS      func() (*model.HTTPSSvc, error)
	MockDecodeLookupHost func() ([]string, error)
	MockDecodeNS         func() ([]*net.NS, error)
	MockDecodeCNAME      func() (string, error)
}

DNSResponse allows mocking model.DNSResponse.

func (*DNSResponse) Bytes added in v3.16.0

func (r *DNSResponse) Bytes() []byte

func (*DNSResponse) DecodeCNAME added in v3.16.0

func (r *DNSResponse) DecodeCNAME() (string, error)

func (*DNSResponse) DecodeHTTPS added in v3.16.0

func (r *DNSResponse) DecodeHTTPS() (*model.HTTPSSvc, error)

func (*DNSResponse) DecodeLookupHost added in v3.16.0

func (r *DNSResponse) DecodeLookupHost() ([]string, error)

func (*DNSResponse) DecodeNS added in v3.16.0

func (r *DNSResponse) DecodeNS() ([]*net.NS, error)

func (*DNSResponse) Query added in v3.16.0

func (r *DNSResponse) Query() model.DNSQuery

func (*DNSResponse) Rcode added in v3.16.0

func (r *DNSResponse) Rcode() int

type DNSTransport

type DNSTransport struct {
	MockRoundTrip func(ctx context.Context, query model.DNSQuery) (model.DNSResponse, error)

	MockRequiresPadding func() bool

	MockNetwork func() string

	MockAddress func() string

	MockCloseIdleConnections func()
}

DNSTransport allows mocking dnsx.DNSTransport.

func (*DNSTransport) Address

func (txp *DNSTransport) Address() string

Address calls MockAddress.

func (*DNSTransport) CloseIdleConnections

func (txp *DNSTransport) CloseIdleConnections()

CloseIdleConnections calls MockCloseIdleConnections.

func (*DNSTransport) Network

func (txp *DNSTransport) Network() string

Network calls MockNetwork.

func (*DNSTransport) RequiresPadding

func (txp *DNSTransport) RequiresPadding() bool

RequiresPadding calls MockRequiresPadding.

func (*DNSTransport) RoundTrip

func (txp *DNSTransport) RoundTrip(ctx context.Context, query model.DNSQuery) (model.DNSResponse, error)

RoundTrip calls MockRoundTrip.

type Dialer

type Dialer struct {
	MockDialContext          func(ctx context.Context, network, address string) (net.Conn, error)
	MockCloseIdleConnections func()
}

Dialer is a mockable Dialer.

func (*Dialer) CloseIdleConnections

func (d *Dialer) CloseIdleConnections()

CloseIdleConnections calls MockCloseIdleConnections.

func (*Dialer) DialContext

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

DialContext calls MockDialContext.

type Experiment added in v3.16.0

type Experiment struct {
	MockKibiBytesReceived func() float64

	MockKibiBytesSent func() float64

	MockName func() string

	MockGetSummaryKeys func(m *model.Measurement) (any, error)

	MockReportID func() string

	MockMeasureAsync func(ctx context.Context, input string) (<-chan *model.Measurement, error)

	MockMeasureWithContext func(
		ctx context.Context, input string) (measurement *model.Measurement, err error)

	MockSaveMeasurement func(measurement *model.Measurement, filePath string) error

	MockSubmitAndUpdateMeasurementContext func(
		ctx context.Context, measurement *model.Measurement) error

	MockOpenReportContext func(ctx context.Context) error
}

Experiment mocks model.Experiment

func (*Experiment) GetSummaryKeys added in v3.16.0

func (e *Experiment) GetSummaryKeys(m *model.Measurement) (any, error)

func (*Experiment) KibiBytesReceived added in v3.16.0

func (e *Experiment) KibiBytesReceived() float64

func (*Experiment) KibiBytesSent added in v3.16.0

func (e *Experiment) KibiBytesSent() float64

func (*Experiment) MeasureAsync added in v3.16.0

func (e *Experiment) MeasureAsync(
	ctx context.Context, input string) (<-chan *model.Measurement, error)

func (*Experiment) MeasureWithContext added in v3.16.0

func (e *Experiment) MeasureWithContext(
	ctx context.Context, input string) (measurement *model.Measurement, err error)

func (*Experiment) Name added in v3.16.0

func (e *Experiment) Name() string

func (*Experiment) OpenReportContext added in v3.16.0

func (e *Experiment) OpenReportContext(ctx context.Context) error

func (*Experiment) ReportID added in v3.16.0

func (e *Experiment) ReportID() string

func (*Experiment) SaveMeasurement added in v3.16.0

func (e *Experiment) SaveMeasurement(measurement *model.Measurement, filePath string) error

func (*Experiment) SubmitAndUpdateMeasurementContext added in v3.16.0

func (e *Experiment) SubmitAndUpdateMeasurementContext(
	ctx context.Context, measurement *model.Measurement) error

type ExperimentBuilder added in v3.16.0

type ExperimentBuilder struct {
	MockInterruptible func() bool

	MockInputPolicy func() model.InputPolicy

	MockOptions func() (map[string]model.ExperimentOptionInfo, error)

	MockSetOptionAny func(key string, value any) error

	MockSetOptionsAny func(options map[string]any) error

	MockSetCallbacks func(callbacks model.ExperimentCallbacks)

	MockNewExperiment func() model.Experiment
}

ExperimentBuilder mocks model.ExperimentBuilder.

func (*ExperimentBuilder) InputPolicy added in v3.16.0

func (eb *ExperimentBuilder) InputPolicy() model.InputPolicy

func (*ExperimentBuilder) Interruptible added in v3.16.0

func (eb *ExperimentBuilder) Interruptible() bool

func (*ExperimentBuilder) NewExperiment added in v3.16.0

func (eb *ExperimentBuilder) NewExperiment() model.Experiment

func (*ExperimentBuilder) Options added in v3.16.0

func (*ExperimentBuilder) SetCallbacks added in v3.16.0

func (eb *ExperimentBuilder) SetCallbacks(callbacks model.ExperimentCallbacks)

func (*ExperimentBuilder) SetOptionAny added in v3.16.0

func (eb *ExperimentBuilder) SetOptionAny(key string, value any) error

func (*ExperimentBuilder) SetOptionsAny added in v3.16.0

func (eb *ExperimentBuilder) SetOptionsAny(options map[string]any) error

type ExperimentInputLoader added in v3.16.0

type ExperimentInputLoader struct {
	MockLoad func(ctx context.Context) ([]model.OOAPIURLInfo, error)
}

ExperimentInputLoader mocks model.ExperimentInputLoader

func (*ExperimentInputLoader) Load added in v3.16.0

Load calls MockLoad

type ExperimentInputProcessor added in v3.16.0

type ExperimentInputProcessor struct {
	MockRun func(ctx context.Context) error
}

ExperimentInputProcessor processes inputs running the given experiment.

func (*ExperimentInputProcessor) Run added in v3.16.0

type HTTPClient

type HTTPClient struct {
	MockDo func(req *http.Request) (*http.Response, error)

	MockCloseIdleConnections func()
}

HTTPClient allows mocking an http.Client.

func (*HTTPClient) CloseIdleConnections

func (txp *HTTPClient) CloseIdleConnections()

CloseIdleConnections calls MockCloseIdleConnections.

func (*HTTPClient) Do

func (txp *HTTPClient) Do(req *http.Request) (*http.Response, error)

Do calls MockDo.

type HTTPResponseWriter added in v3.16.0

type HTTPResponseWriter struct {
	MockHeader func() http.Header

	MockWrite func(b []byte) (int, error)

	MockWriteHeader func(statusCode int)
}

HTTPResponseWriter allows mocking http.ResponseWriter.

func (*HTTPResponseWriter) Header added in v3.16.0

func (w *HTTPResponseWriter) Header() http.Header

func (*HTTPResponseWriter) Write added in v3.16.0

func (w *HTTPResponseWriter) Write(b []byte) (int, error)

func (*HTTPResponseWriter) WriteHeader added in v3.16.0

func (w *HTTPResponseWriter) WriteHeader(statusCode int)

type HTTPTransport

type HTTPTransport struct {
	MockNetwork              func() string
	MockRoundTrip            func(req *http.Request) (*http.Response, error)
	MockCloseIdleConnections func()
}

HTTPTransport mocks netxlite.HTTPTransport.

func (*HTTPTransport) CloseIdleConnections

func (txp *HTTPTransport) CloseIdleConnections()

CloseIdleConnections calls MockCloseIdleConnections.

func (*HTTPTransport) Network

func (txp *HTTPTransport) Network() string

Network calls MockNetwork.

func (*HTTPTransport) RoundTrip

func (txp *HTTPTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip calls MockRoundTrip.

type KeyValueStore added in v3.16.0

type KeyValueStore struct {
	MockGet func(key string) (value []byte, err error)

	MockSet func(key string, value []byte) (err error)
}

KeyValueStore allows mocking model.KeyValueStore.

func (*KeyValueStore) Get added in v3.16.0

func (kvs *KeyValueStore) Get(key string) (value []byte, err error)

func (*KeyValueStore) Set added in v3.16.0

func (kvs *KeyValueStore) Set(key string, value []byte) (err error)

type Listener

type Listener struct {
	// Accept allows mocking Accept.
	MockAccept func() (net.Conn, error)

	// Close allows mocking Close.
	MockClose func() error

	// Addr allows mocking Addr.
	MockAddr func() net.Addr
}

Listener allows mocking a net.Listener.

func (*Listener) Accept

func (li *Listener) Accept() (net.Conn, error)

Accept implements net.Listener.Accept

func (*Listener) Addr

func (li *Listener) Addr() net.Addr

Addr implements net.Listener.Addr

func (*Listener) Close

func (li *Listener) Close() error

Close implements net.Listener.Closer.

type Logger

type Logger struct {
	MockDebug  func(message string)
	MockDebugf func(format string, v ...interface{})
	MockInfo   func(message string)
	MockInfof  func(format string, v ...interface{})
	MockWarn   func(message string)
	MockWarnf  func(format string, v ...interface{})
}

Logger allows mocking a logger.

func (*Logger) Debug

func (lo *Logger) Debug(message string)

Debug calls MockDebug.

func (*Logger) Debugf

func (lo *Logger) Debugf(format string, v ...interface{})

Debugf calls MockDebugf.

func (*Logger) Info added in v3.15.0

func (lo *Logger) Info(message string)

Info calls MockInfo.

func (*Logger) Infof added in v3.15.0

func (lo *Logger) Infof(format string, v ...interface{})

Infof calls MockInfof.

func (*Logger) Warn added in v3.15.0

func (lo *Logger) Warn(message string)

Warn calls MockWarn.

func (*Logger) Warnf added in v3.15.0

func (lo *Logger) Warnf(format string, v ...interface{})

Warnf calls MockWarnf.

type QUICDialer

type QUICDialer struct {
	// MockDialContext allows mocking DialContext.
	MockDialContext func(ctx context.Context, address string,
		tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error)

	// MockCloseIdleConnections allows mocking CloseIdleConnections.
	MockCloseIdleConnections func()
}

QUICDialer is a mockable netxlite.QUICDialer.

func (*QUICDialer) CloseIdleConnections

func (qcd *QUICDialer) CloseIdleConnections()

CloseIdleConnections calls MockCloseIdleConnections.

func (*QUICDialer) DialContext

func (qcd *QUICDialer) DialContext(ctx context.Context, address string,
	tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error)

DialContext calls MockDialContext.

type QUICEarlyConnection added in v3.15.0

type QUICEarlyConnection struct {
	MockAcceptStream      func(context.Context) (quic.Stream, error)
	MockAcceptUniStream   func(context.Context) (quic.ReceiveStream, error)
	MockOpenStream        func() (quic.Stream, error)
	MockOpenStreamSync    func(ctx context.Context) (quic.Stream, error)
	MockOpenUniStream     func() (quic.SendStream, error)
	MockOpenUniStreamSync func(ctx context.Context) (quic.SendStream, error)
	MockLocalAddr         func() net.Addr
	MockRemoteAddr        func() net.Addr
	MockCloseWithError    func(code quic.ApplicationErrorCode, reason string) error
	MockContext           func() context.Context
	MockConnectionState   func() quic.ConnectionState
	MockHandshakeComplete func() context.Context
	MockNextConnection    func() quic.Connection
	MockSendMessage       func(b []byte) error
	MockReceiveMessage    func() ([]byte, error)
}

QUICEarlyConnection is a mockable quic.EarlyConnection.

func (*QUICEarlyConnection) AcceptStream added in v3.15.0

func (s *QUICEarlyConnection) AcceptStream(ctx context.Context) (quic.Stream, error)

AcceptStream calls MockAcceptStream.

func (*QUICEarlyConnection) AcceptUniStream added in v3.15.0

func (s *QUICEarlyConnection) AcceptUniStream(ctx context.Context) (quic.ReceiveStream, error)

AcceptUniStream calls MockAcceptUniStream.

func (*QUICEarlyConnection) CloseWithError added in v3.15.0

func (c *QUICEarlyConnection) CloseWithError(
	code quic.ApplicationErrorCode, reason string) error

CloseWithError calls MockCloseWithError.

func (*QUICEarlyConnection) ConnectionState added in v3.15.0

func (s *QUICEarlyConnection) ConnectionState() quic.ConnectionState

ConnectionState calls MockConnectionState.

func (*QUICEarlyConnection) Context added in v3.15.0

func (s *QUICEarlyConnection) Context() context.Context

Context calls MockContext.

func (*QUICEarlyConnection) HandshakeComplete added in v3.15.0

func (s *QUICEarlyConnection) HandshakeComplete() context.Context

HandshakeComplete calls MockHandshakeComplete.

func (*QUICEarlyConnection) LocalAddr added in v3.15.0

func (c *QUICEarlyConnection) LocalAddr() net.Addr

LocalAddr class MockLocalAddr.

func (*QUICEarlyConnection) NextConnection added in v3.15.0

func (s *QUICEarlyConnection) NextConnection() quic.Connection

NextConnection calls MockNextConnection.

func (*QUICEarlyConnection) OpenStream added in v3.15.0

func (s *QUICEarlyConnection) OpenStream() (quic.Stream, error)

OpenStream calls MockOpenStream.

func (*QUICEarlyConnection) OpenStreamSync added in v3.15.0

func (s *QUICEarlyConnection) OpenStreamSync(ctx context.Context) (quic.Stream, error)

OpenStreamSync calls MockOpenStreamSync.

func (*QUICEarlyConnection) OpenUniStream added in v3.15.0

func (s *QUICEarlyConnection) OpenUniStream() (quic.SendStream, error)

OpenUniStream calls MockOpenUniStream.

func (*QUICEarlyConnection) OpenUniStreamSync added in v3.15.0

func (s *QUICEarlyConnection) OpenUniStreamSync(ctx context.Context) (quic.SendStream, error)

OpenUniStreamSync calls MockOpenUniStreamSync.

func (*QUICEarlyConnection) ReceiveMessage added in v3.15.0

func (s *QUICEarlyConnection) ReceiveMessage() ([]byte, error)

ReceiveMessage calls MockReceiveMessage.

func (*QUICEarlyConnection) RemoteAddr added in v3.15.0

func (c *QUICEarlyConnection) RemoteAddr() net.Addr

RemoteAddr calls MockRemoteAddr.

func (*QUICEarlyConnection) SendMessage added in v3.15.0

func (s *QUICEarlyConnection) SendMessage(b []byte) error

SendMessage calls MockSendMessage.

type QUICListener

type QUICListener struct {
	MockListen func(addr *net.UDPAddr) (model.UDPLikeConn, error)
}

QUICListener is a mockable netxlite.QUICListener.

func (*QUICListener) Listen

func (ql *QUICListener) Listen(addr *net.UDPAddr) (model.UDPLikeConn, error)

Listen calls MockListen.

type Reader

type Reader struct {
	MockRead func(b []byte) (int, error)
}

Reader allows to mock any io.Reader.

func (*Reader) Read

func (r *Reader) Read(b []byte) (int, error)

Read implements io.Reader.Read.

type Resolver

type Resolver struct {
	MockLookupHost           func(ctx context.Context, domain string) ([]string, error)
	MockNetwork              func() string
	MockAddress              func() string
	MockCloseIdleConnections func()
	MockLookupHTTPS          func(ctx context.Context, domain string) (*model.HTTPSSvc, error)
	MockLookupNS             func(ctx context.Context, domain string) ([]*net.NS, error)
}

Resolver is a mockable Resolver.

func (*Resolver) Address

func (r *Resolver) Address() string

Address calls MockAddress.

func (*Resolver) CloseIdleConnections

func (r *Resolver) CloseIdleConnections()

CloseIdleConnections calls MockCloseIdleConnections.

func (*Resolver) LookupHTTPS

func (r *Resolver) LookupHTTPS(ctx context.Context, domain string) (*model.HTTPSSvc, error)

LookupHTTPS calls MockLookupHTTPS.

func (*Resolver) LookupHost

func (r *Resolver) LookupHost(ctx context.Context, domain string) ([]string, error)

LookupHost calls MockLookupHost.

func (*Resolver) LookupNS added in v3.15.0

func (r *Resolver) LookupNS(ctx context.Context, domain string) ([]*net.NS, error)

LookupNS calls MockLookupNS.

func (*Resolver) Network

func (r *Resolver) Network() string

Network calls MockNetwork.

type Saver added in v3.16.0

type Saver struct {
	MockSaveMeasurement func(m *model.Measurement) error
}

Saver saves a measurement on some persistent storage.

func (*Saver) SaveMeasurement added in v3.16.0

func (s *Saver) SaveMeasurement(m *model.Measurement) error

type Session added in v3.16.0

type Session struct {
	MockGetTestHelpersByName func(name string) ([]model.OOAPIService, bool)

	MockDefaultHTTPClient func() model.HTTPClient

	MockFetchPsiphonConfig func(ctx context.Context) ([]byte, error)

	MockFetchTorTargets func(
		ctx context.Context, cc string) (map[string]model.OOAPITorTarget, error)

	MockFetchURLList func(
		ctx context.Context, config model.OOAPIURLListConfig) ([]model.OOAPIURLInfo, error)

	MockKeyValueStore func() model.KeyValueStore

	MockLogger func() model.Logger

	MockMaybeResolverIP func() string

	MockProbeASNString func() string

	MockProbeCC func() string

	MockProbeIP func() string

	MockProbeNetworkName func() string

	MockProxyURL func() *url.URL

	MockResolverIP func() string

	MockSoftwareName func() string

	MockSoftwareVersion func() string

	MockTempDir func() string

	MockTorArgs func() []string

	MockTorBinary func() string

	MockTunnelDir func() string

	MockUserAgent func() string

	MockNewExperimentBuilder func(name string) (model.ExperimentBuilder, error)

	MockNewSubmitter func(ctx context.Context) (model.Submitter, error)

	MockCheckIn func(ctx context.Context,
		config *model.OOAPICheckInConfig) (*model.OOAPICheckInInfo, error)
}

Session allows to mock sessions.

func (*Session) CheckIn added in v3.16.0

func (sess *Session) CheckIn(ctx context.Context,
	config *model.OOAPICheckInConfig) (*model.OOAPICheckInInfo, error)

func (*Session) DefaultHTTPClient added in v3.16.0

func (sess *Session) DefaultHTTPClient() model.HTTPClient

func (*Session) FetchPsiphonConfig added in v3.16.0

func (sess *Session) FetchPsiphonConfig(ctx context.Context) ([]byte, error)

func (*Session) FetchTorTargets added in v3.16.0

func (sess *Session) FetchTorTargets(
	ctx context.Context, cc string) (map[string]model.OOAPITorTarget, error)

func (*Session) FetchURLList added in v3.16.0

func (sess *Session) FetchURLList(
	ctx context.Context, config model.OOAPIURLListConfig) ([]model.OOAPIURLInfo, error)

func (*Session) GetTestHelpersByName added in v3.16.0

func (sess *Session) GetTestHelpersByName(name string) ([]model.OOAPIService, bool)

func (*Session) KeyValueStore added in v3.16.0

func (sess *Session) KeyValueStore() model.KeyValueStore

func (*Session) Logger added in v3.16.0

func (sess *Session) Logger() model.Logger

func (*Session) MaybeResolverIP added in v3.16.0

func (sess *Session) MaybeResolverIP() string

func (*Session) NewExperimentBuilder added in v3.16.0

func (sess *Session) NewExperimentBuilder(name string) (model.ExperimentBuilder, error)

func (*Session) NewSubmitter added in v3.16.0

func (sess *Session) NewSubmitter(ctx context.Context) (model.Submitter, error)

func (*Session) ProbeASNString added in v3.16.0

func (sess *Session) ProbeASNString() string

func (*Session) ProbeCC added in v3.16.0

func (sess *Session) ProbeCC() string

func (*Session) ProbeIP added in v3.16.0

func (sess *Session) ProbeIP() string

func (*Session) ProbeNetworkName added in v3.16.0

func (sess *Session) ProbeNetworkName() string

func (*Session) ProxyURL added in v3.16.0

func (sess *Session) ProxyURL() *url.URL

func (*Session) ResolverIP added in v3.16.0

func (sess *Session) ResolverIP() string

func (*Session) SoftwareName added in v3.16.0

func (sess *Session) SoftwareName() string

func (*Session) SoftwareVersion added in v3.16.0

func (sess *Session) SoftwareVersion() string

func (*Session) TempDir added in v3.16.0

func (sess *Session) TempDir() string

func (*Session) TorArgs added in v3.16.0

func (sess *Session) TorArgs() []string

func (*Session) TorBinary added in v3.16.0

func (sess *Session) TorBinary() string

func (*Session) TunnelDir added in v3.16.0

func (sess *Session) TunnelDir() string

func (*Session) UserAgent added in v3.16.0

func (sess *Session) UserAgent() string

type Submitter added in v3.16.0

type Submitter struct {
	MockSubmit func(ctx context.Context, m *model.Measurement) error
}

Submitter mocks model.Submitter.

func (*Submitter) Submit added in v3.16.0

func (s *Submitter) Submit(ctx context.Context, m *model.Measurement) error

Submit calls MockSubmit

type TLSConn

type TLSConn struct {
	// Conn is the embedded mockable Conn.
	Conn

	// MockConnectionState allows to mock the ConnectionState method.
	MockConnectionState func() tls.ConnectionState

	// MockHandshakeContext allows to mock the HandshakeContext method.
	MockHandshakeContext func(ctx context.Context) error

	// MockNetConn returns the underlying net.Conn
	MockNetConn func() net.Conn
}

TLSConn allows to mock netxlite.TLSConn.

func (*TLSConn) ConnectionState

func (c *TLSConn) ConnectionState() tls.ConnectionState

ConnectionState calls MockConnectionState.

func (*TLSConn) HandshakeContext

func (c *TLSConn) HandshakeContext(ctx context.Context) error

HandshakeContext calls MockHandshakeContext.

func (*TLSConn) NetConn added in v3.16.0

func (c *TLSConn) NetConn() net.Conn

NetConn calls MockNetConn.

type TLSDialer

type TLSDialer struct {
	// MockCloseIdleConnections allows to mock the CloseIdleConnections method.
	MockCloseIdleConnections func()

	// MockDialTLSContext allows to mock the DialTLSContext method.
	MockDialTLSContext func(ctx context.Context, network, address string) (net.Conn, error)
}

TLSDialer allows to mock netxlite.TLSDialer.

func (*TLSDialer) CloseIdleConnections

func (d *TLSDialer) CloseIdleConnections()

CloseIdleConnections calls MockCloseIdleConnections.

func (*TLSDialer) DialTLSContext

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

DialTLSContext calls MockDialTLSContext.

type TLSHandshaker

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

TLSHandshaker is a mockable TLS handshaker.

func (*TLSHandshaker) Handshake

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

Handshake calls MockHandshake.

type Trace added in v3.16.0

type Trace struct {
	MockTimeNow func() time.Time

	MockMaybeWrapNetConn func(conn net.Conn) net.Conn

	MockMaybeWrapUDPLikeConn func(conn model.UDPLikeConn) model.UDPLikeConn

	MockOnDNSRoundTripForLookupHost func(started time.Time, reso model.Resolver, query model.DNSQuery,
		response model.DNSResponse, addrs []string, err error, finished time.Time)

	MockOnDelayedDNSResponse func(started time.Time, txp model.DNSTransport, query model.DNSQuery,
		response model.DNSResponse, addrs []string, err error, finished time.Time) error

	MockOnConnectDone func(
		started time.Time, network, domain, remoteAddr string, err error, finished time.Time)

	MockOnTLSHandshakeStart func(now time.Time, remoteAddr string, config *tls.Config)

	MockOnTLSHandshakeDone func(started time.Time, remoteAddr string, config *tls.Config,
		state tls.ConnectionState, err error, finished time.Time)

	MockOnQUICHandshakeStart func(now time.Time, remoteAddrs string, config *quic.Config)

	MockOnQUICHandshakeDone func(started time.Time, remoteAddr string, qconn quic.EarlyConnection,
		config *tls.Config, err error, finished time.Time)
}

Trace allows mocking model.Trace.

func (*Trace) MaybeWrapNetConn added in v3.16.0

func (t *Trace) MaybeWrapNetConn(conn net.Conn) net.Conn

func (*Trace) MaybeWrapUDPLikeConn added in v3.16.0

func (t *Trace) MaybeWrapUDPLikeConn(conn model.UDPLikeConn) model.UDPLikeConn

func (*Trace) OnConnectDone added in v3.16.0

func (t *Trace) OnConnectDone(
	started time.Time, network, domain, remoteAddr string, err error, finished time.Time)

func (*Trace) OnDNSRoundTripForLookupHost added in v3.16.0

func (t *Trace) OnDNSRoundTripForLookupHost(started time.Time, reso model.Resolver, query model.DNSQuery,
	response model.DNSResponse, addrs []string, err error, finished time.Time)

func (*Trace) OnDelayedDNSResponse added in v3.16.0

func (t *Trace) OnDelayedDNSResponse(started time.Time, txp model.DNSTransport, query model.DNSQuery,
	response model.DNSResponse, addrs []string, err error, finished time.Time) error

func (*Trace) OnQUICHandshakeDone added in v3.16.0

func (t *Trace) OnQUICHandshakeDone(started time.Time, remoteAddr string, qconn quic.EarlyConnection,
	config *tls.Config, err error, finished time.Time)

func (*Trace) OnQUICHandshakeStart added in v3.16.0

func (t *Trace) OnQUICHandshakeStart(now time.Time, remoteAddr string, config *quic.Config)

func (*Trace) OnTLSHandshakeDone added in v3.16.0

func (t *Trace) OnTLSHandshakeDone(started time.Time, remoteAddr string, config *tls.Config,
	state tls.ConnectionState, err error, finished time.Time)

func (*Trace) OnTLSHandshakeStart added in v3.16.0

func (t *Trace) OnTLSHandshakeStart(now time.Time, remoteAddr string, config *tls.Config)

func (*Trace) TimeNow added in v3.16.0

func (t *Trace) TimeNow() time.Time

type UDPLikeConn

type UDPLikeConn struct {
	MockWriteTo          func(p []byte, addr net.Addr) (int, error)
	MockClose            func() error
	MockLocalAddr        func() net.Addr
	MockRemoteAddr       func() net.Addr
	MockSetDeadline      func(t time.Time) error
	MockSetReadDeadline  func(t time.Time) error
	MockSetWriteDeadline func(t time.Time) error
	MockReadFrom         func(p []byte) (int, net.Addr, error)
	MockSyscallConn      func() (syscall.RawConn, error)
	MockSetReadBuffer    func(n int) error
}

UDPLikeConn is an UDP conn used by QUIC.

func (*UDPLikeConn) Close

func (c *UDPLikeConn) Close() error

Close calls MockClose.

func (*UDPLikeConn) LocalAddr

func (c *UDPLikeConn) LocalAddr() net.Addr

LocalAddr calls MockLocalAddr.

func (*UDPLikeConn) ReadFrom

func (c *UDPLikeConn) ReadFrom(b []byte) (int, net.Addr, error)

ReadFrom calls MockReadFrom.

func (*UDPLikeConn) RemoteAddr

func (c *UDPLikeConn) RemoteAddr() net.Addr

RemoteAddr calls MockRemoteAddr.

func (*UDPLikeConn) SetDeadline

func (c *UDPLikeConn) SetDeadline(t time.Time) error

SetDeadline calls MockSetDeadline.

func (*UDPLikeConn) SetReadBuffer

func (c *UDPLikeConn) SetReadBuffer(n int) error

SetReadBuffer calls MockSetReadBuffer.

func (*UDPLikeConn) SetReadDeadline

func (c *UDPLikeConn) SetReadDeadline(t time.Time) error

SetReadDeadline calls MockSetReadDeadline.

func (*UDPLikeConn) SetWriteDeadline

func (c *UDPLikeConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline calls MockSetWriteDeadline.

func (*UDPLikeConn) SyscallConn

func (c *UDPLikeConn) SyscallConn() (syscall.RawConn, error)

SyscallConn calls MockSyscallConn.

func (*UDPLikeConn) WriteTo

func (c *UDPLikeConn) WriteTo(p []byte, addr net.Addr) (int, error)

WriteTo calls MockWriteTo.

type Writer added in v3.16.0

type Writer struct {
	MockWrite func(b []byte) (int, error)
}

Writer allows to mock any io.Writer.

func (*Writer) Write added in v3.16.0

func (r *Writer) Write(b []byte) (int, error)

Write implements io.Writer.Write.

Jump to

Keyboard shortcuts

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