Documentation
¶
Overview ¶
Package session models a measurement session.
Index ¶
- type Session
- func (s *Session) ASNDatabasePath() string
- func (s *Session) AddAvailableHTTPSBouncer(baseURL string)
- func (s *Session) AddAvailableHTTPSCollector(baseURL string)
- func (s *Session) CABundlePath() string
- func (s *Session) CountryDatabasePath() string
- func (s *Session) MaybeLookupBackends(ctx context.Context) (err error)
- func (s *Session) MaybeLookupCollectors(ctx context.Context) error
- func (s *Session) MaybeLookupLocation(ctx context.Context) (err error)
- func (s *Session) MaybeLookupTestHelpers(ctx context.Context) error
- func (s *Session) NewOrchestraClient(ctx context.Context) (*orchestra.Client, error)
- func (s *Session) ProbeASN() uint
- func (s *Session) ProbeASNString() string
- func (s *Session) ProbeCC() string
- func (s *Session) ProbeIP() string
- func (s *Session) ProbeNetworkName() string
- func (s *Session) ResolverASN() uint
- func (s *Session) ResolverASNString() string
- func (s *Session) ResolverIP() string
- func (s *Session) ResolverNetworkName() string
- func (s *Session) UserAgent() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct {
// AssetsDir is the directory where to store assets.
AssetsDir string
// AvailableBouncers contains the available bouncers.
AvailableBouncers []model.Service
// AvailableCollectors contains the available collectors.
AvailableCollectors []model.Service
// AvailableTestHelpers contains the available test helpers.
AvailableTestHelpers map[string][]model.Service
// ExplicitProxy indicates that the user has explicitly
// configured a proxy and wants us to know that. For more
// info, see the documentation of New.
ExplicitProxy bool
// HTTPDefaultClient is the default HTTP client to use.
HTTPDefaultClient *http.Client
// HTTPNoProxyClient is a non-proxied HTTP client.
HTTPNoProxyClient *http.Client
// KVStore is a key-value store used by this session.
KVStore model.KeyValueStore
// Logger is the log emitter.
Logger log.Logger
// PrivacySettings contains the collector privacy settings. The default
// is to only redact the user's IP address from results.
PrivacySettings model.PrivacySettings
// SoftwareName contains the software name.
SoftwareName string
// SoftwareVersion contains the software version.
SoftwareVersion string
// TempDir is the directory where to store temporary files
TempDir string
// TLSConfig contains the TLS config
TLSConfig *tls.Config
// contains filtered or unexported fields
}
Session contains information on a measurement session.
func New ¶
func New( logger log.Logger, softwareName, softwareVersion, assetsDir string, proxy *url.URL, tlsConfig *tls.Config, tempDir string, kvstore model.KeyValueStore, ) *Session
New creates a new experiments session. The logger is the logger to use. The softwareName and softwareVersion identify the application that we're using. The assetsDir is the directory where assets will be downloaded and searched for. The proxy and tlsConfig arguments are more complicated as explained below.
We configure two HTTP clients. The default client is used to contact services where the communication may be proxided. The non proxied client is for running measurements. The proxy argument only influences the former as the latter is not proxied in any case. (You can always edit the session after New has returned if you don't like this policy.)
If proxy is nil, we'll configure the default client to use http.ProxyFromEnvironment. This means that we'll honour the HTTP_PROXY environment variable, if present. If proxy is non nil, we'll use it as a proxy unconditionally. Also, in the latter case, we'll keep track of the fact that we've an explicit proxy, and will do our best to avoid confusing services like mlab-ns, that may be confused by a proxy.
Regarding tlsConfig, passing nil will always be a good idea, as in that case Go is more flexible in upgrading to http2, while with a custom CA it will not use http2. Yet, there may also be cases where a specific CA is still required. See the documention of httpx.NewTransport for more information on this.
func (*Session) ASNDatabasePath ¶
ASNDatabasePath returns the path where the ASN database path should be if you have called s.FetchResourcesIdempotent.
func (*Session) AddAvailableHTTPSBouncer ¶
AddAvailableHTTPSBouncer adds the HTTP bouncer base URL to the list of URLs that are tried.
func (*Session) AddAvailableHTTPSCollector ¶
AddAvailableHTTPSCollector adds an HTTP collector base URL to the list of URLs that are tried.
func (*Session) CABundlePath ¶
CABundlePath is like ASNDatabasePath but for the CA bundle path.
func (*Session) CountryDatabasePath ¶
CountryDatabasePath is like ASNDatabasePath but for the country DB path.
func (*Session) MaybeLookupBackends ¶
MaybeLookupBackends discovers the available OONI backends. For each backend type, we query the bouncer only if we don't already have information.
This is equivalent to calling MaybeLookupCollectors followed by calling MaybeLookupTestHelpers if MaybeLookupCollectors succeeds.
func (*Session) MaybeLookupCollectors ¶
MaybeLookupCollectors discovers collector information unless this bit of information has already been configured or discovered.
func (*Session) MaybeLookupLocation ¶
MaybeLookupLocation discovers details on the probe location only if this information it not already available.
func (*Session) MaybeLookupTestHelpers ¶
MaybeLookupTestHelpers is like MaybeLookupCollectors for test helpers.
func (*Session) NewOrchestraClient ¶ added in v0.3.0
NewOrchestraClient creates a new orchestra client. This client is registered and logged in with the OONI orchestra. An error is returned on failure.
func (*Session) ProbeASNString ¶
ProbeASNString returns the probe ASN as a string.
func (*Session) ProbeNetworkName ¶
ProbeNetworkName returns the probe network name.
func (*Session) ResolverASN ¶ added in v0.5.0
ResolverASN returns the resolver ASN
func (*Session) ResolverASNString ¶ added in v0.5.0
ResolverASNString returns the resolver ASN as a string
func (*Session) ResolverIP ¶
ResolverIP returns the resolver IP
func (*Session) ResolverNetworkName ¶ added in v0.5.0
ResolverNetworkName returns the resolver network name.