Help us shape the future of Go! Take the 2026 Go Developer Survey

stats

package
v7.5.39 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: GPL-3.0 Imports: 5 Imported by: 4

Documentation

Index

Constants

View Source
const (
	STATUS_CONNECTING   = "connecting"
	STATUS_CONNECTED    = "connected"
	STATUS_DISCONNECTED = "disconnected"
	STATUS_THROTTLED    = "throttled"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	AlertType AlertType `json:"alertType"`
	Details   string    `json:"alertDetails"`
	HelpURL   string    `json:"helpURL"`
}

func (Alert) Alert

func (e Alert) Alert() string

type AlertType

type AlertType string
const (
	FAIL_TO_SET_SYSTEM_PROXY AlertType = "fail_to_set_system_proxy"
	FAIL_TO_OPEN_BROWSER     AlertType = "fail_to_open_browser"
	// TODO: code to trigger this alert
	NO_INTERNET_CONNECTION AlertType = "no_internet_connection"
)

type Stats

type Stats struct {
	City               string  `json:"city"`
	Country            string  `json:"country"`
	CountryCode        string  `json:"countryCode"`
	HTTPSUpgrades      int     `json:"httpsUpgrades"`
	AdsBlocked         int     `json:"adsBlocked"`
	Disconnected       bool    `json:"disconnected"`
	HasSucceedingProxy bool    `json:"hasSucceedingProxy"`
	HitDataCap         bool    `json:"hitDataCap"`
	IsPro              bool    `json:"isPro"`
	YinbiEnabled       bool    `json:"yinbiEnabled"`
	Status             string  `json:"status"`
	Alerts             []Alert `json:"alerts"`
}

Stats are stats and status of the current Lantern

type Tracker

type Tracker interface {
	// Latest returns the latest Stats that are being tracked
	Latest() Stats

	// AddListener registers a new listener for stats updates and returns a
	// function that can be used to close the listener.
	AddListener(func(newStats Stats)) (close func())

	// SetActiveProxyLocation updates the location of last successfully dialed
	// proxy. countryCode is in ISO Alpha-2 form, see
	// http://www.nationsonline.org/oneworld/country_code_list.htm
	SetActiveProxyLocation(city, country, countryCode string)

	// IncHTTPSUpgrades indicates that Lantern client redirects a HTTP request
	// to HTTPS via HTTPSEverywhere.
	IncHTTPSUpgrades()

	// IncAdsBlocked indicates that a proxy request is blocked per easylist rules.
	IncAdsBlocked()

	// SetDisconnected indicates that we've entered disconnected mode
	SetDisconnected(val bool)

	// SetHasSucceedingProxy indicates that we do (or don't) have a succeeding
	// proxy.
	SetHasSucceedingProxy(val bool)

	// SetHitDataCap indicates that we've hit the data cap
	SetHitDataCap(val bool)

	// SetIsPro indicates that we're pro
	SetIsPro(val bool)

	// SetYinbiEnabled indicates that the user is eligible to participate in the
	// Yinbi giveaway
	SetYinbiEnabled(val bool)

	// SetAlert indicates that some alert needs user attention. If transient is
	// true, the alert will be cleared automatically 10 seconds later.
	SetAlert(alertType AlertType, details string, transient bool)

	// ClearAlert clears the alert state if the current alert has the specific
	// type.
	ClearAlert(alertType AlertType)
}

Tracker is a common interface to receive user perceptible Lantern stats

func NewTracker

func NewTracker() Tracker

NewTracker creates a new Tracker

Jump to

Keyboard shortcuts

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