stats

package
v7.6.175 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: GPL-3.0 Imports: 5 Imported by: 3

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 Noop added in v7.6.46

type Noop struct{}

Noop is a no-op implementation of Tracker

func (*Noop) AddListener added in v7.6.46

func (s *Noop) AddListener(_ func(newStats Stats)) (close func())

AddListener registers a new listener for stats updates and returns a function that can be used to close the listener.

func (*Noop) ClearAlert added in v7.6.46

func (s *Noop) ClearAlert(alertType AlertType)

ClearAlert clears the alert state if the current alert has the specific type.

func (*Noop) IncAdsBlocked added in v7.6.46

func (s *Noop) IncAdsBlocked()

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

func (*Noop) IncHTTPSUpgrades added in v7.6.46

func (s *Noop) IncHTTPSUpgrades()

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

func (*Noop) Latest added in v7.6.46

func (s *Noop) Latest() Stats

Latest returns the latest Stats that are being tracked

func (*Noop) SetActiveProxyLocation added in v7.6.46

func (s *Noop) SetActiveProxyLocation(city string, country string, countryCode string)

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

func (*Noop) SetAlert added in v7.6.46

func (s *Noop) SetAlert(alertType AlertType, details string, transient bool)

SetAlert indicates that some alert needs user attention. If transient is true, the alert will be cleared automatically 10 seconds later.

func (*Noop) SetDisconnected added in v7.6.46

func (s *Noop) SetDisconnected(val bool)

SetDisconnected indicates that we've entered disconnected mode

func (*Noop) SetHasSucceedingProxy added in v7.6.46

func (s *Noop) SetHasSucceedingProxy(val bool)

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

func (*Noop) SetHitDataCap added in v7.6.46

func (s *Noop) SetHitDataCap(val bool)

SetHitDataCap indicates that we've hit the data cap

func (*Noop) SetIsPro added in v7.6.46

func (s *Noop) SetIsPro(val bool)

SetIsPro indicates that we're pro

func (*Noop) SetYinbiEnabled added in v7.6.46

func (s *Noop) SetYinbiEnabled(val bool)

SetYinbiEnabled indicates that the user is eligible to participate in the Yinbi giveaway

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 NewNoop added in v7.6.46

func NewNoop() Tracker

Returns a new Noop Tracker

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