Documentation ¶
Overview ¶
package internalsdk implements the mobile application functionality of flashlight
Index ¶
- Variables
- func AllocateRelayAddress(localAddr string) (string, error)
- func BytesToFloat64LittleEndian(b []byte) (float64, error)
- func CheckForUpdates(deviceInfo DeviceInfo) (string, error)
- func Debug(tag, msg string)
- func DownloadUpdate(deviceInfo DeviceInfo, url, apkPath string, updater Updater) bool
- func Error(tag, msg string)
- func InstallFinished(deviceInfo DeviceInfo, success bool)
- func NewReplicaServer(handler *replicaServer.HttpHandler) (net.Listener, *http.Server, error)
- func NewStatsTracker(session panickingSession) *statsTracker
- func RelayTo(relayAddr string) (string, error)
- func SDKVersion() string
- func SendIssueReport(session Session, issueType string, description string, ...) error
- func SetGeoInfo(cb GeoCallback)
- func StopTun2Socks()
- func Tun2Socks(fd int, socksAddr, dnsGrabAddr string, mtu int, wrappedSession Session) error
- type AdProvider
- type AdSettings
- type Arguments
- type ChangeSet
- type DeviceInfo
- type EmailMessage
- type EmailResponseHandler
- type GeoCallback
- type MessagingModel
- type Model
- type ReplicaServer
- type Session
- type SessionModel
- func (m *SessionModel) BandwidthUpdate(p1 int, p2 int, p3 int, p4 int) error
- func (m *SessionModel) Code() (string, error)
- func (m *SessionModel) Currency() (string, error)
- func (m *SessionModel) DeviceOS() (string, error)
- func (m *SessionModel) Email() (string, error)
- func (m *SessionModel) ForceReplica() bool
- func (m *SessionModel) GetAppName() string
- func (m *SessionModel) GetCountryCode() (string, error)
- func (m *SessionModel) GetDNSServer() (string, error)
- func (m *SessionModel) GetDeviceID() (string, error)
- func (m *SessionModel) GetForcedCountryCode() (string, error)
- func (m *SessionModel) GetTimeZone() (string, error)
- func (m *SessionModel) GetToken() (string, error)
- func (m *SessionModel) GetUserID() (int64, error)
- func (m SessionModel) InvokeMethod(method string, arguments Arguments) (*minisql.Value, error)
- func (m *SessionModel) IsProUser() (bool, error)
- func (m *SessionModel) IsStoreVersion() (bool, error)
- func (m *SessionModel) Locale() (string, error)
- func (m SessionModel) Name() string
- func (m *SessionModel) Provider() (string, error)
- func (m *SessionModel) SerializedInternalHeaders() (string, error)
- func (m *SessionModel) SetChatEnabled(chatEnable bool)
- func (m *SessionModel) SetCountry(country string) error
- func (m *SessionModel) SetIP(ipAddress string) error
- func (m *SessionModel) SetReplicaAddr(replicaAddr string)
- func (m *SessionModel) SetShowInterstitialAdsEnabled(adsEnable bool)
- func (m *SessionModel) SetStaging(staging bool) error
- func (m *SessionModel) SplitTunnelingEnabled() (bool, error)
- func (m *SessionModel) StartService(configDir string, locale string, settings Settings)
- func (m SessionModel) Subscribe(req *SubscriptionRequest) error
- func (m SessionModel) Unsubscribe(path string)
- func (m *SessionModel) UpdateAdSettings(adsetting AdSettings) error
- func (m *SessionModel) UpdateStats(serverCity string, serverCountry string, serverCountryCode string, p3 int, ...) error
- type SessionModelOpts
- type Settings
- type StartResult
- type SubscriptionRequest
- type SurveyInfo
- type Update
- type Updater
- type UpdaterModel
- type VPNManager
- type VPNModel
- func (m *VPNModel) GetVPNStatus() (string, error)
- func (m VPNModel) InvokeMethod(method string, arguments Arguments) (*minisql.Value, error)
- func (m VPNModel) Name() string
- func (m *VPNModel) SaveVPNStatus(status string) error
- func (s *VPNModel) SetManager(manager VPNManager)
- func (m VPNModel) Subscribe(req *SubscriptionRequest) error
- func (m *VPNModel) SwitchVPN(on bool) error
- func (m VPNModel) Unsubscribe(path string)
- func (m *VPNModel) UpdateBandwidth(percent int64, remaining int64, allowedint int64, ttlSeconds int64) error
Constants ¶
This section is empty.
Variables ¶
var ( // This gets set at build time ApplicationVersion = "9999.99.99" // This gets set at build time RevisionDate = "" )
Functions ¶
func AllocateRelayAddress ¶
AllocateRelay allocates a relay location at which peers can relay WebRTC traffic to us. If successful, it starts relaying traffic to/from the localAddr and returns the URL at which peers should connect in order to start relaying.
func CheckForUpdates ¶
func CheckForUpdates(deviceInfo DeviceInfo) (string, error)
CheckForUpdates checks to see if a new version of Lantern is available
func DownloadUpdate ¶
func DownloadUpdate(deviceInfo DeviceInfo, url, apkPath string, updater Updater) bool
DownloadUpdate downloads the latest APK from the given url to the apkPath file destination.
func InstallFinished ¶
func InstallFinished(deviceInfo DeviceInfo, success bool)
InstallFinished is called after an update successfully installs or fails to and records ops related to it
func NewReplicaServer ¶
func NewReplicaServer(handler *replicaServer.HttpHandler) (net.Listener, *http.Server, error)
NewReplicaServer uses 'handler' to setup a new net.Listener for Replica on localhost over the next available TCP port.
Returns an http.Server configured with a Replica http.Handler and a TCP listener bound to a random port
func NewStatsTracker ¶
func NewStatsTracker(session panickingSession) *statsTracker
func SendIssueReport ¶
func SetGeoInfo ¶
func SetGeoInfo(cb GeoCallback)
SetGetGeoInfo set's the client's current geo info on the given GeoCallback (if available).
func Tun2Socks ¶
Tun2Socks wraps the TUN device identified by fd with an ipproxy server that does the following:
1. dns packets (any UDP packets to port 53) are routed to dnsGrabAddr 2. All other udp packets are routed directly to their destination 3. All TCP traffic is routed through the Lantern proxy at the given socksAddr.
Types ¶
type AdProvider ¶
type AdProvider interface { GetNativeBannerZoneID() string GetStandardBannerZoneID() string GetInterstitialZoneID() string ShouldShowAd() bool }
AdProvider provides information for displaying an ad and makes decisions on whether or not to display it.
type AdSettings ¶
type AdSettings interface { // GetAdProvider gets an ad provider if and only if ads are enabled based on the passed parameters. GetAdProvider(isPro bool, countryCode string, daysSinceInstalled int) (AdProvider, error) }
AdSettings is an interface for retrieving mobile ad settings from the global config
type ChangeSet ¶
type ChangeSet struct {
// contains filtered or unexported fields
}
ChangeSet represents changes in a database.
type DeviceInfo ¶
type DeviceInfo interface { DeviceID() string Model() string Hardware() string SdkVersion() int UserID() string }
DeviceInfo provides information about a device for sending with ops when downloading and installing auto-updates
type EmailMessage ¶
EmailMessage exposes the type email.Message as part of this package.
func (*EmailMessage) PutInt ¶
func (msg *EmailMessage) PutInt(key string, val int)
PutInt sets an integer variable
func (*EmailMessage) PutString ¶
func (msg *EmailMessage) PutString(key string, val string)
PutString sets a string variable
func (*EmailMessage) Send ¶
func (msg *EmailMessage) Send(handler EmailResponseHandler)
Send sends this EmailMessage using the email package.
type EmailResponseHandler ¶
type EmailResponseHandler interface { OnError(errMsg string) OnSuccess() }
EmailResponseHandler is used to return a response to the client in the event there's an error sending an email
type GeoCallback ¶
type MessagingModel ¶
type MessagingModel struct {
// contains filtered or unexported fields
}
Messing Model
func NewMessagingModel ¶
func NewMessagingModel(mdb minisql.DB) (*MessagingModel, error)
func (MessagingModel) InvokeMethod ¶
InvokeMethod handles method invocations on the model.
func (MessagingModel) Subscribe ¶
func (m MessagingModel) Subscribe(req *SubscriptionRequest) error
Subscribe subscribes to database changes based on the provided request.
func (MessagingModel) Unsubscribe ¶
func (m MessagingModel) Unsubscribe(path string)
Unsubscribe unsubscribes from database changes using the provided ID.
type Model ¶
type Model interface { Name() string InvokeMethod(method string, arguments Arguments) (*minisql.Value, error) Subscribe(req *SubscriptionRequest) error Unsubscribe(id string) }
Model defines the methods that any model should implement
type ReplicaServer ¶
type ReplicaServer struct { ConfigDir string Flashlight *flashlight.Flashlight Session Session UserConfig common.UserConfig // contains filtered or unexported fields }
Replica HTTP Server that handles Replica API requests on localhost at a random port.
func (*ReplicaServer) CheckEnabled ¶
func (s *ReplicaServer) CheckEnabled()
Checks whether Replica should be enabled and lazily starts the server if necessary.
If enabled, the server is started lazily and the server's random address is reported to Session.SetReplicaAddr. If disabled after having been enabled, the server keeps running and ReplicaAddr remains set to its old value.
type Session ¶
type Session interface { GetAppName() string GetDeviceID() (string, error) GetUserID() (int64, error) GetToken() (string, error) SetCountry(string) error SetIP(string) error UpdateAdSettings(AdSettings) error UpdateStats(serverCity string, serverCountry string, serverCountryCode string, p3 int, p4 int, hasSucceedingProxy bool) error SetStaging(bool) error BandwidthUpdate(int, int, int, int) error Locale() (string, error) GetTimeZone() (string, error) Code() (string, error) GetCountryCode() (string, error) GetForcedCountryCode() (string, error) GetDNSServer() (string, error) Provider() (string, error) IsStoreVersion() (bool, error) Email() (string, error) Currency() (string, error) DeviceOS() (string, error) IsProUser() (bool, error) SetReplicaAddr(string) ForceReplica() bool SetChatEnabled(bool) SplitTunnelingEnabled() (bool, error) SetShowInterstitialAdsEnabled(bool) // workaround for lack of any sequence types in gomobile bind... ;_; // used to implement GetInternalHeaders() map[string]string // Should return a JSON encoded map[string]string {"key":"val","key2":"val", ...} SerializedInternalHeaders() (string, error) }
Session provides an interface for interacting with the Android Java/Kotlin code. Note - all methods return an error so that Go has the opportunity to inspect any exceptions thrown from the Java code. If a method interface doesn't include an error, exceptions on the Java side immediately result in a panic from which Go cannot recover.
type SessionModel ¶
type SessionModel struct {
// contains filtered or unexported fields
}
Custom Model implemnation SessionModel is a custom model derived from the baseModel.
func NewSessionModel ¶
func NewSessionModel(mdb minisql.DB, opts *SessionModelOpts) (*SessionModel, error)
NewSessionModel initializes a new SessionModel instance.
func (*SessionModel) BandwidthUpdate ¶
Keep name as p1,p2,p3..... Name become part of Objective c so this is important
func (*SessionModel) Code ¶
func (m *SessionModel) Code() (string, error)
Todo change method name to referral code
func (*SessionModel) Currency ¶
func (m *SessionModel) Currency() (string, error)
func (*SessionModel) DeviceOS ¶
func (m *SessionModel) DeviceOS() (string, error)
func (*SessionModel) Email ¶
func (m *SessionModel) Email() (string, error)
func (*SessionModel) ForceReplica ¶
func (m *SessionModel) ForceReplica() bool
func (*SessionModel) GetAppName ¶
func (m *SessionModel) GetAppName() string
func (*SessionModel) GetCountryCode ¶
func (m *SessionModel) GetCountryCode() (string, error)
Todo need to make chanegs for Force country setup
func (*SessionModel) GetDNSServer ¶
func (m *SessionModel) GetDNSServer() (string, error)
func (*SessionModel) GetDeviceID ¶
func (m *SessionModel) GetDeviceID() (string, error)
func (*SessionModel) GetForcedCountryCode ¶
func (m *SessionModel) GetForcedCountryCode() (string, error)
func (*SessionModel) GetTimeZone ¶
func (m *SessionModel) GetTimeZone() (string, error)
func (*SessionModel) GetToken ¶
func (m *SessionModel) GetToken() (string, error)
func (*SessionModel) GetUserID ¶
func (m *SessionModel) GetUserID() (int64, error)
Todo There is some issue with user id changeing it value When Coverting from bytes to Float
func (SessionModel) InvokeMethod ¶
InvokeMethod handles method invocations on the model.
func (*SessionModel) IsProUser ¶
func (m *SessionModel) IsProUser() (bool, error)
func (*SessionModel) IsStoreVersion ¶
func (m *SessionModel) IsStoreVersion() (bool, error)
func (*SessionModel) Locale ¶
func (m *SessionModel) Locale() (string, error)
func (*SessionModel) Provider ¶
func (m *SessionModel) Provider() (string, error)
func (*SessionModel) SerializedInternalHeaders ¶
func (m *SessionModel) SerializedInternalHeaders() (string, error)
func (*SessionModel) SetChatEnabled ¶
func (m *SessionModel) SetChatEnabled(chatEnable bool)
func (*SessionModel) SetCountry ¶
func (m *SessionModel) SetCountry(country string) error
func (*SessionModel) SetIP ¶
func (m *SessionModel) SetIP(ipAddress string) error
SetIP stores the IP address of the client after a successful geolookup
func (*SessionModel) SetReplicaAddr ¶
func (m *SessionModel) SetReplicaAddr(replicaAddr string)
func (*SessionModel) SetShowInterstitialAdsEnabled ¶
func (m *SessionModel) SetShowInterstitialAdsEnabled(adsEnable bool)
func (*SessionModel) SetStaging ¶
func (m *SessionModel) SetStaging(staging bool) error
func (*SessionModel) SplitTunnelingEnabled ¶
func (m *SessionModel) SplitTunnelingEnabled() (bool, error)
func (*SessionModel) StartService ¶
func (m *SessionModel) StartService(configDir string, locale string, settings Settings)
Internal functions that manage method
func (SessionModel) Subscribe ¶
func (m SessionModel) Subscribe(req *SubscriptionRequest) error
Subscribe subscribes to database changes based on the provided request.
func (SessionModel) Unsubscribe ¶
func (m SessionModel) Unsubscribe(path string)
Unsubscribe unsubscribes from database changes using the provided ID.
func (*SessionModel) UpdateAdSettings ¶
func (m *SessionModel) UpdateAdSettings(adsetting AdSettings) error
func (*SessionModel) UpdateStats ¶
func (m *SessionModel) UpdateStats(serverCity string, serverCountry string, serverCountryCode string, p3 int, p4 int, hasSucceedingProxy bool) error
Note - the names of these parameters have to match what's defined on the `Session` interface
type SessionModelOpts ¶
type StartResult ¶
StartResult provides information about the started Lantern
func Start ¶
func Start(configDir string, locale string, settings Settings, wrappedSession Session) (*StartResult, error)
Start starts a HTTP and SOCKS proxies at random addresses. It blocks up till the given timeout waiting for the proxy to listen, and returns the addresses at which it is listening (HTTP, SOCKS). If the proxy doesn't start within the given timeout, this method returns an error.
If a Lantern proxy is already running within this process, that proxy is reused.
Note - this does not wait for the entire initialization sequence to finish, just for the proxy to be listening. Once the proxy is listening, one can start to use it, even as it finishes its initialization sequence. However, initial activity may be slow, so clients with low read timeouts may time out.
type SubscriptionRequest ¶
type SubscriptionRequest struct { ID string PathPrefixes string JoinDetails bool ReceiveInitial bool Updater UpdaterModel }
SubscriptionRequest defines the structure of a subscription request.
type SurveyInfo ¶
type Updater ¶
type Updater autoupdate.Updater
type UpdaterModel ¶
UpdaterModel defines an interface to handle database changes.
type VPNManager ¶
type VPNManager interface { StartVPN() StopVPN() }
type VPNModel ¶
type VPNModel struct {
// contains filtered or unexported fields
}
Custom Model implemnation VPNModel is a custom model derived from the baseModel.
func (*VPNModel) GetVPNStatus ¶
func (VPNModel) InvokeMethod ¶
InvokeMethod handles method invocations on the model.
func (*VPNModel) SaveVPNStatus ¶
func (*VPNModel) SetManager ¶
func (s *VPNModel) SetManager(manager VPNManager)
func (VPNModel) Subscribe ¶
func (m VPNModel) Subscribe(req *SubscriptionRequest) error
Subscribe subscribes to database changes based on the provided request.
func (VPNModel) Unsubscribe ¶
func (m VPNModel) Unsubscribe(path string)
Unsubscribe unsubscribes from database changes using the provided ID.