app

package
v0.0.0-...-97b48c1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: GPL-3.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingTab = errors.New("missing tab")
	AccountTab    = Tab("account")
	DeveloperTab  = Tab("developer")
	VPNTab        = Tab("vpn")
	UnknownTab    = Tab("")
)

Functions

func LoconfScanner

func LoconfScanner(settings *Settings, configDir string, interval time.Duration, proChecker func() (bool, bool), iconURL func() string) (stop func())

LoconfScanner starts a goroutine to periodically check for new loconf files. This will show announcements via desktop notification. Each announcement is shown only once. It will also do things like check for updates to uninstall survey config

interval: The duration between each check.

proChecker: A function to check if current user is Pro (to decide whether show the announcement or not).

Returns a function to stop the loop.

func NewStatsTracker

func NewStatsTracker() *statsTracker

Types

type App

type App struct {
	Flags flashlight.Flags // Command-line flags passed to the app.
	// contains filtered or unexported fields
}

App is the core of the Lantern desktop application, managing components and configurations.

func NewApp

func NewApp() (*App, error)

NewApp creates a new desktop app that initializes the app and acts as a moderator between all desktop components.

func NewAppWithFlags

func NewAppWithFlags(flags flashlight.Flags, configDir string) (*App, error)

NewAppWithFlags creates a new App instance with the given flags and configuration directory.

func (*App) AddExitFunc

func (app *App) AddExitFunc(label string, exitFunc func())

AddExitFunc adds a function to be called before the application exits.

func (*App) AuthClient

func (app *App) AuthClient() auth.AuthClient

func (*App) Connect

func (app *App) Connect()

Connect turns on proxying

func (*App) Disconnect

func (app *App) Disconnect()

Disconnect turns off proxying

func (*App) Exit

func (app *App) Exit(err error) bool

Exit tells the application to exit, optionally supplying an error that caused the exit. Returns true if the app is actually exiting, false if exit has already been requested.

func (*App) FetchUserData

func (app *App) FetchUserData() error

Client session methods this method get call when user is being created first time

func (*App) GetDeviceID

func (app *App) GetDeviceID() (string, error)

func (*App) GetHasConfigFetched

func (app *App) GetHasConfigFetched() bool

func (*App) GetHasProxyFetched

func (app *App) GetHasProxyFetched() bool

func (*App) GetLanguage

func (app *App) GetLanguage() string

GetLanguage returns the user language

func (*App) GetOnSuccess

func (app *App) GetOnSuccess() bool

func (*App) GetUserFirstVisit

func (app *App) GetUserFirstVisit() (bool, error)

func (*App) HasSucceedingProxy

func (app *App) HasSucceedingProxy() bool

HasSucceedingProxy returns whether or not the app is currently configured with any succeeding proxies

func (*App) IsFeatureEnabled

func (app *App) IsFeatureEnabled(feature string) bool

IsFeatureEnabled checks whether or not the given feature is enabled by flashlight

func (*App) IsPro

func (app *App) IsPro() bool

IsPro indicates whether or not the app is pro

func (*App) IsProUser

func (app *App) IsProUser(ctx context.Context, uc common.UserConfig) (bool, bool)

func (*App) IsProUserFast

func (app *App) IsProUserFast() (isPro bool, statusKnown bool)

IsProUserFast indicates whether or not the user is pro and whether or not the user's status is know, never calling the Pro API to determine the status.

func (*App) IsUserLoggedIn

func (app *App) IsUserLoggedIn() bool

func (*App) LogPanicAndExit

func (app *App) LogPanicAndExit(msg string)

is only used in the panicwrap parent process.

func (*App) OnSettingChange

func (app *App) OnSettingChange(attr SettingName, cb func(interface{}))

OnSettingChange sets a callback cb to get called when attr is changed from server. When calling multiple times for same attr, only the last one takes effect.

func (*App) OnStatsChange

func (app *App) OnStatsChange(fn func(stats.Stats))

OnStatsChange adds a listener for Stats changes.

func (*App) ProClient

func (app *App) ProClient() proclient.ProClient

func (*App) ProxyAddrReachable

func (app *App) ProxyAddrReachable(ctx context.Context) error

ProxyAddrReachable checks if Lantern's HTTP proxy responds with the correct status within the deadline.

func (*App) RefreshUserData

func (app *App) RefreshUserData() (*protos.User, error)

func (*App) Run

func (app *App) Run(ctx context.Context) error

Run creates a new instance of App, initializes necessary components, and starts running the application.

func (*App) SendConfig

func (app *App) SendConfig()

func (*App) SendMessageToUI

func (app *App) SendMessageToUI(service string, message interface{})

Create func that send message to UI

func (*App) SetEmailAddress

func (app *App) SetEmailAddress(email string) error

func (*App) SetExpiration

func (app *App) SetExpiration(exp int64) error

func (*App) SetLanguage

func (app *App) SetLanguage(lang string)

SetLanguage sets the user language

func (*App) SetProUser

func (app *App) SetProUser(pro bool) error

func (*App) SetReferralCode

func (app *App) SetReferralCode(referral string) error

func (*App) SetUserData

func (app *App) SetUserData(ctx context.Context, userID int64, u *protos.User)

SetUserData stores the user data in the cache

func (*App) SetUserDevices

func (app *App) SetUserDevices(userID int64, devices []*protos.Device)

SetUserDevices updates the list of devices associated with a user in the cache.

func (*App) SetUserIDAndToken

func (app *App) SetUserIDAndToken(id int64, token string) error

func (*App) SetUserLoggedIn

func (app *App) SetUserLoggedIn(value bool)

func (*App) Settings

func (app *App) Settings() *Settings

func (*App) Stats

func (app *App) Stats() stats.Stats

func (*App) SysProxyOff

func (app *App) SysProxyOff() error

func (*App) SysproxyOn

func (app *App) SysproxyOn() error

func (*App) UserConfig

func (app *App) UserConfig() common.UserConfig

UserConfig returns the current user configuration after applying settings.

func (*App) UserData

func (app *App) UserData(args ...int64) (*protos.User, bool)

UserData retrieves the user data from the cache.

func (*App) WaitForExit

func (app *App) WaitForExit() error

WaitForExit waits for a request to exit the application.

func (*App) WebsocketAddr

func (app *App) WebsocketAddr() string

type SettingName

type SettingName string

SettingName is the name of a setting.

const (
	SNAutoReport   SettingName = "autoReport"
	SNAutoLaunch   SettingName = "autoLaunch"
	SNProxyAll     SettingName = "proxyAll"
	SNGoogleAds    SettingName = "googleAds"
	SNSystemProxy  SettingName = "systemProxy"
	SNDisconnected SettingName = "disconnected"

	SNLanguage       SettingName = "lang"
	SNCountry        SettingName = "country"
	SNLocalHTTPToken SettingName = "localHTTPToken"

	SNDeviceID                  SettingName = "deviceID"
	SNEmailAddress              SettingName = "emailAddress"
	SNUserID                    SettingName = "userID"
	SNUserToken                 SettingName = "userToken"
	SNUserPro                   SettingName = "userPro"
	SNReferralCode              SettingName = "referralCode"
	SNMigratedDeviceIDForUserID SettingName = "migratedDeviceIDForUserID"
	SNTakenSurveys              SettingName = "takenSurveys"
	SNPastAnnouncements         SettingName = "pastAnnouncements"

	SNAddr      SettingName = "addr"
	SNSOCKSAddr SettingName = "socksAddr"
	SNUIAddr    SettingName = "uiAddr"

	SNVersion            SettingName = "version"
	SNBuildDate          SettingName = "buildDate"
	SNRevisionDate       SettingName = "revisionDate"
	SNEnabledExperiments SettingName = "enabledExperiments"

	// Auth methods
	SNUserFirstVisit SettingName = "userFirstVisit"
	SNExpiryDate     SettingName = "expirydate"
	SNUserLoggedIn   SettingName = "userLoggedIn"
	SNSalt           SettingName = "salt"
)

type Settings

type Settings struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Settings is a struct of all settings unique to this particular Lantern instance.

func LoadSettings

func LoadSettings(configDir string) *Settings

LoadSettings loads the initial settings at startup, either from disk or using defaults.

func LoadSettingsFrom

func LoadSettingsFrom(version, revisionDate, buildDate, path string) *Settings

func (*Settings) GetAddr

func (s *Settings) GetAddr() string

GetAddr gets the HTTP proxy address.

func (*Settings) GetAppName

func (s *Settings) GetAppName() string

func (*Settings) GetCountry

func (s *Settings) GetCountry() string

GetCountry returns the user country

func (*Settings) GetDeviceID

func (s *Settings) GetDeviceID() string

GetDeviceID returns the unique ID of this device.

func (*Settings) GetDisconnected

func (s *Settings) GetDisconnected() bool

GetDisconnected returns whether or not we're disconnected

func (*Settings) GetEmailAddress

func (s *Settings) GetEmailAddress() string

GetEmailAddress gets the email address of pro users.

func (*Settings) GetEnabledExperiments

func (s *Settings) GetEnabledExperiments() []string

GetEnabledExperiments returns the names of the Lantern experiment IDs that were enabled via flags.

func (*Settings) GetExpirationDate

func (s *Settings) GetExpirationDate() string

func (*Settings) GetGoogleAds

func (s *Settings) GetGoogleAds() bool

GetGoogleAds returns whether or not to proxy all traffic.

func (*Settings) GetInt64Eventually

func (s *Settings) GetInt64Eventually(name SettingName) (int64, error)

GetInt64Eventually blocks returning an int64 until the int has a value other than the defualt.

func (*Settings) GetInternalHeaders

func (s *Settings) GetInternalHeaders() map[string]string

GetInternalHeaders returns extra headers sent with requests to internal services

func (*Settings) GetLanguage

func (s *Settings) GetLanguage() string

GetLanguage returns the user language

func (*Settings) GetLocalHTTPToken

func (s *Settings) GetLocalHTTPToken() string

GetLocalHTTPToken returns the local HTTP token.

func (*Settings) GetMigratedDeviceIDForUserID

func (s *Settings) GetMigratedDeviceIDForUserID() int64

GetMigratedDeviceIDForUserID returns the user ID (if any) for which the current device's ID has been migrated from the old style to the new style

func (*Settings) GetPastAnnouncements

func (s *Settings) GetPastAnnouncements() []string

GetPastAnnouncements returns past campaign announcements

func (*Settings) GetProxyAll

func (s *Settings) GetProxyAll() bool

GetProxyAll returns whether or not to proxy all traffic.

func (*Settings) GetReferralCode

func (s *Settings) GetReferralCode() string

GetReferralCode returns the user referral code

func (*Settings) GetSOCKSAddr

func (s *Settings) GetSOCKSAddr() string

GetSOCKSAddr returns the SOCKS proxy address.

func (*Settings) GetSalt

func (s *Settings) GetSalt() []byte

func (*Settings) GetSystemProxy

func (s *Settings) GetSystemProxy() bool

GetSystemProxy returns whether or not to set system proxy when lantern starts

func (*Settings) GetTakenSurveys

func (s *Settings) GetTakenSurveys() []string

GetTakenSurveys returns the IDs of surveys the user has already taken.

func (*Settings) GetTimeZone

func (s *Settings) GetTimeZone() (string, error)

func (*Settings) GetToken

func (s *Settings) GetToken() string

GetToken returns the user token

func (*Settings) GetUIAddr

func (s *Settings) GetUIAddr() string

GetUIAddr returns the address of the UI, stored across runs to avoid a different port on each run, which breaks things like local storage in the UI.

func (*Settings) GetUserFirstVisit

func (s *Settings) GetUserFirstVisit() bool

GetUserFirstVisit returns the user's first visit flag

func (*Settings) GetUserID

func (s *Settings) GetUserID() int64

GetUserID returns the user ID

func (*Settings) IsAutoLaunch

func (s *Settings) IsAutoLaunch() bool

IsAutoLaunch returns whether or not to automatically launch on system startup.

func (*Settings) IsAutoReport

func (s *Settings) IsAutoReport() bool

IsAutoReport returns whether or not to auto-report debugging and analytics data.

func (*Settings) IsProUser

func (s *Settings) IsProUser() bool

func (*Settings) IsUserLoggedIn

func (s *Settings) IsUserLoggedIn() bool

func (*Settings) Locale

func (s *Settings) Locale() string

Locale returns the user language

func (*Settings) OnChange

func (s *Settings) OnChange(attr SettingName, cb func(interface{}))

OnChange sets a callback cb to get called when attr is changed from UI.

func (*Settings) SaveSalt

func (s *Settings) SaveSalt(salt []byte)

func (*Settings) SetAddr

func (s *Settings) SetAddr(addr string)

SetAddr sets the HTTP proxy address.

func (*Settings) SetCountry

func (s *Settings) SetCountry(country string)

SetCountry sets the user's country.

func (*Settings) SetDisconnected

func (s *Settings) SetDisconnected(disconnected bool)

SetDisconnected sets whether or not we're disconnected

func (*Settings) SetEmailAddress

func (s *Settings) SetEmailAddress(email string)

SetEmailAddress locally stores the email address of a pro user

func (*Settings) SetEnabledExperiments

func (s *Settings) SetEnabledExperiments(ex []string)

SetEnabledExperiments sets the Lantern experiment IDs that were enabled via flags.

func (*Settings) SetExpiration

func (s *Settings) SetExpiration(expiration int64)

func (*Settings) SetExpirationDate

func (s *Settings) SetExpirationDate(date string)

func (*Settings) SetGoogleAds

func (s *Settings) SetGoogleAds(g bool)

SetGoogleAds sets whether or not to proxy all traffic.

func (*Settings) SetLanguage

func (s *Settings) SetLanguage(language string)

SetLanguage sets the user language

func (*Settings) SetLocalHTTPToken

func (s *Settings) SetLocalHTTPToken(token string)

SetLocalHTTPToken sets the local HTTP token, stored on disk because we've seen weird issues on Windows where the OS remembers old, inactive PAC URLs with old tokens and uses them, breaking Edge and IE.

func (*Settings) SetMigratedDeviceIDForUserID

func (s *Settings) SetMigratedDeviceIDForUserID(userID int64)

SetMigratedDeviceIDForUserID stores the user ID (if any) for which the current device's ID has been migrated from the old style to the new style

func (*Settings) SetPastAnnouncements

func (s *Settings) SetPastAnnouncements(announcements []string)

SetPastAnnouncements sets past campaigns announcements

func (*Settings) SetProUser

func (s *Settings) SetProUser(value bool)

func (*Settings) SetProxyAll

func (s *Settings) SetProxyAll(proxyAll bool)

SetProxyAll sets whether or not to proxy all traffic.

func (*Settings) SetReferralCode

func (s *Settings) SetReferralCode(referralCode string)

SetReferralCode sets the user referral code

func (*Settings) SetSOCKSAddr

func (s *Settings) SetSOCKSAddr(addr string)

SetSOCKSAddr sets the SOCKS proxy address.

func (*Settings) SetTakenSurveys

func (s *Settings) SetTakenSurveys(campaigns []string)

SetTakenSurveys sets the IDs of taken surveys.

func (*Settings) SetUIAddr

func (s *Settings) SetUIAddr(uiaddr string)

SetUIAddr sets the last known UI address.

func (*Settings) SetUserFirstVisit

func (s *Settings) SetUserFirstVisit(value bool)

Auth methods SetUserFirstVisit sets the user's first visit flag

func (*Settings) SetUserIDAndToken

func (s *Settings) SetUserIDAndToken(id int64, token string)

SetUserIDAndToken sets the user ID and token atomically

func (*Settings) SetUserLoggedIn

func (s *Settings) SetUserLoggedIn(value bool)

func (*Settings) StartService

func (s *Settings) StartService(channel ws.UIChannel) error

StartService starts the settings service that synchronizes Lantern's configuration with every UI client

type Tab

type Tab string

Identifies a specific tab in the desktop app

func ParseTab

func ParseTab(s string) (Tab, error)

Parse the given string into a Tab

Jump to

Keyboard shortcuts

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