session

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package session models a measurement session.

Index

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

	// 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

	// 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,
) *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

func (s *Session) ASNDatabasePath() string

ASNDatabasePath returns the path where the ASN database path should be if you have called s.FetchResourcesIdempotent.

func (*Session) AddAvailableHTTPSBouncer

func (s *Session) AddAvailableHTTPSBouncer(baseURL string)

AddAvailableHTTPSBouncer adds the HTTP bouncer base URL to the list of URLs that are tried.

func (*Session) AddAvailableHTTPSCollector

func (s *Session) AddAvailableHTTPSCollector(baseURL string)

AddAvailableHTTPSCollector adds an HTTP collector base URL to the list of URLs that are tried.

func (*Session) CABundlePath

func (s *Session) CABundlePath() string

CABundlePath is like ASNDatabasePath but for the CA bundle path.

func (*Session) CountryDatabasePath

func (s *Session) CountryDatabasePath() string

CountryDatabasePath is like ASNDatabasePath but for the country DB path.

func (*Session) MaybeLookupBackends

func (s *Session) MaybeLookupBackends(ctx context.Context) (err error)

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

func (s *Session) MaybeLookupCollectors(ctx context.Context) error

MaybeLookupCollectors discovers collector information unless this bit of information has already been configured or discovered.

func (*Session) MaybeLookupLocation

func (s *Session) MaybeLookupLocation(ctx context.Context) (err error)

MaybeLookupLocation discovers details on the probe location only if this information it not already available.

func (*Session) MaybeLookupTestHelpers

func (s *Session) MaybeLookupTestHelpers(ctx context.Context) error

MaybeLookupTestHelpers is like MaybeLookupCollectors for test helpers.

func (*Session) ProbeASN added in v0.1.1

func (s *Session) ProbeASN() uint

ProbeASN returns the probe ASN as an integer.

func (*Session) ProbeASNString

func (s *Session) ProbeASNString() string

ProbeASNString returns the probe ASN as a string.

func (*Session) ProbeCC

func (s *Session) ProbeCC() string

ProbeCC returns the probe CC.

func (*Session) ProbeIP

func (s *Session) ProbeIP() string

ProbeIP returns the probe IP.

func (*Session) ProbeNetworkName

func (s *Session) ProbeNetworkName() string

ProbeNetworkName returns the probe network name.

func (*Session) ResolverIP

func (s *Session) ResolverIP() string

ResolverIP returns the resolver IP

func (*Session) UserAgent

func (s *Session) UserAgent() string

UserAgent constructs the user agent to be used in this session.

Jump to

Keyboard shortcuts

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