collector

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package collector contains a OONI collector client implementation.

Specifically we implement v2.0.0 of the OONI collector specification defined in https://github.com/ooni/spec/blob/master/backends/bk-003-collector.md.

Index

Constants

View Source
const (
	// DefaultDataFormatVersion is the default data format version
	DefaultDataFormatVersion = "0.2.0"

	// DefaultFormat is the default format
	DefaultFormat = "json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// BaseURL is the bouncer base URL.
	BaseURL string

	// HTTPClient is the HTTP client to use.
	HTTPClient *http.Client

	// Logger is the logger to use.
	Logger log.Logger

	// UserAgent is the user agent to use.
	UserAgent string
}

Client is a client for the OONI collector API.

func (*Client) OpenReport

func (c *Client) OpenReport(
	ctx context.Context, rt ReportTemplate,
) (*Report, error)

OpenReport opens a new report.

type Report

type Report struct {
	// ID is the report ID
	ID string
	// contains filtered or unexported fields
}

Report is an open report

func (*Report) Close

func (r *Report) Close(ctx context.Context) error

Close closes the report. Returns nil on success; an error on failure.

func (*Report) SubmitMeasurement

func (r *Report) SubmitMeasurement(
	ctx context.Context, m *model.Measurement,
) error

SubmitMeasurement submits a measurement belonging to the report to the OONI collector. We will unconditionally modify the measurement with the ReportID it should contain. If the collector supports sending back to us a measurement ID, we also update the m.OOID field with it.

type ReportTemplate

type ReportTemplate struct {
	// DataFormatVersion is unconditionally set to `0.2.0` and you don't
	// need to be concerned about it.
	DataFormatVersion string `json:"data_format_version"`

	// Format is unconditionally set to `json` and you don't need
	// to be concerned about it.
	Format string `json:"format"`

	// ProbeASN is the probe's autonomous system number (e.g. `AS1234`)
	ProbeASN string `json:"probe_asn"`

	// ProbeCC is the probe's country code (e.g. `IT`)
	ProbeCC string `json:"probe_cc"`

	// SoftwareName is the app name (e.g. `measurement-kit`)
	SoftwareName string `json:"software_name"`

	// SoftwareVersion is the app version (e.g. `0.9.1`)
	SoftwareVersion string `json:"software_version"`

	// TestName is the test name (e.g. `ndt`)
	TestName string `json:"test_name"`

	// TestVersion is the test version (e.g. `1.0.1`)
	TestVersion string `json:"test_version"`
}

ReportTemplate is the template for opening a report

Jump to

Keyboard shortcuts

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