settings

package
v0.0.0-...-b80b294 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UserConfig

func UserConfig(settings *Settings) sdkcommon.UserConfig

UserConfig creates a new user config from the given settings

Types

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 EmptySettings

func EmptySettings() *Settings

EmptySettings returns a new settings instance without loading any file from disk.

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

Jump to

Keyboard shortcuts

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