Documentation ¶
Overview ¶
package internalsdk implements the mobile application functionality of flashlight
Index ¶
- func AllocateRelayAddress(localAddr string) (string, error)
- func BytesToFloat64LittleEndian(b []byte) (float64, error)
- func BytesToInt64Slice(b []byte) []int
- func CheckForUpdates(deviceInfo DeviceInfo) (string, error)
- func ConvertToUserDetailsResponse(userResponse *protos.LoginResponse) *protos.User
- func CreateBinaryFile(name string, data protoreflect.ProtoMessage) error
- func Debug(tag, msg string)
- func DownloadUpdate(deviceInfo DeviceInfo, url, apkPath string, updater Updater) bool
- func Error(tag, msg string)
- func GenerateEncryptedKey(password string, email string, salt []byte) *big.Int
- func GenerateRandomString(length int) string
- func GenerateSalt() ([]byte, error)
- func InstallFinished(deviceInfo DeviceInfo, success bool)
- func Int64SliceToBytes(int64Slice []int) []byte
- 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 StringToIntSlice(str string) ([]int, error)
- func ToString(value int64) string
- func Tun2Socks(fd int, socksAddr, dnsGrabAddr string, mtu int, wrappedSession Session) error
- type AdProvider
- type AdSettings
- type AppInfo
- type Arguments
- type ChangeSet
- type ClientSession
- type DeviceInfo
- type EmailMessage
- type EmailResponseHandler
- type GeoCallback
- type MessagingModel
- type Model
- type PanickingSession
- type ReplicaServer
- type Session
- type SessionModel
- func (m *SessionModel) BandwidthUpdate(p1 int, p2 int, p3 int, p4 int) error
- func (m *SessionModel) ChatEnable() bool
- 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) IpAddress() (string, 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) SetAuthEnabled(authEnabled bool)
- func (m *SessionModel) SetChatEnabled(chatEnabled bool)
- func (m *SessionModel) SetCountry(country string) error
- func (m *SessionModel) SetHasConfigFetched(fetached bool)
- func (m *SessionModel) SetHasProxyFetched(fetached bool)
- func (m *SessionModel) SetIP(ipAddress string) error
- func (m *SessionModel) SetOnSuccess(fetached bool)
- func (m *SessionModel) SetReplicaAddr(replicaAddr string)
- func (m *SessionModel) SetShowGoogleAds(adsEnable bool)
- func (m *SessionModel) SetShowTapSellAds(adsEnable bool)
- func (m *SessionModel) SetStaging(staging bool) error
- func (m *SessionModel) SetUserIdAndToken(p1 int64, p2 string) error
- func (m *SessionModel) SplitTunnelingEnabled() (bool, error)
- 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 Survey
- type SurveyInfo
- type SurveyModel
- type SurveyResponse
- 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 ¶
This section is empty.
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 BytesToInt64Slice ¶
func CheckForUpdates ¶
func CheckForUpdates(deviceInfo DeviceInfo) (string, error)
CheckForUpdates checks to see if a new version of Lantern is available
func ConvertToUserDetailsResponse ¶
func ConvertToUserDetailsResponse(userResponse *protos.LoginResponse) *protos.User
func CreateBinaryFile ¶
func CreateBinaryFile(name string, data protoreflect.ProtoMessage) error
create binary data from proto
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 GenerateEncryptedKey ¶
Takes password and email, salt and returns encrypted key
func GenerateRandomString ¶
func GenerateSalt ¶
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 Int64SliceToBytes ¶
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 StringToIntSlice ¶
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 AppInfo ¶
type AppInfo struct { PackageName string `json:"packageName"` Name string `json:"name"` Icon []int `json:"icon"` }
Define the struct to match the JSON structure
type ChangeSet ¶
type ChangeSet struct {
// contains filtered or unexported fields
}
ChangeSet represents changes in a database.
type ClientSession ¶
type ClientSession interface { GetDeviceID() (string, error) GetUserID() (int64, error) GetToken() (string, error) Locale() (string, error) SetUserIdAndToken(int64, string) error }
ClientSession includes information needed to create a new client session
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 PanickingSession ¶
type PanickingSession interface { common.AuthConfig SetCountry(string) UpdateAdSettings(AdSettings) UpdateStats(string, string, string, int, int, bool) SetStaging(bool) BandwidthUpdate(int, int, int, int) Locale() string GetTimeZone() string Code() string GetCountryCode() string GetForcedCountryCode() string GetDNSServer() string Provider() string IsStoreVersion() bool Email() string Currency() string DeviceOS() string IsProUser() bool SetAuthEnabled(bool) SetChatEnabled(bool) SetIP(string) SplitTunnelingEnabled() bool SetShowGoogleAds(bool) SetShowTapSellAds(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 SetHasConfigFetched(bool) SetHasProxyFetched(bool) SetUserIdAndToken(int64, string) SetOnSuccess(bool) ChatEnable() bool Wrapped() Session }
PanickingSession wraps the Session interface but panics instead of returning errors
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 { ClientSession GetAppName() string 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 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 SetAuthEnabled(bool) SetChatEnabled(bool) SplitTunnelingEnabled() (bool, error) SetShowGoogleAds(bool) SetShowTapSellAds(bool) SetHasConfigFetched(bool) SetHasProxyFetched(bool) SetUserIdAndToken(int64, string) error SetOnSuccess(bool) ChatEnable() 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..... percent: Long, remaining: Long, allowed: Long, ttlSeconds: Long Name become part of Objective c so this is important
func (*SessionModel) ChatEnable ¶
func (m *SessionModel) ChatEnable() bool
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) IpAddress ¶
func (m *SessionModel) IpAddress() (string, error)
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) SetAuthEnabled ¶
func (m *SessionModel) SetAuthEnabled(authEnabled bool)
func (*SessionModel) SetChatEnabled ¶
func (m *SessionModel) SetChatEnabled(chatEnabled bool)
func (*SessionModel) SetCountry ¶
func (m *SessionModel) SetCountry(country string) error
func (*SessionModel) SetHasConfigFetched ¶
func (m *SessionModel) SetHasConfigFetched(fetached bool)
func (*SessionModel) SetHasProxyFetched ¶
func (m *SessionModel) SetHasProxyFetched(fetached bool)
func (*SessionModel) SetIP ¶
func (m *SessionModel) SetIP(ipAddress string) error
SetIP stores the IP address of the client after a successful geolookup
func (*SessionModel) SetOnSuccess ¶
func (m *SessionModel) SetOnSuccess(fetached bool)
func (*SessionModel) SetReplicaAddr ¶
func (m *SessionModel) SetReplicaAddr(replicaAddr string)
func (*SessionModel) SetShowGoogleAds ¶
func (m *SessionModel) SetShowGoogleAds(adsEnable bool)
func (*SessionModel) SetShowTapSellAds ¶
func (m *SessionModel) SetShowTapSellAds(adsEnable bool)
func (*SessionModel) SetStaging ¶
func (m *SessionModel) SetStaging(staging bool) error
func (*SessionModel) SetUserIdAndToken ¶
func (m *SessionModel) SetUserIdAndToken(p1 int64, p2 string) error
Keep name as p1,p2 somehow is conflicting with objective c p1 is userid and p2 is token
func (*SessionModel) SplitTunnelingEnabled ¶
func (m *SessionModel) SplitTunnelingEnabled() (bool, error)
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 Survey ¶
type Survey struct { Enabled bool `json:"enabled"` Probability float64 `json:"probability"` Campaign string `json:"campaign"` URL string `json:"url"` Message string `json:"message"` Thanks string `json:"thanks"` Button string `json:"button"` ShowPlansScreen *bool `json:"showPlansScreen,omitempty"` }
type SurveyInfo ¶
type SurveyModel ¶
type SurveyModel struct {
*SessionModel
}
func NewSurveyModel ¶
func NewSurveyModel(session SessionModel) (*SurveyModel, error)
SurveyModel is a custom model derived from the baseModel.
func (SurveyModel) InvokeMethod ¶
InvokeMethod handles method invocations on the model.
func (*SurveyModel) IsSurveyAvalible ¶
func (s *SurveyModel) IsSurveyAvalible() (*Survey, error)
IsSurveyAvalible checks if the survey is available for the user.
func (SurveyModel) Subscribe ¶
func (m SurveyModel) Subscribe(req *SubscriptionRequest) error
Subscribe subscribes to database changes based on the provided request.
func (SurveyModel) Unsubscribe ¶
func (m SurveyModel) Unsubscribe(path string)
Unsubscribe unsubscribes from database changes using the provided ID.
type SurveyResponse ¶
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.