Documentation ¶
Overview ¶
Package mocks contains mocks for implementing unit tests.
Index ¶
- func NewGeoIPASNLookupper(mx map[string]*model.LocationASN) model.GeoIPASNLookupper
- type Addr
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(b []byte) (int, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(b []byte) (int, error)
- type DNSDecoder
- type DNSEncoder
- type DNSQuery
- type DNSResponse
- func (r *DNSResponse) Bytes() []byte
- func (r *DNSResponse) DecodeCNAME() (string, error)
- func (r *DNSResponse) DecodeHTTPS() (*model.HTTPSSvc, error)
- func (r *DNSResponse) DecodeLookupHost() ([]string, error)
- func (r *DNSResponse) DecodeNS() ([]*net.NS, error)
- func (r *DNSResponse) Query() model.DNSQuery
- func (r *DNSResponse) Rcode() int
- type DNSTransport
- type Database
- func (d *Database) AddTestKeys(msmt *model.DatabaseMeasurement, sk model.MeasurementSummaryKeys) error
- func (d *Database) CreateMeasurement(reportID sql.NullString, testName string, measurementDir string, idx int, ...) (*model.DatabaseMeasurement, error)
- func (d *Database) CreateNetwork(loc model.LocationProvider) (*model.DatabaseNetwork, error)
- func (d *Database) CreateOrUpdateURL(urlStr string, categoryCode string, countryCode string) (int64, error)
- func (d *Database) CreateResult(homePath string, testGroupName string, networkID int64) (*model.DatabaseResult, error)
- func (d *Database) DeleteResult(resultID int64) error
- func (d *Database) Done(msmt *model.DatabaseMeasurement) error
- func (d *Database) Failed(msmt *model.DatabaseMeasurement, failure string) error
- func (d *Database) Finished(result *model.DatabaseResult) error
- func (d *Database) GetMeasurementJSON(msmtID int64) (map[string]interface{}, error)
- func (d *Database) ListMeasurements(resultID int64) ([]model.DatabaseMeasurementURLNetwork, error)
- func (d *Database) ListResults() ([]model.DatabaseResultNetwork, []model.DatabaseResultNetwork, error)
- func (d *Database) UpdateUploadedStatus(result *model.DatabaseResult) error
- func (d *Database) UploadFailed(msmt *model.DatabaseMeasurement, failure string) error
- func (d *Database) UploadSucceeded(msmt *model.DatabaseMeasurement) error
- type Dialer
- type Experiment
- func (e *Experiment) KibiBytesReceived() float64
- func (e *Experiment) KibiBytesSent() float64
- func (e *Experiment) MeasureWithContext(ctx context.Context, target model.ExperimentTarget) (measurement *model.Measurement, err error)
- func (e *Experiment) Name() string
- func (e *Experiment) OpenReportContext(ctx context.Context) error
- func (e *Experiment) ReportID() string
- func (e *Experiment) SaveMeasurement(measurement *model.Measurement, filePath string) error
- func (e *Experiment) SubmitAndUpdateMeasurementContext(ctx context.Context, measurement *model.Measurement) error
- type ExperimentBuilder
- func (eb *ExperimentBuilder) InputPolicy() model.InputPolicy
- func (eb *ExperimentBuilder) Interruptible() bool
- func (eb *ExperimentBuilder) NewExperiment() model.Experiment
- func (eb *ExperimentBuilder) NewTargetLoader(config *model.ExperimentTargetLoaderConfig) model.ExperimentTargetLoader
- func (eb *ExperimentBuilder) Options() (map[string]model.ExperimentOptionInfo, error)
- func (eb *ExperimentBuilder) SetCallbacks(callbacks model.ExperimentCallbacks)
- func (eb *ExperimentBuilder) SetOptionAny(key string, value any) error
- func (eb *ExperimentBuilder) SetOptionsAny(options map[string]any) error
- func (eb *ExperimentBuilder) SetOptionsJSON(value json.RawMessage) error
- type ExperimentInputProcessor
- type ExperimentMeasurer
- type ExperimentTargetLoader
- type GeoIPASNLookupper
- type HTTP3RoundTripper
- type HTTPClient
- type HTTPResponseWriter
- type HTTPTransport
- type KeyValueStore
- type Listener
- type LocationProvider
- type Logger
- type MeasuringNetwork
- func (mn *MeasuringNetwork) NewDialerWithoutResolver(dl model.DebugLogger, w ...model.DialerWrapper) model.Dialer
- func (mn *MeasuringNetwork) NewParallelDNSOverHTTPSResolver(logger model.DebugLogger, URL string) model.Resolver
- func (mn *MeasuringNetwork) NewParallelUDPResolver(logger model.DebugLogger, dialer model.Dialer, address string) model.Resolver
- func (mn *MeasuringNetwork) NewQUICDialerWithoutResolver(listener model.UDPListener, logger model.DebugLogger, ...) model.QUICDialer
- func (mn *MeasuringNetwork) NewStdlibResolver(logger model.DebugLogger) model.Resolver
- func (mn *MeasuringNetwork) NewTLSHandshakerStdlib(logger model.DebugLogger) model.TLSHandshaker
- func (mn *MeasuringNetwork) NewTLSHandshakerUTLS(logger model.DebugLogger, id *utls.ClientHelloID) model.TLSHandshaker
- func (mn *MeasuringNetwork) NewUDPListener() model.UDPListener
- type QUICDialer
- type QUICEarlyConnection
- func (s *QUICEarlyConnection) AcceptStream(ctx context.Context) (quic.Stream, error)
- func (s *QUICEarlyConnection) AcceptUniStream(ctx context.Context) (quic.ReceiveStream, error)
- func (c *QUICEarlyConnection) CloseWithError(code quic.ApplicationErrorCode, reason string) error
- func (s *QUICEarlyConnection) ConnectionState() quic.ConnectionState
- func (s *QUICEarlyConnection) Context() context.Context
- func (s *QUICEarlyConnection) HandshakeComplete() <-chan struct{}
- func (c *QUICEarlyConnection) LocalAddr() net.Addr
- func (s *QUICEarlyConnection) NextConnection() quic.Connection
- func (s *QUICEarlyConnection) OpenStream() (quic.Stream, error)
- func (s *QUICEarlyConnection) OpenStreamSync(ctx context.Context) (quic.Stream, error)
- func (s *QUICEarlyConnection) OpenUniStream() (quic.SendStream, error)
- func (s *QUICEarlyConnection) OpenUniStreamSync(ctx context.Context) (quic.SendStream, error)
- func (s *QUICEarlyConnection) ReceiveDatagram(ctx context.Context) ([]byte, error)
- func (c *QUICEarlyConnection) RemoteAddr() net.Addr
- func (s *QUICEarlyConnection) SendDatagram(b []byte) error
- type Reader
- type Resolver
- func (r *Resolver) Address() string
- func (r *Resolver) CloseIdleConnections()
- func (r *Resolver) LookupHTTPS(ctx context.Context, domain string) (*model.HTTPSSvc, error)
- func (r *Resolver) LookupHost(ctx context.Context, domain string) ([]string, error)
- func (r *Resolver) LookupNS(ctx context.Context, domain string) ([]*net.NS, error)
- func (r *Resolver) Network() string
- type Saver
- type Session
- func (sess *Session) CheckIn(ctx context.Context, config *model.OOAPICheckInConfig) (*model.OOAPICheckInResult, error)
- func (sess *Session) Close() error
- func (sess *Session) DefaultHTTPClient() model.HTTPClient
- func (sess *Session) FetchOpenVPNConfig(ctx context.Context, provider, cc string) (*model.OOAPIVPNProviderConfig, error)
- func (sess *Session) FetchPsiphonConfig(ctx context.Context) ([]byte, error)
- func (sess *Session) FetchTorTargets(ctx context.Context, cc string) (map[string]model.OOAPITorTarget, error)
- func (sess *Session) GetTestHelpersByName(name string) ([]model.OOAPIService, bool)
- func (sess *Session) KeyValueStore() model.KeyValueStore
- func (sess *Session) Logger() model.Logger
- func (sess *Session) MaybeLookupBackendsContext(ctx context.Context) error
- func (sess *Session) MaybeLookupLocationContext(ctx context.Context) error
- func (sess *Session) MaybeResolverIP() string
- func (sess *Session) NewExperimentBuilder(name string) (model.ExperimentBuilder, error)
- func (sess *Session) NewSubmitter(ctx context.Context) (model.Submitter, error)
- func (sess *Session) ProbeASNString() string
- func (sess *Session) ProbeCC() string
- func (sess *Session) ProbeIP() string
- func (sess *Session) ProbeNetworkName() string
- func (sess *Session) ProxyURL() *url.URL
- func (sess *Session) ResolverASNString() string
- func (sess *Session) ResolverIP() string
- func (sess *Session) ResolverNetworkName() string
- func (sess *Session) SoftwareName() string
- func (sess *Session) SoftwareVersion() string
- func (sess *Session) TempDir() string
- func (sess *Session) TorArgs() []string
- func (sess *Session) TorBinary() string
- func (sess *Session) TunnelDir() string
- func (sess *Session) UserAgent() string
- type Submitter
- type TLSConn
- type TLSDialer
- type TLSHandshaker
- type Trace
- func (t *Trace) MaybeWrapNetConn(conn net.Conn) net.Conn
- func (t *Trace) MaybeWrapUDPLikeConn(conn model.UDPLikeConn) model.UDPLikeConn
- func (t *Trace) OnConnectDone(started time.Time, network, domain, remoteAddr string, err error, ...)
- func (t *Trace) OnDNSRoundTripForLookupHost(started time.Time, reso model.Resolver, query model.DNSQuery, ...)
- func (t *Trace) OnDelayedDNSResponse(started time.Time, txp model.DNSTransport, query model.DNSQuery, ...) error
- func (t *Trace) OnQUICHandshakeDone(started time.Time, remoteAddr string, qconn quic.EarlyConnection, ...)
- func (t *Trace) OnQUICHandshakeStart(now time.Time, remoteAddr string, config *quic.Config)
- func (t *Trace) OnTLSHandshakeDone(started time.Time, remoteAddr string, config *tls.Config, ...)
- func (t *Trace) OnTLSHandshakeStart(now time.Time, remoteAddr string, config *tls.Config)
- func (t *Trace) TimeNow() time.Time
- type UDPLikeConn
- func (c *UDPLikeConn) Close() error
- func (c *UDPLikeConn) LocalAddr() net.Addr
- func (c *UDPLikeConn) ReadFrom(b []byte) (int, net.Addr, error)
- func (c *UDPLikeConn) RemoteAddr() net.Addr
- func (c *UDPLikeConn) SetDeadline(t time.Time) error
- func (c *UDPLikeConn) SetReadBuffer(n int) error
- func (c *UDPLikeConn) SetReadDeadline(t time.Time) error
- func (c *UDPLikeConn) SetWriteDeadline(t time.Time) error
- func (c *UDPLikeConn) SyscallConn() (syscall.RawConn, error)
- func (c *UDPLikeConn) WriteTo(p []byte, addr net.Addr) (int, error)
- type UDPListener
- type UnderlyingNetwork
- func (un *UnderlyingNetwork) DefaultCertPool() *x509.CertPool
- func (un *UnderlyingNetwork) DialContext(ctx context.Context, network, address string) (net.Conn, error)
- func (un *UnderlyingNetwork) DialTimeout() time.Duration
- func (un *UnderlyingNetwork) GetaddrinfoLookupANY(ctx context.Context, domain string) ([]string, string, error)
- func (un *UnderlyingNetwork) GetaddrinfoResolverNetwork() string
- func (un *UnderlyingNetwork) ListenTCP(network string, addr *net.TCPAddr) (net.Listener, error)
- func (un *UnderlyingNetwork) ListenUDP(network string, addr *net.UDPAddr) (model.UDPLikeConn, error)
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGeoIPASNLookupper ¶ added in v3.19.0
func NewGeoIPASNLookupper(mx map[string]*model.LocationASN) model.GeoIPASNLookupper
NewGeoIPASNLookupper creates a model.GeoIPASNLookupper from the given map.
Types ¶
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) SetDeadline ¶
SetDeadline calls MockSetDeadline.
func (*Conn) SetReadDeadline ¶
SetReadDeadline calls MockSetReadDeadline.
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline calls MockSetWriteDeadline.
type DNSDecoder ¶
type DNSDecoder struct {
MockDecodeResponse func(data []byte, query model.DNSQuery) (model.DNSResponse, error)
}
DNSDecoder allows mocking model.DNSDecoder.
func (*DNSDecoder) DecodeResponse ¶
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.
type DNSQuery ¶
type DNSQuery struct { MockDomain func() string MockType func() uint16 MockBytes func() ([]byte, error) MockID func() uint16 }
DNSQuery allocks mocking model.DNSQuery.
type DNSResponse ¶
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 ¶
func (r *DNSResponse) Bytes() []byte
func (*DNSResponse) DecodeCNAME ¶
func (r *DNSResponse) DecodeCNAME() (string, error)
func (*DNSResponse) DecodeHTTPS ¶
func (r *DNSResponse) DecodeHTTPS() (*model.HTTPSSvc, error)
func (*DNSResponse) DecodeLookupHost ¶
func (r *DNSResponse) DecodeLookupHost() ([]string, error)
func (*DNSResponse) Query ¶
func (r *DNSResponse) Query() model.DNSQuery
func (*DNSResponse) Rcode ¶
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) CloseIdleConnections ¶
func (txp *DNSTransport) CloseIdleConnections()
CloseIdleConnections calls MockCloseIdleConnections.
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 Database ¶
type Database struct { MockCreateNetwork func(loc model.LocationProvider) (*model.DatabaseNetwork, error) MockCreateOrUpdateURL func(urlStr string, categoryCode string, countryCode string) (int64, error) MockCreateResult func(homePath string, testGroupName string, networkID int64) (*model.DatabaseResult, error) MockUpdateUploadedStatus func(result *model.DatabaseResult) error MockFinished func(result *model.DatabaseResult) error MockDeleteResult func(resultID int64) error MockCreateMeasurement func(reportID sql.NullString, testName string, measurementDir string, idx int, resultID int64, urlID sql.NullInt64) (*model.DatabaseMeasurement, error) MockAddTestKeys func(msmt *model.DatabaseMeasurement, sk model.MeasurementSummaryKeys) error MockDone func(msmt *model.DatabaseMeasurement) error MockUploadFailed func(msmt *model.DatabaseMeasurement, failure string) error MockUploadSucceeded func(msmt *model.DatabaseMeasurement) error MockFailed func(msmt *model.DatabaseMeasurement, failure string) error MockListResults func() ([]model.DatabaseResultNetwork, []model.DatabaseResultNetwork, error) MockListMeasurements func(resultID int64) ([]model.DatabaseMeasurementURLNetwork, error) MockGetMeasurementJSON func(msmtID int64) (map[string]interface{}, error) }
Database allows mocking a database
func (*Database) AddTestKeys ¶
func (d *Database) AddTestKeys(msmt *model.DatabaseMeasurement, sk model.MeasurementSummaryKeys) error
AddTestKeys calls MockAddTestKeys
func (*Database) CreateMeasurement ¶
func (d *Database) CreateMeasurement(reportID sql.NullString, testName string, measurementDir string, idx int, resultID int64, urlID sql.NullInt64) (*model.DatabaseMeasurement, error)
CreateMeasurement calls MockCreateMeasurement
func (*Database) CreateNetwork ¶
func (d *Database) CreateNetwork(loc model.LocationProvider) (*model.DatabaseNetwork, error)
CreateNetwork calls MockCreateNetwork
func (*Database) CreateOrUpdateURL ¶
func (d *Database) CreateOrUpdateURL(urlStr string, categoryCode string, countryCode string) (int64, error)
CreateOrUpdateURL calls MockCreateOrUpdateURL
func (*Database) CreateResult ¶
func (d *Database) CreateResult(homePath string, testGroupName string, networkID int64) (*model.DatabaseResult, error)
CreateResult calls MockCreateResult
func (*Database) DeleteResult ¶
DeleteResult calls MockDeleteResult
func (*Database) Done ¶
func (d *Database) Done(msmt *model.DatabaseMeasurement) error
Done calls MockDone
func (*Database) Failed ¶
func (d *Database) Failed(msmt *model.DatabaseMeasurement, failure string) error
Failed calls MockFailed
func (*Database) Finished ¶
func (d *Database) Finished(result *model.DatabaseResult) error
Finished calls MockFinished
func (*Database) GetMeasurementJSON ¶
GetMeasurementJSON calls MockGetMeasurementJSON
func (*Database) ListMeasurements ¶
func (d *Database) ListMeasurements(resultID int64) ([]model.DatabaseMeasurementURLNetwork, error)
ListMeasurements calls MockListMeasurements
func (*Database) ListResults ¶
func (d *Database) ListResults() ([]model.DatabaseResultNetwork, []model.DatabaseResultNetwork, error)
ListResults calla MockListResults
func (*Database) UpdateUploadedStatus ¶
func (d *Database) UpdateUploadedStatus(result *model.DatabaseResult) error
UpdateUploadedStatus calls MockUpdateUploadedStatus
func (*Database) UploadFailed ¶
func (d *Database) UploadFailed(msmt *model.DatabaseMeasurement, failure string) error
UploadFailed calls MockUploadFailed
func (*Database) UploadSucceeded ¶
func (d *Database) UploadSucceeded(msmt *model.DatabaseMeasurement) error
UploadSucceeded calls MockUploadSucceeded
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.
type Experiment ¶
type Experiment struct { MockKibiBytesReceived func() float64 MockKibiBytesSent func() float64 MockName func() string MockReportID func() string MockMeasureWithContext func( ctx context.Context, target model.ExperimentTarget) (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) KibiBytesReceived ¶
func (e *Experiment) KibiBytesReceived() float64
func (*Experiment) KibiBytesSent ¶
func (e *Experiment) KibiBytesSent() float64
func (*Experiment) MeasureWithContext ¶
func (e *Experiment) MeasureWithContext( ctx context.Context, target model.ExperimentTarget) (measurement *model.Measurement, err error)
func (*Experiment) Name ¶
func (e *Experiment) Name() string
func (*Experiment) OpenReportContext ¶
func (e *Experiment) OpenReportContext(ctx context.Context) error
func (*Experiment) ReportID ¶
func (e *Experiment) ReportID() string
func (*Experiment) SaveMeasurement ¶
func (e *Experiment) SaveMeasurement(measurement *model.Measurement, filePath string) error
func (*Experiment) SubmitAndUpdateMeasurementContext ¶
func (e *Experiment) SubmitAndUpdateMeasurementContext( ctx context.Context, measurement *model.Measurement) error
type ExperimentBuilder ¶
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 MockSetOptionsJSON func(value json.RawMessage) error MockSetCallbacks func(callbacks model.ExperimentCallbacks) MockNewExperiment func() model.Experiment MockNewTargetLoader func(config *model.ExperimentTargetLoaderConfig) model.ExperimentTargetLoader }
ExperimentBuilder mocks model.ExperimentBuilder.
func (*ExperimentBuilder) InputPolicy ¶
func (eb *ExperimentBuilder) InputPolicy() model.InputPolicy
func (*ExperimentBuilder) Interruptible ¶
func (eb *ExperimentBuilder) Interruptible() bool
func (*ExperimentBuilder) NewExperiment ¶
func (eb *ExperimentBuilder) NewExperiment() model.Experiment
func (*ExperimentBuilder) NewTargetLoader ¶ added in v3.23.0
func (eb *ExperimentBuilder) NewTargetLoader(config *model.ExperimentTargetLoaderConfig) model.ExperimentTargetLoader
func (*ExperimentBuilder) Options ¶
func (eb *ExperimentBuilder) Options() (map[string]model.ExperimentOptionInfo, error)
func (*ExperimentBuilder) SetCallbacks ¶
func (eb *ExperimentBuilder) SetCallbacks(callbacks model.ExperimentCallbacks)
func (*ExperimentBuilder) SetOptionAny ¶
func (eb *ExperimentBuilder) SetOptionAny(key string, value any) error
func (*ExperimentBuilder) SetOptionsAny ¶
func (eb *ExperimentBuilder) SetOptionsAny(options map[string]any) error
func (*ExperimentBuilder) SetOptionsJSON ¶ added in v3.23.0
func (eb *ExperimentBuilder) SetOptionsJSON(value json.RawMessage) error
type ExperimentInputProcessor ¶
ExperimentInputProcessor processes inputs running the given experiment.
type ExperimentMeasurer ¶ added in v3.19.0
type ExperimentMeasurer struct { MockExperimentName func() string MockExperimentVersion func() string MockRun func(ctx context.Context, args *model.ExperimentArgs) error }
func (*ExperimentMeasurer) ExperimentName ¶ added in v3.19.0
func (em *ExperimentMeasurer) ExperimentName() string
ExperimentName implements model.ExperimentMeasurer.
func (*ExperimentMeasurer) ExperimentVersion ¶ added in v3.19.0
func (em *ExperimentMeasurer) ExperimentVersion() string
ExperimentVersion implements model.ExperimentMeasurer.
func (*ExperimentMeasurer) Run ¶ added in v3.19.0
func (em *ExperimentMeasurer) Run(ctx context.Context, args *model.ExperimentArgs) error
Run implements model.ExperimentMeasurer.
type ExperimentTargetLoader ¶ added in v3.23.0
type ExperimentTargetLoader struct {
MockLoad func(ctx context.Context) ([]model.ExperimentTarget, error)
}
ExperimentTargetLoader mocks model.ExperimentTargetLoader
func (*ExperimentTargetLoader) Load ¶ added in v3.23.0
func (eil *ExperimentTargetLoader) Load(ctx context.Context) ([]model.ExperimentTarget, error)
Load calls MockLoad
type GeoIPASNLookupper ¶ added in v3.19.0
GeoIPASNLookupper allows mocking model.GeoIPASNLookupper.
type HTTP3RoundTripper ¶
type HTTP3RoundTripper struct { MockRoundTrip func(req *http.Request) (*http.Response, error) MockClose func() error }
HTTP3RoundTripper allows mocking http3.RoundTripper.
func (*HTTP3RoundTripper) Close ¶
func (txp *HTTP3RoundTripper) Close() error
Close calls MockClose.
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.
type HTTPResponseWriter ¶
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 ¶
func (w *HTTPResponseWriter) Header() http.Header
func (*HTTPResponseWriter) WriteHeader ¶
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.
type KeyValueStore ¶
type KeyValueStore struct { MockGet func(key string) (value []byte, err error) MockSet func(key string, value []byte) (err error) }
KeyValueStore allows mocking model.KeyValueStore.
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.
type LocationProvider ¶
type LocationProvider struct { MockProbeASN func() uint MockProbeASNString func() string MockProbeCC func() string MockProbeIP func() string MockProbeNetworkName func() string MockResolverIP func() string }
func (*LocationProvider) ProbeASN ¶
func (loc *LocationProvider) ProbeASN() uint
ProbeASN calls MockProbeASN
func (*LocationProvider) ProbeASNString ¶
func (loc *LocationProvider) ProbeASNString() string
ProbeASNString calls MockProbeASNString
func (*LocationProvider) ProbeCC ¶
func (loc *LocationProvider) ProbeCC() string
ProbeCC call MockProbeCC
func (*LocationProvider) ProbeIP ¶
func (loc *LocationProvider) ProbeIP() string
ProbeIP calls MockProbeIP
func (*LocationProvider) ProbeNetworkName ¶
func (loc *LocationProvider) ProbeNetworkName() string
ProbeNetworkName calls MockProbeNetworkName
func (*LocationProvider) ResolverIP ¶
func (loc *LocationProvider) ResolverIP() string
ResolverIP calls MockResolverIP
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.
type MeasuringNetwork ¶ added in v3.19.0
type MeasuringNetwork struct { MockNewDialerWithoutResolver func(dl model.DebugLogger, w ...model.DialerWrapper) model.Dialer MockNewParallelDNSOverHTTPSResolver func(logger model.DebugLogger, URL string) model.Resolver MockNewParallelUDPResolver func(logger model.DebugLogger, dialer model.Dialer, address string) model.Resolver MockNewQUICDialerWithoutResolver func(listener model.UDPListener, logger model.DebugLogger, w ...model.QUICDialerWrapper) model.QUICDialer MockNewStdlibResolver func(logger model.DebugLogger) model.Resolver MockNewTLSHandshakerStdlib func(logger model.DebugLogger) model.TLSHandshaker MockNewTLSHandshakerUTLS func(logger model.DebugLogger, id *utls.ClientHelloID) model.TLSHandshaker MockNewUDPListener func() model.UDPListener }
MeasuringNetwork allows mocking model.MeasuringNetwork.
func (*MeasuringNetwork) NewDialerWithoutResolver ¶ added in v3.19.0
func (mn *MeasuringNetwork) NewDialerWithoutResolver(dl model.DebugLogger, w ...model.DialerWrapper) model.Dialer
NewDialerWithoutResolver implements model.MeasuringNetwork.
func (*MeasuringNetwork) NewParallelDNSOverHTTPSResolver ¶ added in v3.19.0
func (mn *MeasuringNetwork) NewParallelDNSOverHTTPSResolver(logger model.DebugLogger, URL string) model.Resolver
NewParallelDNSOverHTTPSResolver implements model.MeasuringNetwork.
func (*MeasuringNetwork) NewParallelUDPResolver ¶ added in v3.19.0
func (mn *MeasuringNetwork) NewParallelUDPResolver(logger model.DebugLogger, dialer model.Dialer, address string) model.Resolver
NewParallelUDPResolver implements model.MeasuringNetwork.
func (*MeasuringNetwork) NewQUICDialerWithoutResolver ¶ added in v3.19.0
func (mn *MeasuringNetwork) NewQUICDialerWithoutResolver(listener model.UDPListener, logger model.DebugLogger, w ...model.QUICDialerWrapper) model.QUICDialer
NewQUICDialerWithoutResolver implements model.MeasuringNetwork.
func (*MeasuringNetwork) NewStdlibResolver ¶ added in v3.19.0
func (mn *MeasuringNetwork) NewStdlibResolver(logger model.DebugLogger) model.Resolver
NewStdlibResolver implements model.MeasuringNetwork.
func (*MeasuringNetwork) NewTLSHandshakerStdlib ¶ added in v3.19.0
func (mn *MeasuringNetwork) NewTLSHandshakerStdlib(logger model.DebugLogger) model.TLSHandshaker
NewTLSHandshakerStdlib implements model.MeasuringNetwork.
func (*MeasuringNetwork) NewTLSHandshakerUTLS ¶ added in v3.19.0
func (mn *MeasuringNetwork) NewTLSHandshakerUTLS(logger model.DebugLogger, id *utls.ClientHelloID) model.TLSHandshaker
NewTLSHandshakerUTLS implements model.MeasuringNetwork.
func (*MeasuringNetwork) NewUDPListener ¶ added in v3.19.0
func (mn *MeasuringNetwork) NewUDPListener() model.UDPListener
NewUDPListener implements model.MeasuringNetwork.
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 ¶
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() <-chan struct{} MockNextConnection func() quic.Connection MockSendDatagram func(b []byte) error MockReceiveDatagram func(ctx context.Context) ([]byte, error) }
QUICEarlyConnection is a mockable quic.EarlyConnection.
func (*QUICEarlyConnection) AcceptStream ¶
func (s *QUICEarlyConnection) AcceptStream(ctx context.Context) (quic.Stream, error)
AcceptStream calls MockAcceptStream.
func (*QUICEarlyConnection) AcceptUniStream ¶
func (s *QUICEarlyConnection) AcceptUniStream(ctx context.Context) (quic.ReceiveStream, error)
AcceptUniStream calls MockAcceptUniStream.
func (*QUICEarlyConnection) CloseWithError ¶
func (c *QUICEarlyConnection) CloseWithError( code quic.ApplicationErrorCode, reason string) error
CloseWithError calls MockCloseWithError.
func (*QUICEarlyConnection) ConnectionState ¶
func (s *QUICEarlyConnection) ConnectionState() quic.ConnectionState
ConnectionState calls MockConnectionState.
func (*QUICEarlyConnection) Context ¶
func (s *QUICEarlyConnection) Context() context.Context
Context calls MockContext.
func (*QUICEarlyConnection) HandshakeComplete ¶
func (s *QUICEarlyConnection) HandshakeComplete() <-chan struct{}
HandshakeComplete calls MockHandshakeComplete.
func (*QUICEarlyConnection) LocalAddr ¶
func (c *QUICEarlyConnection) LocalAddr() net.Addr
LocalAddr class MockLocalAddr.
func (*QUICEarlyConnection) NextConnection ¶
func (s *QUICEarlyConnection) NextConnection() quic.Connection
NextConnection calls MockNextConnection.
func (*QUICEarlyConnection) OpenStream ¶
func (s *QUICEarlyConnection) OpenStream() (quic.Stream, error)
OpenStream calls MockOpenStream.
func (*QUICEarlyConnection) OpenStreamSync ¶
func (s *QUICEarlyConnection) OpenStreamSync(ctx context.Context) (quic.Stream, error)
OpenStreamSync calls MockOpenStreamSync.
func (*QUICEarlyConnection) OpenUniStream ¶
func (s *QUICEarlyConnection) OpenUniStream() (quic.SendStream, error)
OpenUniStream calls MockOpenUniStream.
func (*QUICEarlyConnection) OpenUniStreamSync ¶
func (s *QUICEarlyConnection) OpenUniStreamSync(ctx context.Context) (quic.SendStream, error)
OpenUniStreamSync calls MockOpenUniStreamSync.
func (*QUICEarlyConnection) ReceiveDatagram ¶ added in v3.20.0
func (s *QUICEarlyConnection) ReceiveDatagram(ctx context.Context) ([]byte, error)
ReceiveDatagram calls MockReceiveDatagram.
func (*QUICEarlyConnection) RemoteAddr ¶
func (c *QUICEarlyConnection) RemoteAddr() net.Addr
RemoteAddr calls MockRemoteAddr.
func (*QUICEarlyConnection) SendDatagram ¶ added in v3.20.0
func (s *QUICEarlyConnection) SendDatagram(b []byte) error
SendDatagram calls MockSendDatagram.
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) CloseIdleConnections ¶
func (r *Resolver) CloseIdleConnections()
CloseIdleConnections calls MockCloseIdleConnections.
func (*Resolver) LookupHTTPS ¶
LookupHTTPS calls MockLookupHTTPS.
func (*Resolver) LookupHost ¶
LookupHost calls MockLookupHost.
type Saver ¶
type Saver struct {
MockSaveMeasurement func(m *model.Measurement) error
}
Saver saves a measurement on some persistent storage.
func (*Saver) SaveMeasurement ¶
func (s *Saver) SaveMeasurement(m *model.Measurement) error
type Session ¶
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) MockFetchOpenVPNConfig func( ctx context.Context, provider, cc string) (*model.OOAPIVPNProviderConfig, 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.OOAPICheckInResult, error) MockClose func() error MockMaybeLookupBackendsContext func(ctx context.Context) error MockMaybeLookupLocationContext func(ctx context.Context) error MockResolverASNString func() string MockResolverNetworkName func() string }
Session allows to mock sessions.
func (*Session) CheckIn ¶
func (sess *Session) CheckIn(ctx context.Context, config *model.OOAPICheckInConfig) (*model.OOAPICheckInResult, error)
func (*Session) DefaultHTTPClient ¶
func (sess *Session) DefaultHTTPClient() model.HTTPClient
func (*Session) FetchOpenVPNConfig ¶ added in v3.23.0
func (*Session) FetchPsiphonConfig ¶
func (*Session) FetchTorTargets ¶
func (*Session) GetTestHelpersByName ¶
func (sess *Session) GetTestHelpersByName(name string) ([]model.OOAPIService, bool)
func (*Session) KeyValueStore ¶
func (sess *Session) KeyValueStore() model.KeyValueStore
func (*Session) MaybeLookupBackendsContext ¶ added in v3.23.0
func (*Session) MaybeLookupLocationContext ¶ added in v3.23.0
func (*Session) MaybeResolverIP ¶
func (*Session) NewExperimentBuilder ¶
func (sess *Session) NewExperimentBuilder(name string) (model.ExperimentBuilder, error)
func (*Session) NewSubmitter ¶
func (*Session) ProbeASNString ¶
func (*Session) ProbeNetworkName ¶
func (*Session) ResolverASNString ¶ added in v3.23.0
func (*Session) ResolverIP ¶
func (*Session) ResolverNetworkName ¶ added in v3.23.0
func (*Session) SoftwareName ¶
func (*Session) SoftwareVersion ¶
type Submitter ¶
type Submitter struct {
MockSubmit func(ctx context.Context, m *model.Measurement) error
}
Submitter mocks model.Submitter.
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 ¶
HandshakeContext calls MockHandshakeContext.
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.
type TLSHandshaker ¶
type TLSHandshaker struct {
MockHandshake func(ctx context.Context, conn net.Conn, config *tls.Config) (model.TLSConn, error)
}
TLSHandshaker is a mockable TLS handshaker.
type Trace ¶
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) MaybeWrapUDPLikeConn ¶
func (t *Trace) MaybeWrapUDPLikeConn(conn model.UDPLikeConn) model.UDPLikeConn
func (*Trace) OnConnectDone ¶
func (*Trace) OnDNSRoundTripForLookupHost ¶
func (*Trace) OnDelayedDNSResponse ¶
func (*Trace) OnQUICHandshakeDone ¶
func (*Trace) OnQUICHandshakeStart ¶
func (*Trace) OnTLSHandshakeDone ¶
func (*Trace) OnTLSHandshakeStart ¶
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) LocalAddr ¶
func (c *UDPLikeConn) LocalAddr() net.Addr
LocalAddr calls MockLocalAddr.
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.
type UDPListener ¶ added in v3.19.0
type UDPListener struct {
MockListen func(addr *net.UDPAddr) (model.UDPLikeConn, error)
}
UDPListener is a mockable netxlite.UDPListener.
func (*UDPListener) Listen ¶ added in v3.19.0
func (ql *UDPListener) Listen(addr *net.UDPAddr) (model.UDPLikeConn, error)
Listen calls MockListen.
type UnderlyingNetwork ¶
type UnderlyingNetwork struct { MockDefaultCertPool func() *x509.CertPool MockDialTimeout func() time.Duration MockDialContext func(ctx context.Context, network, address string) (net.Conn, error) MockListenTCP func(network string, addr *net.TCPAddr) (net.Listener, error) MockListenUDP func(network string, addr *net.UDPAddr) (model.UDPLikeConn, error) MockGetaddrinfoLookupANY func(ctx context.Context, domain string) ([]string, string, error) MockGetaddrinfoResolverNetwork func() string }
UnderlyingNetwork allows mocking model.UnderlyingNetwork.
func (*UnderlyingNetwork) DefaultCertPool ¶
func (un *UnderlyingNetwork) DefaultCertPool() *x509.CertPool
func (*UnderlyingNetwork) DialContext ¶
func (*UnderlyingNetwork) DialTimeout ¶ added in v3.19.0
func (un *UnderlyingNetwork) DialTimeout() time.Duration
func (*UnderlyingNetwork) GetaddrinfoLookupANY ¶
func (*UnderlyingNetwork) GetaddrinfoResolverNetwork ¶
func (un *UnderlyingNetwork) GetaddrinfoResolverNetwork() string
func (*UnderlyingNetwork) ListenUDP ¶
func (un *UnderlyingNetwork) ListenUDP(network string, addr *net.UDPAddr) (model.UDPLikeConn, error)
Source Files ¶
- addr.go
- database.go
- dialer.go
- dnsdecoder.go
- dnsencoder.go
- dnsquery.go
- dnsresponse.go
- dnstransport.go
- doc.go
- experiment.go
- experimentbuilder.go
- experimentinputprocessor.go
- experimentmeasurer.go
- experimenttargetloader.go
- geoip.go
- http.go
- http3.go
- keyvaluestore.go
- listener.go
- location.go
- logger.go
- measuringnetwork.go
- quic.go
- reader.go
- resolver.go
- saver.go
- session.go
- submitter.go
- tls.go
- trace.go
- udplistener.go
- underlyingnetwork.go
- writer.go