Documentation ¶
Overview ¶
Package model contains the shared interfaces and data structures.
Criteria for adding a type to this package ¶
This package should contain two types:
1. important interfaces that are shared by several packages within the codebase, with the objective of separating unrelated pieces of code and making unit testing easier;
2. important pieces of data that are shared across different packages (e.g., the representation of a Measurement).
In general, this package should not contain logic, unless this logic is strictly related to data structures and we cannot implement this logic elsewhere.
Content of this package ¶
The following list (which may not always be up-to-date) summarizes the categories of types that currently belong here and names the files in which they are implemented:
- experiment.go: generic definition of a network experiment and all the required support types;
- keyvaluestore.go: generic definition of a key-value store, used in several places across the codebase;
- logger.go: generic definition of an apex/log compatible logger, used in several places across the codebase;
- measurement.go: data type representing the result of a network measurement, used in many many places;
- netx.go: network extension interfaces and data used everywhere we need to perform network operations;
- ooapi.go: types to communicate with the OONI API.
Index ¶
- Constants
- Variables
- func ErrorToStringOrOK(err error) string
- type ArchivalDNSAnswer
- type ArchivalDNSLookupResult
- type ArchivalExtSpec
- type ArchivalHTTPBody
- type ArchivalHTTPHeader
- type ArchivalHTTPRequest
- type ArchivalHTTPRequestResult
- type ArchivalHTTPResponse
- type ArchivalHTTPTor
- type ArchivalMaybeBinaryData
- type ArchivalNetworkEvent
- type ArchivalTCPConnectResult
- type ArchivalTCPConnectStatus
- type ArchivalTLSOrQUICHandshakeResult
- type DNSDecoder
- type DNSEncoder
- type DNSTransport
- type DebugLogger
- type Dialer
- type ExperimentAsyncTestKeys
- type ExperimentCallbacks
- type ExperimentMeasurer
- type ExperimentMeasurerAsync
- type ExperimentSession
- type HTTPClient
- type HTTPSSvc
- type HTTPTransport
- type InfoLogger
- type KeyValueStore
- type Logger
- type Measurement
- type MeasurementTarget
- type OOAPICheckInConfig
- type OOAPICheckInConfigWebConnectivity
- type OOAPICheckInInfo
- type OOAPICheckInInfoWebConnectivity
- type OOAPIService
- type OOAPITorTarget
- type OOAPIURLInfo
- type OOAPIURLListConfig
- type PrinterCallbacks
- type QUICDialer
- type QUICListener
- type Resolver
- type RunType
- type SimpleDialer
- type TLSDialer
- type TLSHandshaker
- type UDPLikeConn
- type UnderlyingNetworkLibrary
Constants ¶
const ( // RunTypeManual indicates that the user manually run `ooniprobe run`. Command // line tools such as miniooni should always use this run type. RunTypeManual = RunType("manual") // RunTypeTimed indicates that the user run `ooniprobe run unattended`, which // is the correct way to run ooniprobe from scripts and cronjobs. RunTypeTimed = RunType("timed") )
const (
// DefaultProbeIP is the default probe IP.
DefaultProbeIP = "127.0.0.1"
)
const Scrubbed = `[scrubbed]`
Scrubbed is the string that replaces IP addresses.
Variables ¶
var ( // ArchivalExtDNS is the version of df-002-dnst.md ArchivalExtDNS = ArchivalExtSpec{Name: "dnst", V: 0} // ArchivalExtNetevents is the version of df-008-netevents.md ArchivalExtNetevents = ArchivalExtSpec{Name: "netevents", V: 0} // ArchivalExtHTTP is the version of df-001-httpt.md ArchivalExtHTTP = ArchivalExtSpec{Name: "httpt", V: 0} // ArchivalExtTCPConnect is the version of df-005-tcpconnect.md ArchivalExtTCPConnect = ArchivalExtSpec{Name: "tcpconnect", V: 0} // ArchivalExtTLSHandshake is the version of df-006-tlshandshake.md ArchivalExtTLSHandshake = ArchivalExtSpec{Name: "tlshandshake", V: 0} // ArchivalExtTunnel is the version of df-009-tunnel.md ArchivalExtTunnel = ArchivalExtSpec{Name: "tunnel", V: 0} )
var ErrInvalidProbeIP = errors.New("model: invalid probe IP")
ErrInvalidProbeIP indicates that we're dealing with a string that is not the valid serialization of an IP address.
Functions ¶
func ErrorToStringOrOK ¶ added in v3.15.0
ErrorToStringOrOK emits "ok" on "<nil>"" values for success.
Types ¶
type ArchivalDNSAnswer ¶
type ArchivalDNSAnswer struct { ASN int64 `json:"asn,omitempty"` ASOrgName string `json:"as_org_name,omitempty"` AnswerType string `json:"answer_type"` Hostname string `json:"hostname,omitempty"` IPv4 string `json:"ipv4,omitempty"` IPv6 string `json:"ipv6,omitempty"` TTL *uint32 `json:"ttl"` }
ArchivalDNSAnswer is a DNS answer.
type ArchivalDNSLookupResult ¶
type ArchivalDNSLookupResult struct { Answers []ArchivalDNSAnswer `json:"answers"` Engine string `json:"engine"` Failure *string `json:"failure"` Hostname string `json:"hostname"` QueryType string `json:"query_type"` ResolverHostname *string `json:"resolver_hostname"` ResolverPort *string `json:"resolver_port"` ResolverAddress string `json:"resolver_address"` T float64 `json:"t"` }
ArchivalDNSLookupResult is the result of a DNS lookup.
See https://github.com/ooni/spec/blob/master/data-formats/df-002-dnst.md.
type ArchivalExtSpec ¶
ArchivalExtSpec describes a data format extension
func (ArchivalExtSpec) AddTo ¶
func (spec ArchivalExtSpec) AddTo(m *Measurement)
AddTo adds the current ExtSpec to the specified measurement
type ArchivalHTTPBody ¶
type ArchivalHTTPBody = ArchivalMaybeBinaryData
ArchivalHTTPBody is an HTTP body. As an implementation note, this type must be an alias for the MaybeBinaryValue type, otherwise the specific serialisation mechanism implemented by MaybeBinaryValue is not working.
type ArchivalHTTPHeader ¶
type ArchivalHTTPHeader struct { Key string Value ArchivalMaybeBinaryData }
ArchivalHTTPHeader is a single HTTP header.
func (ArchivalHTTPHeader) MarshalJSON ¶
func (hh ArchivalHTTPHeader) MarshalJSON() ([]byte, error)
MarshalJSON marshals a single HTTP header to a tuple where the first element is a string and the second element is maybe-binary data.
func (*ArchivalHTTPHeader) UnmarshalJSON ¶
func (hh *ArchivalHTTPHeader) UnmarshalJSON(d []byte) error
UnmarshalJSON is the opposite of MarshalJSON.
type ArchivalHTTPRequest ¶
type ArchivalHTTPRequest struct { Body ArchivalHTTPBody `json:"body"` BodyIsTruncated bool `json:"body_is_truncated"` HeadersList []ArchivalHTTPHeader `json:"headers_list"` Headers map[string]ArchivalMaybeBinaryData `json:"headers"` Method string `json:"method"` Tor ArchivalHTTPTor `json:"tor"` Transport string `json:"x_transport"` URL string `json:"url"` }
ArchivalHTTPRequest contains an HTTP request.
Headers are a map in Web Connectivity data format but we have added support for a list since January 2020.
type ArchivalHTTPRequestResult ¶
type ArchivalHTTPRequestResult struct { Failure *string `json:"failure"` Request ArchivalHTTPRequest `json:"request"` Response ArchivalHTTPResponse `json:"response"` T float64 `json:"t"` }
ArchivalHTTPRequestResult is the result of sending an HTTP request.
See https://github.com/ooni/spec/blob/master/data-formats/df-001-httpt.md.
type ArchivalHTTPResponse ¶
type ArchivalHTTPResponse struct { Body ArchivalHTTPBody `json:"body"` BodyIsTruncated bool `json:"body_is_truncated"` Code int64 `json:"code"` HeadersList []ArchivalHTTPHeader `json:"headers_list"` Headers map[string]ArchivalMaybeBinaryData `json:"headers"` // The following fields are not serialised but are useful to simplify // analysing the measurements in telegram, whatsapp, etc. Locations []string `json:"-"` }
ArchivalHTTPResponse contains an HTTP response.
Headers are a map in Web Connectivity data format but we have added support for a list since January 2020.
type ArchivalHTTPTor ¶
type ArchivalHTTPTor struct { ExitIP *string `json:"exit_ip"` ExitName *string `json:"exit_name"` IsTor bool `json:"is_tor"` }
ArchivalHTTPTor contains Tor information.
type ArchivalMaybeBinaryData ¶
type ArchivalMaybeBinaryData struct {
Value string
}
ArchivalMaybeBinaryData is a possibly binary string. We use this helper class to define a custom JSON encoder that allows us to choose the proper representation depending on whether the Value field is valid UTF-8 or not.
See https://github.com/ooni/spec/blob/master/data-formats/df-001-httpt.md#maybebinarydata
func (ArchivalMaybeBinaryData) MarshalJSON ¶
func (hb ArchivalMaybeBinaryData) MarshalJSON() ([]byte, error)
MarshalJSON marshals a string-like to JSON following the OONI spec that says that UTF-8 content is represented as string and non-UTF-8 content is instead represented using `{"format":"base64","data":"..."}`.
func (*ArchivalMaybeBinaryData) UnmarshalJSON ¶
func (hb *ArchivalMaybeBinaryData) UnmarshalJSON(d []byte) error
UnmarshalJSON is the opposite of MarshalJSON.
type ArchivalNetworkEvent ¶
type ArchivalNetworkEvent struct { Address string `json:"address,omitempty"` Failure *string `json:"failure"` NumBytes int64 `json:"num_bytes,omitempty"` Operation string `json:"operation"` Proto string `json:"proto,omitempty"` T float64 `json:"t"` Tags []string `json:"tags,omitempty"` }
ArchivalNetworkEvent is a network event. It contains all the possible fields and most fields are optional. They are only added when it makes sense for them to be there _and_ we have data to show.
See https://github.com/ooni/spec/blob/master/data-formats/df-008-netevents.md.
type ArchivalTCPConnectResult ¶
type ArchivalTCPConnectResult struct { IP string `json:"ip"` Port int `json:"port"` Status ArchivalTCPConnectStatus `json:"status"` T float64 `json:"t"` }
ArchivalTCPConnectResult contains the result of a TCP connect.
See https://github.com/ooni/spec/blob/master/data-formats/df-005-tcpconnect.md.
type ArchivalTCPConnectStatus ¶
type ArchivalTCPConnectStatus struct { Blocked *bool `json:"blocked,omitempty"` Failure *string `json:"failure"` Success bool `json:"success"` }
ArchivalTCPConnectStatus is the status of ArchivalTCPConnectResult.
type ArchivalTLSOrQUICHandshakeResult ¶
type ArchivalTLSOrQUICHandshakeResult struct { Address string `json:"address"` CipherSuite string `json:"cipher_suite"` Failure *string `json:"failure"` NegotiatedProtocol string `json:"negotiated_protocol"` NoTLSVerify bool `json:"no_tls_verify"` PeerCertificates []ArchivalMaybeBinaryData `json:"peer_certificates"` ServerName string `json:"server_name"` T float64 `json:"t"` Tags []string `json:"tags"` TLSVersion string `json:"tls_version"` }
ArchivalTLSOrQUICHandshakeResult is the result of a TLS or QUIC handshake.
See https://github.com/ooni/spec/blob/master/data-formats/df-006-tlshandshake.md
type DNSDecoder ¶
type DNSDecoder interface { // DecodeLookupHost decodes an A or AAAA reply. // // Arguments: // // - qtype is the query type (e.g., dns.TypeAAAA) // // - data contains the reply bytes read from a DNSTransport // // - queryID is the original query ID // // Returns: // // - on success, a list of IP addrs inside the reply and a nil error // // - on failure, a nil list and an error. // // Note that this function will return an error if there is no // IP address inside of the reply. DecodeLookupHost(qtype uint16, data []byte, queryID uint16) ([]string, error) // DecodeHTTPS is like DecodeLookupHost but decodes an HTTPS reply. // // The argument is the reply as read by the DNSTransport. // // On success, this function returns an HTTPSSvc structure and // a nil error. On failure, the HTTPSSvc pointer is nil and // the error points to the error that occurred. // // This function will return an error if the HTTPS reply does not // contain at least a valid ALPN entry. It will not return // an error, though, when there are no IPv4/IPv6 hints in the reply. DecodeHTTPS(data []byte, queryID uint16) (*HTTPSSvc, error) // DecodeNS is like DecodeHTTPS but for NS queries. DecodeNS(data []byte, queryID uint16) ([]*net.NS, error) // DecodeReply decodes a DNS reply message. // // Arguments: // // - data is the raw reply // // This function fails if we cannot parse data as a DNS // message or the message is not a reply. // // If you use this function, remember that: // // 1. the Rcode MAY be nonzero; // // 2. the replyID MAY NOT match the original query ID. // // That is, this is a very basic parsing method. DecodeReply(data []byte) (*dns.Msg, error) }
The DNSDecoder decodes DNS replies.
type DNSEncoder ¶
type DNSEncoder interface { // Encode transforms its arguments into a serialized DNS query. // // Arguments: // // - domain is the domain for the query (e.g., x.org); // // - qtype is the query type (e.g., dns.TypeA); // // - padding is whether to add padding to the query. // // On success, this function returns a valid byte array, the queryID, and // a nil error. On failure, we have a non-nil error, a nil arrary and a zero // query ID. Encode(domain string, qtype uint16, padding bool) ([]byte, uint16, error) }
The DNSEncoder encodes DNS queries to bytes
type DNSTransport ¶
type DNSTransport interface { // RoundTrip sends a DNS query and receives the reply. RoundTrip(ctx context.Context, query []byte) (reply []byte, err error) // RequiresPadding returns whether this transport needs padding. RequiresPadding() bool // Network is the network of the round tripper (e.g. "dot"). Network() string // Address is the address of the round tripper (e.g. "1.1.1.1:853"). Address() string // CloseIdleConnections closes idle connections, if any. CloseIdleConnections() }
DNSTransport represents an abstract DNS transport.
type DebugLogger ¶
type DebugLogger interface { // Debug emits a debug message. Debug(msg string) // Debugf formats and emits a debug message. Debugf(format string, v ...interface{}) }
DebugLogger is a logger emitting only debug messages.
type Dialer ¶
type Dialer interface { // A Dialer is also a SimpleDialer. SimpleDialer // CloseIdleConnections closes idle connections, if any. CloseIdleConnections() }
Dialer is a SimpleDialer with the possibility of closing open connections.
type ExperimentAsyncTestKeys ¶
type ExperimentAsyncTestKeys struct { // Extensions contains the extensions used by this experiment. Extensions map[string]int64 // Input is the input this measurement refers to. Input MeasurementTarget // MeasurementRuntime is the total measurement runtime. MeasurementRuntime float64 // TestHelpers contains the test helpers used in the experiment TestHelpers map[string]interface{} // TestKeys contains the actual test keys. TestKeys interface{} }
ExperimentAsyncTestKeys is the type of test keys returned by an experiment when running in async fashion rather than in sync fashion.
type ExperimentCallbacks ¶
type ExperimentCallbacks interface { // OnProgress provides information about an experiment progress. OnProgress(percentage float64, message string) }
ExperimentCallbacks contains experiment event-handling callbacks
type ExperimentMeasurer ¶
type ExperimentMeasurer interface { // ExperimentName returns the experiment name. ExperimentName() string // ExperimentVersion returns the experiment version. ExperimentVersion() string // Run runs the experiment with the specified context, session, // measurement, and experiment calbacks. This method should only // return an error in case the experiment could not run (e.g., // a required input is missing). Otherwise, the code should just // set the relevant OONI error inside of the measurement and // return nil. This is important because the caller WILL NOT submit // the measurement if this method returns an error. Run( ctx context.Context, sess ExperimentSession, measurement *Measurement, callbacks ExperimentCallbacks, ) error // GetSummaryKeys returns summary keys expected by ooni/probe-cli. GetSummaryKeys(*Measurement) (interface{}, error) }
ExperimentMeasurer is the interface that allows to run a measurement for a specific experiment.
type ExperimentMeasurerAsync ¶
type ExperimentMeasurerAsync interface { // RunAsync runs the experiment in async fashion. // // Arguments: // // - ctx is the context for deadline/timeout/cancellation // // - sess is the measurement session // // - input is the input URL to measure // // - callbacks contains the experiment callbacks // // Returns either a channel where TestKeys are posted or an error. // // An error indicates that specific preconditions for running the experiment // are not met (e.g., the input URL is invalid). // // On success, the experiment will post on the channel each new // measurement until it is done and closes the channel. RunAsync(ctx context.Context, sess ExperimentSession, input string, callbacks ExperimentCallbacks) (<-chan *ExperimentAsyncTestKeys, error) }
ExperimentMeasurerAsync is a measurer that can run in async fashion.
Currently this functionality is optional, but we will likely migrate all experiments to use this functionality in 2022.
type ExperimentSession ¶
type ExperimentSession interface { GetTestHelpersByName(name string) ([]OOAPIService, bool) DefaultHTTPClient() *http.Client FetchPsiphonConfig(ctx context.Context) ([]byte, error) FetchTorTargets(ctx context.Context, cc string) (map[string]OOAPITorTarget, error) FetchURLList(ctx context.Context, config OOAPIURLListConfig) ([]OOAPIURLInfo, error) Logger() Logger ProbeCC() string ResolverIP() string TempDir() string TorArgs() []string TorBinary() string TunnelDir() string UserAgent() string }
ExperimentSession is the experiment's view of a session.
type HTTPClient ¶
HTTPClient is an http.Client-like interface.
type HTTPSSvc ¶
type HTTPSSvc struct { // ALPN contains the ALPNs inside the HTTPS reply. ALPN []string // IPv4 contains the IPv4 hints (which may be empty). IPv4 []string // IPv6 contains the IPv6 hints (which may be empty). IPv6 []string }
HTTPSSvc is the reply to an HTTPS DNS query.
type HTTPTransport ¶
type HTTPTransport interface { // Network returns the network used by the transport, which // should be one of "tcp" and "quic". Network() string // RoundTrip performs the HTTP round trip. RoundTrip(req *http.Request) (*http.Response, error) // CloseIdleConnections closes idle connections. CloseIdleConnections() }
HTTPTransport is an http.Transport-like structure.
type InfoLogger ¶
type InfoLogger interface { // An InfoLogger is also a DebugLogger. DebugLogger // Info emits an informational message. Info(msg string) // Infof formats and emits an informational message. Infof(format string, v ...interface{}) }
InfoLogger is a logger emitting debug and infor messages.
type KeyValueStore ¶
type KeyValueStore interface { // Get gets the value of the given key or returns an // error if there is no such key or we cannot read // from the key-value store. Get(key string) (value []byte, err error) // Set sets the value of the given key and returns // whether the operation was successful or not. Set(key string, value []byte) (err error) }
KeyValueStore is a generic key-value store.
type Logger ¶
type Logger interface { // A Logger is also an InfoLogger. InfoLogger // Warn emits a warning message. Warn(msg string) // Warnf formats and emits a warning message. Warnf(format string, v ...interface{}) }
Logger defines the common interface that a logger should have. It is out of the box compatible with `log.Log` in `apex/log`.
var DiscardLogger Logger = logDiscarder{}
DiscardLogger is the default logger that discards its input
type Measurement ¶
type Measurement struct { // Annotations contains results annotations Annotations map[string]string `json:"annotations,omitempty"` // DataFormatVersion is the version of the data format DataFormatVersion string `json:"data_format_version"` // Extensions contains information about the extensions included // into the test_keys of this measurement. Extensions map[string]int64 `json:"extensions,omitempty"` // ID is the locally generated measurement ID ID string `json:"id,omitempty"` // Input is the measurement input Input MeasurementTarget `json:"input"` // InputHashes contains input hashes InputHashes []string `json:"input_hashes,omitempty"` // MeasurementStartTime is the time when the measurement started MeasurementStartTime string `json:"measurement_start_time"` // MeasurementStartTimeSaved is the moment in time when we // started the measurement. This is not included into the JSON // and is only used within probe-engine as a "zero" time. MeasurementStartTimeSaved time.Time `json:"-"` // Options contains command line options Options []string `json:"options,omitempty"` // ProbeASN contains the probe autonomous system number ProbeASN string `json:"probe_asn"` // ProbeCC contains the probe country code ProbeCC string `json:"probe_cc"` // ProbeCity contains the probe city ProbeCity string `json:"probe_city,omitempty"` // ProbeIP contains the probe IP ProbeIP string `json:"probe_ip,omitempty"` // ProbeNetworkName contains the probe network name ProbeNetworkName string `json:"probe_network_name"` // ReportID contains the report ID ReportID string `json:"report_id"` // ResolverASN is the ASN of the resolver ResolverASN string `json:"resolver_asn"` // ResolverIP is the resolver IP ResolverIP string `json:"resolver_ip"` // ResolverNetworkName is the network name of the resolver. ResolverNetworkName string `json:"resolver_network_name"` // SoftwareName contains the software name SoftwareName string `json:"software_name"` // SoftwareVersion contains the software version SoftwareVersion string `json:"software_version"` // TestHelpers contains the test helpers. It seems this structure is more // complex than we would like. In particular, using a map from string to // string does not fit into the web_connectivity use case. Hence, for now // we're going to represent this using interface{}. In going forward we // may probably want to have more uniform test helpers. TestHelpers map[string]interface{} `json:"test_helpers,omitempty"` // TestKeys contains the real test result. This field is opaque because // each experiment will insert here a different structure. TestKeys interface{} `json:"test_keys"` // TestName contains the test name TestName string `json:"test_name"` // MeasurementRuntime contains the measurement runtime. The JSON name // is test_runtime because this is the name expected by the OONI backend // even though that name is clearly a misleading one. MeasurementRuntime float64 `json:"test_runtime"` // TestStartTime contains the test start time TestStartTime string `json:"test_start_time"` // TestVersion contains the test version TestVersion string `json:"test_version"` }
Measurement is a OONI measurement.
This structure is compatible with the definition of the base data format in https://github.com/ooni/spec/blob/master/data-formats/df-000-base.md.
func (*Measurement) AddAnnotation ¶
func (m *Measurement) AddAnnotation(key, value string)
AddAnnotation adds a single annotations to m.Annotations.
func (*Measurement) AddAnnotations ¶
func (m *Measurement) AddAnnotations(input map[string]string)
AddAnnotations adds the annotations from input to m.Annotations.
func (*Measurement) MaybeRewriteTestKeys ¶
func (m *Measurement) MaybeRewriteTestKeys( currentIP string, marshal func(interface{}) ([]byte, error)) error
MaybeRewriteTestKeys is the function called by Scrub that ensures that m's serialization doesn't include the IP
func (*Measurement) Scrub ¶
func (m *Measurement) Scrub(probeIP string) (err error)
Scrub scrubs the probeIP out of the measurement.
type MeasurementTarget ¶
type MeasurementTarget string
MeasurementTarget is the target of a OONI measurement.
func (MeasurementTarget) MarshalJSON ¶
func (t MeasurementTarget) MarshalJSON() ([]byte, error)
MarshalJSON serializes the MeasurementTarget.
type OOAPICheckInConfig ¶
type OOAPICheckInConfig struct { Charging bool `json:"charging"` // Charging indicate if the phone is actually charging OnWiFi bool `json:"on_wifi"` // OnWiFi indicate if the phone is actually connected to a WiFi network Platform string `json:"platform"` // Platform of the probe ProbeASN string `json:"probe_asn"` // ProbeASN is the probe country code ProbeCC string `json:"probe_cc"` // ProbeCC is the probe country code RunType RunType `json:"run_type"` // RunType SoftwareName string `json:"software_name"` // SoftwareName of the probe SoftwareVersion string `json:"software_version"` // SoftwareVersion of the probe WebConnectivity OOAPICheckInConfigWebConnectivity `json:"web_connectivity"` // WebConnectivity class contain an array of categories }
OOAPICheckInConfig contains configuration for calling the checkin API.
type OOAPICheckInConfigWebConnectivity ¶
type OOAPICheckInConfigWebConnectivity struct {
CategoryCodes []string `json:"category_codes"` // CategoryCodes is an array of category codes
}
OOAPICheckInConfigWebConnectivity is the configuration for the WebConnectivity test
type OOAPICheckInInfo ¶
type OOAPICheckInInfo struct {
WebConnectivity *OOAPICheckInInfoWebConnectivity `json:"web_connectivity"`
}
OOAPICheckInInfo contains the return test objects from the checkin API
type OOAPICheckInInfoWebConnectivity ¶
type OOAPICheckInInfoWebConnectivity struct { ReportID string `json:"report_id"` URLs []OOAPIURLInfo `json:"urls"` }
OOAPICheckInInfoWebConnectivity contains the array of URLs returned by the checkin API
type OOAPIService ¶
type OOAPIService struct { // Address is the address of the server. Address string `json:"address"` // Type is the type of the service. Type string `json:"type"` // Front is the front to use with "cloudfront" type entries. Front string `json:"front,omitempty"` }
OOAPIService describes a backend service.
The fields of this struct have the meaning described in v2.0.0 of the OONI bouncer specification defined by https://github.com/ooni/spec/blob/master/backends/bk-004-bouncer.md.
type OOAPITorTarget ¶
type OOAPITorTarget struct { // Address is the address of the target. Address string `json:"address"` // Name is the name of the target. Name string `json:"name"` // Params contains optional params for, e.g., pluggable transports. Params map[string][]string `json:"params"` // Protocol is the protocol to use with the target. Protocol string `json:"protocol"` // Source is the source from which we fetched this specific // target. Whenever the source is non-empty, we will treat // this specific target as a private target. Source string `json:"source"` }
OOAPITorTarget is a target for the tor experiment.
type OOAPIURLInfo ¶
type OOAPIURLInfo struct { CategoryCode string `json:"category_code"` CountryCode string `json:"country_code"` URL string `json:"url"` }
OOAPIURLInfo contains info on a test lists URL
type OOAPIURLListConfig ¶
type OOAPIURLListConfig struct { Categories []string // Categories to query for (empty means all) CountryCode string // CountryCode is the optional country code Limit int64 // Max number of URLs (<= 0 means no limit) }
OOAPIURLListConfig contains configuration for fetching the URL list.
type PrinterCallbacks ¶
type PrinterCallbacks struct {
Logger
}
PrinterCallbacks is the default event handler
func NewPrinterCallbacks ¶
func NewPrinterCallbacks(logger Logger) PrinterCallbacks
NewPrinterCallbacks returns a new default callback handler
func (PrinterCallbacks) OnProgress ¶
func (d PrinterCallbacks) OnProgress(percentage float64, message string)
OnProgress provides information about an experiment progress.
type QUICDialer ¶
type QUICDialer 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. // // Recommended tlsConfig setup: // // - set ServerName to be the SNI; // // - set RootCAs to NewDefaultCertPool(); // // - set NextProtos to []string{"h3"}. // // Typically, you want to pass `&quic.Config{}` as quicConfig. DialContext(ctx context.Context, network, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlyConnection, error) // CloseIdleConnections closes idle connections, if any. CloseIdleConnections() }
QUICDialer dials QUIC sessions.
type QUICListener ¶
type QUICListener interface { // Listen creates a new listening UDPLikeConn. Listen(addr *net.UDPAddr) (UDPLikeConn, error) }
QUICListener listens for QUIC connections.
type Resolver ¶
type Resolver interface { // LookupHost behaves like net.Resolver.LookupHost. LookupHost(ctx context.Context, hostname string) (addrs []string, err error) // Network returns the resolver type (e.g., system, dot, doh). Network() string // Address returns the resolver address (e.g., 8.8.8.8:53). Address() string // CloseIdleConnections closes idle connections, if any. CloseIdleConnections() // LookupHTTPS issues an HTTPS query for a domain. LookupHTTPS( ctx context.Context, domain string) (*HTTPSSvc, error) // LookupNS issues a NS query for a domain. LookupNS(ctx context.Context, domain string) ([]*net.NS, error) }
Resolver performs domain name resolutions.
type SimpleDialer ¶
type SimpleDialer interface { // DialContext behaves like net.Dialer.DialContext. DialContext(ctx context.Context, network, address string) (net.Conn, error) }
SimpleDialer establishes network connections.
type TLSDialer ¶
type TLSDialer interface { // CloseIdleConnections closes idle connections, if any. CloseIdleConnections() // DialTLSContext dials a TLS connection. This method will always return // to you a oohttp.TLSConn, so you can always safely cast to it. DialTLSContext(ctx context.Context, network, address string) (net.Conn, error) }
TLSDialer is a Dialer dialing TLS connections.
type TLSHandshaker ¶
type TLSHandshaker interface { // Handshake creates a new TLS connection from the given connection and // the given config. This function DOES NOT take ownership of the connection // and it's your responsibility to close it on failure. // // Recommended tlsConfig setup: // // - set ServerName to be the SNI; // // - set RootCAs to NewDefaultCertPool(); // // - set NextProtos to []string{"h2", "http/1.1"} for HTTPS // and []string{"dot"} for DNS-over-TLS. // // QUIRK: The returned connection will always implement the TLSConn interface // exposed by ooni/oohttp. A future version of this interface may instead // return directly a TLSConn to avoid unconditional castings. Handshake(ctx context.Context, conn net.Conn, tlsConfig *tls.Config) ( net.Conn, tls.ConnectionState, error) }
TLSHandshaker is the generic TLS handshaker.
type UDPLikeConn ¶
type UDPLikeConn interface { // An UDPLikeConn is a net.PacketConn conn. net.PacketConn // SetReadBuffer allows setting the read buffer. SetReadBuffer(bytes int) error // SyscallConn returns a conn suitable for calling syscalls, // which is also instrumental to setting the read buffer. SyscallConn() (syscall.RawConn, error) }
UDPLikeConn is a net.PacketConn with some extra functions required to convince the QUIC library (lucas-clemente/quic-go) to inflate the receive buffer of the connection.
The QUIC library will treat this connection as a "dumb" net.PacketConn, calling its ReadFrom and WriteTo methods as opposed to more efficient methods that are available under Linux and (maybe?) FreeBSD.
It seems fine to avoid performance optimizations, because they would complicate the implementation on our side and our use cases (blocking and heavy throttling) do not seem to require such optimizations.
See https://github.com/ooni/probe/issues/1754 for a more comprehensive discussion of UDPLikeConn.
type UnderlyingNetworkLibrary ¶
type UnderlyingNetworkLibrary interface { // ListenUDP creates a new model.UDPLikeConn conn. ListenUDP(network string, laddr *net.UDPAddr) (UDPLikeConn, error) // LookupHost lookups a domain using the stdlib resolver. LookupHost(ctx context.Context, domain string) ([]string, error) // NewSimpleDialer returns a new SimpleDialer. NewSimpleDialer(timeout time.Duration) SimpleDialer }
UnderlyingNetworkLibrary defines the basic functionality from which the network extensions depend. By changing the default implementation of this interface, we can implement a wide array of tests, including self censorship tests.