mysterium

package
v0.0.0-...-365054f Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: GPL-3.0 Imports: 65 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MigrationStatusRequired means new there is new Hermes and identity required to migrate to it
	MigrationStatusRequired = "required"
	// MigrationStatusFinished means migration to new Hermes finished or not needed
	MigrationStatusFinished = "finished"
)
View Source
const AutoNATType = "auto"

AutoNATType passed as NATCompatibility parameter in proposal request indicates NAT type should be probed automatically immediately within given request

Variables

This section is empty.

Functions

func GetServiceTypes

func GetServiceTypes() ([]byte, error)

GetServiceTypes returns all possible service types

func NewWireGuardConnection

func NewWireGuardConnection(opts wireGuardOptions, device wireguardDevice, ipResolver ip.Resolver, handshakeWaiter wireguard_connection.HandshakeWaiter) (connection.Connection, error)

NewWireGuardConnection creates a new wireguard connection

func SetFlagLauncherVersion

func SetFlagLauncherVersion(val string)

SetFlagLauncherVersion sets LauncherVersion flag value, which is reported to Prometheus

Types

type BalanceChangeCallback

type BalanceChangeCallback interface {
	OnChange(identityAddress string, balance float64)
}

BalanceChangeCallback represents balance change callback.

type BuildInfo

type BuildInfo struct {
	Commit      string `json:"commit"`
	Branch      string `json:"branch"`
	BuildNumber string `json:"build_number"`
}

BuildInfo represents node build info.

type ConnectRequest

type ConnectRequest struct {
	Providers               string // comma separated list of providers that will be used for the connection.
	IdentityAddress         string
	ServiceType             string
	CountryCode             string
	IPType                  string
	SortBy                  string
	DNSOption               string
	IncludeMonitoringFailed bool
}

ConnectRequest represents connect request.

  • DNSOption:
  • - "auto" (default) tries the following with fallbacks: provider's DNS -> client's system DNS -> public DNS
  • - "provider" uses DNS servers from provider's system configuration
  • - "system" uses DNS servers from client's system configuration

type ConnectResponse

type ConnectResponse struct {
	ErrorCode    string
	ErrorMessage string
}

ConnectResponse represents connect response with optional error code and message.

type ConnectionStatusChangeCallback

type ConnectionStatusChangeCallback interface {
	OnChange(status string)
}

ConnectionStatusChangeCallback represents status callback.

type ConsumerPaymentConfig

type ConsumerPaymentConfig struct {
	PriceGiBMax  string
	PriceHourMax string
}

ConsumerPaymentConfig defines consumer side payment configuration

type CreatePaymentGatewayOrderReq

type CreatePaymentGatewayOrderReq struct {
	IdentityAddress string
	Gateway         string
	MystAmount      string
	AmountUSD       string
	PayCurrency     string
	Country         string
	State           string
	// GatewayCallerData is marshaled json that is accepting by the payment gateway.
	GatewayCallerData []byte
}

CreatePaymentGatewayOrderReq is used to create a new order.

type Estimates

type Estimates struct {
	VideoMinutes    int64
	MusicMinutes    int64
	BrowsingMinutes int64
	TrafficMB       int64
	PricePerGB      float64
	PricePerMin     float64
}

Estimates represent estimated entertainment

type GatewayClientCallbackReq

type GatewayClientCallbackReq struct {
	IdentityAddress     string
	Gateway             string
	GooglePurchaseToken string
	GoogleProductID     string
}

GatewayClientCallbackReq is the payload for GatewayClientCallback.

type GatewaysResponse

type GatewaysResponse struct {
	Name         string              `json:"name"`
	OrderOptions PaymentOrderOptions `json:"order_options"`
	Currencies   []string            `json:"currencies"`
}

GatewaysResponse represents a respose which cointains gateways and their data.

type GetBalanceRequest

type GetBalanceRequest struct {
	IdentityAddress string
}

GetBalanceRequest represents balance request.

type GetBalanceResponse

type GetBalanceResponse struct {
	Balance float64
}

GetBalanceResponse represents balance response.

type GetGatewaysRequest

type GetGatewaysRequest struct {
	OptionsCurrency string
}

GetGatewaysRequest request for GetGateways.

type GetIdentityRegistrationFeesResponse

type GetIdentityRegistrationFeesResponse struct {
	Fee float64
}

GetIdentityRegistrationFeesResponse represents identity registration fees result.

type GetIdentityRequest

type GetIdentityRequest struct {
	Address    string
	Passphrase string
}

GetIdentityRequest represents identity request.

type GetIdentityResponse

type GetIdentityResponse struct {
	IdentityAddress    string
	ChannelAddress     string
	RegistrationStatus string
}

GetIdentityResponse represents identity response.

type GetLocationResponse

type GetLocationResponse struct {
	IP      string
	Country string
}

GetLocationResponse represents location response.

type GetPaymentOrderRequest

type GetPaymentOrderRequest struct {
	IdentityAddress string
	ID              string
}

GetPaymentOrderRequest a request to get an order.

type GetProposalRequest

type GetProposalRequest struct {
	ProviderID  string
	ServiceType string
}

GetProposalRequest represents proposal request.

type GetProposalsRequest

type GetProposalsRequest struct {
	ServiceType      string
	LocationCountry  string
	IPType           string
	Refresh          bool
	PriceHourMax     float64
	PriceGiBMax      float64
	QualityMin       float32
	PresetID         int
	NATCompatibility string
}

GetProposalsRequest represents proposals request.

type GetStatusResponse

type GetStatusResponse struct {
	State    string
	Proposal proposalDTO
}

GetStatusResponse represents status response.

type HealthCheckData

type HealthCheckData struct {
	Uptime    string     `json:"uptime"`
	Version   string     `json:"version"`
	BuildInfo *BuildInfo `json:"build_info"`
}

HealthCheckData represents node health check info.

type IdentityRegistrationChangeCallback

type IdentityRegistrationChangeCallback interface {
	OnChange(identityAddress string, status string)
}

IdentityRegistrationChangeCallback represents identity registration status callback.

type ListOrdersRequest

type ListOrdersRequest struct {
	IdentityAddress string
}

ListOrdersRequest a request to list orders.

type MigrationStatus

type MigrationStatus = string

MigrationStatus status of the migration

type MigrationStatusResponse

type MigrationStatusResponse struct {
	Status MigrationStatus `json:"status"`
}

MigrationStatusResponse represents status of the migration

type MobileNode

type MobileNode struct {
	// contains filtered or unexported fields
}

MobileNode represents node object tuned for mobile device.

func NewNode

func NewNode(appPath string, options *MobileNodeOptions) (*MobileNode, error)

NewNode function creates new Node.

func (*MobileNode) CalculateEstimates

func (mb *MobileNode) CalculateEstimates(amount float64) *Estimates

CalculateEstimates calculates average service times

func (*MobileNode) Connect

func (mb *MobileNode) Connect(req *ConnectRequest) *ConnectResponse

Connect connects to given provider.

func (*MobileNode) CreatePaymentGatewayOrder

func (mb *MobileNode) CreatePaymentGatewayOrder(req *CreatePaymentGatewayOrderReq) ([]byte, error)

CreatePaymentGatewayOrder creates a payment order.

func (*MobileNode) Disconnect

func (mb *MobileNode) Disconnect() error

Disconnect disconnects or cancels current connection.

func (*MobileNode) ExchangeRate

func (mb *MobileNode) ExchangeRate(quote string) (float64, error)

ExchangeRate returns MYST rate in quote currency.

func (*MobileNode) ExportIdentity

func (mb *MobileNode) ExportIdentity(identityAddress, newPassphrase string) ([]byte, error)

ExportIdentity exports a given identity address encrypting it with the new passphrase.

func (*MobileNode) ForceBalanceUpdate

func (mb *MobileNode) ForceBalanceUpdate(req *GetBalanceRequest) *GetBalanceResponse

ForceBalanceUpdate force updates balance and returns the updated balance.

func (*MobileNode) GatewayClientCallback

func (mb *MobileNode) GatewayClientCallback(req *GatewayClientCallbackReq) error

GatewayClientCallback triggers payment callback for google from client side.

func (*MobileNode) GetAllServicesState

func (mb *MobileNode) GetAllServicesState() ([]byte, error)

GetAllServicesState returns state of all services

func (*MobileNode) GetBalance

func (mb *MobileNode) GetBalance(req *GetBalanceRequest) (*GetBalanceResponse, error)

GetBalance returns current balance.

func (*MobileNode) GetCountries

func (mb *MobileNode) GetCountries(req *GetProposalsRequest) ([]byte, error)

GetCountries returns service proposals number per country from API. go mobile does not support complex slices.

func (*MobileNode) GetDefaultCurrency

func (mb *MobileNode) GetDefaultCurrency() string

GetDefaultCurrency returns the current default currency set.

func (*MobileNode) GetGateways

func (mb *MobileNode) GetGateways(req *GetGatewaysRequest) ([]byte, error)

GetGateways returns possible payment gateways.

func (*MobileNode) GetIdentity

func (mb *MobileNode) GetIdentity(req *GetIdentityRequest) (*GetIdentityResponse, error)

GetIdentity finds first identity and unlocks it. If there is no identity default one will be created.

func (*MobileNode) GetIdentityRegistrationFees

func (mb *MobileNode) GetIdentityRegistrationFees() (*GetIdentityRegistrationFeesResponse, error)

GetIdentityRegistrationFees returns identity registration fees.

func (*MobileNode) GetLocation

func (mb *MobileNode) GetLocation() (*GetLocationResponse, error)

GetLocation return current location including country and IP.

func (*MobileNode) GetNATType

func (mb *MobileNode) GetNATType() (string, error)

GetNATType return current NAT type after a probe.

func (*MobileNode) GetPaymentGatewayOrder

func (mb *MobileNode) GetPaymentGatewayOrder(req *GetPaymentOrderRequest) ([]byte, error)

GetPaymentGatewayOrder gets an order by ID.

func (*MobileNode) GetPaymentGatewayOrderInvoice

func (mb *MobileNode) GetPaymentGatewayOrderInvoice(req *GetPaymentOrderRequest) ([]byte, error)

GetPaymentGatewayOrderInvoice gets the invoice for an order.

func (*MobileNode) GetProposals

func (mb *MobileNode) GetProposals(req *GetProposalsRequest) ([]byte, error)

GetProposals returns service proposals from API or cache. Proposals returned as JSON byte array since go mobile does not support complex slices.

func (*MobileNode) GetProposalsByPreset

func (mb *MobileNode) GetProposalsByPreset(presetID int) ([]byte, error)

GetProposalsByPreset returns service proposals by presetID.

func (*MobileNode) GetStatus

func (mb *MobileNode) GetStatus() ([]byte, error)

GetStatus returns current connection state and provider info if connected to VPN.

func (*MobileNode) GetUnsettledEarnings

func (mb *MobileNode) GetUnsettledEarnings(req *GetBalanceRequest) (*GetBalanceResponse, error)

GetUnsettledEarnings returns unsettled earnings.

func (*MobileNode) HealthCheck

func (mb *MobileNode) HealthCheck() *HealthCheckData

HealthCheck returns node health check data.

func (*MobileNode) ImportIdentity

func (mb *MobileNode) ImportIdentity(data []byte, passphrase string) (string, error)

ImportIdentity import a given identity address given data (json as string) and the current passphrase.

Identity can only be imported if it is registered.

func (*MobileNode) IsFreeRegistrationEligible

func (mb *MobileNode) IsFreeRegistrationEligible(identityAddress string) (bool, error)

IsFreeRegistrationEligible returns true if free registration is possible for a given identity.

func (*MobileNode) ListConsumerSessions

func (mb *MobileNode) ListConsumerSessions(filter *SessionFilter) ([]byte, error)

ListConsumerSessions list consumer sessions

func (*MobileNode) ListPaymentGatewayOrders

func (mb *MobileNode) ListPaymentGatewayOrders(req *ListOrdersRequest) ([]byte, error)

ListPaymentGatewayOrders lists all payment orders.

func (*MobileNode) ListProposalFilterPresets

func (mb *MobileNode) ListProposalFilterPresets() ([]byte, error)

ListProposalFilterPresets lists system and user created filter presets for proposals see ProposalFilterPreset for contract

func (*MobileNode) MigrateHermes

func (mb *MobileNode) MigrateHermes(id string) error

MigrateHermes migrate from old to active Hermes

func (*MobileNode) MigrateHermesStatus

func (mb *MobileNode) MigrateHermesStatus(id string) ([]byte, error)

MigrateHermesStatus migrate from old to active Hermes

func (*MobileNode) OverrideWireguardConnection

func (mb *MobileNode) OverrideWireguardConnection(wgTunnelSetup WireguardTunnelSetup)

OverrideWireguardConnection overrides default wireguard connection implementation to more mobile adapted one.

func (*MobileNode) Reconnect

func (mb *MobileNode) Reconnect(req *ConnectRequest) *ConnectResponse

Reconnect is deprecated, we are doing reconnect now in the connection manager. TODO remove this from mobile app and here too.

func (*MobileNode) RegisterBalanceChangeCallback

func (mb *MobileNode) RegisterBalanceChangeCallback(cb BalanceChangeCallback)

RegisterBalanceChangeCallback registers callback which is called on identity balance change.

func (*MobileNode) RegisterConnectionStatusChangeCallback

func (mb *MobileNode) RegisterConnectionStatusChangeCallback(cb ConnectionStatusChangeCallback)

RegisterConnectionStatusChangeCallback registers callback which is called on active connection status change.

func (*MobileNode) RegisterIdentity

func (mb *MobileNode) RegisterIdentity(req *RegisterIdentityRequest) error

RegisterIdentity starts identity registration in background.

func (*MobileNode) RegisterIdentityRegistrationChangeCallback

func (mb *MobileNode) RegisterIdentityRegistrationChangeCallback(cb IdentityRegistrationChangeCallback)

RegisterIdentityRegistrationChangeCallback registers callback which is called on identity registration status change.

func (*MobileNode) RegisterOrderUpdatedCallback

func (mb *MobileNode) RegisterOrderUpdatedCallback(cb OrderUpdatedCallback)

RegisterOrderUpdatedCallback registers OrderStatusChanged callback.

func (*MobileNode) RegisterServiceStatusChangeCallback

func (mb *MobileNode) RegisterServiceStatusChangeCallback(cb ServiceStatusChangeCallback)

RegisterServiceStatusChangeCallback registers callback which is called on active connection status change.

func (*MobileNode) RegisterStatisticsChangeCallback

func (mb *MobileNode) RegisterStatisticsChangeCallback(cb StatisticsChangeCallback)

RegisterStatisticsChangeCallback registers callback which is called on active connection statistics change.

func (*MobileNode) RegistrationTokenReward

func (mb *MobileNode) RegistrationTokenReward(token string) (float64, error)

RegistrationTokenReward returns the reward amount for a given token.

func (*MobileNode) ResidentCountry

func (mb *MobileNode) ResidentCountry() string

ResidentCountry resident country

func (*MobileNode) SendFeedback

func (mb *MobileNode) SendFeedback(req *SendFeedbackRequest) error

SendFeedback sends user feedback via feedback reported.

func (*MobileNode) SetUserConfig

func (mb *MobileNode) SetUserConfig(key, value string) error

SetUserConfig sets a user values in the configuration file

func (*MobileNode) Shutdown

func (mb *MobileNode) Shutdown() error

Shutdown function stops running mobile node.

func (*MobileNode) StartProvider

func (mb *MobileNode) StartProvider()

StartProvider starts all provider services (provider mode)

func (*MobileNode) StopProvider

func (mb *MobileNode) StopProvider()

StopProvider stops all provider services, started by StartProvider

func (*MobileNode) UpdateResidentCountry

func (mb *MobileNode) UpdateResidentCountry(r *ResidentCountryUpdateRequest) error

UpdateResidentCountry updates resident country

func (*MobileNode) WaitUntilDies

func (mb *MobileNode) WaitUntilDies() error

WaitUntilDies function returns when node stops.

type MobileNodeOptions

type MobileNodeOptions struct {
	Network                        string
	KeepConnectedOnFail            bool
	DiscoveryAddress               string
	BrokerAddresses                []string
	EtherClientRPCL1               []string
	EtherClientRPCL2               []string
	FeedbackURL                    string
	QualityOracleURL               string
	IPDetectorURL                  string
	LocationDetectorURL            string
	TransactorEndpointAddress      string
	AffiliatorEndpointAddress      string
	HermesEndpointAddress          string
	Chain1ID                       int64
	Chain2ID                       int64
	ActiveChainID                  int64
	PilvytisAddress                string
	MystSCAddress                  string
	RegistrySCAddress              string
	HermesSCAddress                string
	ChannelImplementationSCAddress string
	CacheTTLSeconds                int
	ObserverAddress                string
	IsProvider                     bool
	TequilapiSecured               bool
	UIFeaturesEnabled              string
}

MobileNodeOptions contains common mobile node options.

func DefaultNodeOptions

func DefaultNodeOptions() *MobileNodeOptions

DefaultNodeOptions returns default options.

func DefaultNodeOptionsByNetwork

func DefaultNodeOptionsByNetwork(network string) *MobileNodeOptions

DefaultNodeOptionsByNetwork returns default options by network.

func DefaultProviderNodeOptions

func DefaultProviderNodeOptions() *MobileNodeOptions

DefaultProviderNodeOptions returns default options.

type OrderUpdatedCallback

type OrderUpdatedCallback interface {
	OnUpdate(payload *OrderUpdatedCallbackPayload)
}

OrderUpdatedCallback is a callback when order status changes.

type OrderUpdatedCallbackPayload

type OrderUpdatedCallbackPayload struct {
	OrderID     string
	Status      string
	PayAmount   string
	PayCurrency string
}

OrderUpdatedCallbackPayload is the payload of OrderUpdatedCallback.

type PaymentOrderOptions

type PaymentOrderOptions struct {
	Minimum   float64   `json:"minimum"`
	Suggested []float64 `json:"suggested"`
}

PaymentOrderOptions are the suggested and minimum myst amount options for a gateway.

type PaymentOrderResponse

type PaymentOrderResponse struct {
	ID                string          `json:"id"`
	Status            string          `json:"status"`
	IdentityAddress   string          `json:"identity"`
	ChannelAddress    string          `json:"channel_address"`
	Gateway           string          `json:"gateway"`
	ReceiveMYST       string          `json:"receive_myst"`
	PayAmount         string          `json:"pay_amount"`
	PayCurrency       string          `json:"pay_currency"`
	Country           string          `json:"country"`
	Currency          string          `json:"currency"`
	ItemsSubTotal     string          `json:"items_sub_total"`
	TaxRate           string          `json:"tax_rate"`
	TaxSubTotal       string          `json:"tax_sub_total"`
	OrderTotal        string          `json:"order_total"`
	PublicGatewayData json.RawMessage `json:"public_gateway_data"`
}

PaymentOrderResponse represents a payment order for mobile usage.

type ProposalChangeCallback

type ProposalChangeCallback interface {
	OnChange(proposal []byte)
}

ProposalChangeCallback represents proposal callback.

type ProposalFilterPreset

type ProposalFilterPreset struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

ProposalFilterPreset represents proposal filter preset

type RegisterIdentityRequest

type RegisterIdentityRequest struct {
	IdentityAddress string
	Token           string
}

RegisterIdentityRequest represents identity registration request.

type ResidentCountryUpdateRequest

type ResidentCountryUpdateRequest struct {
	IdentityAddress string
	Country         string
}

ResidentCountryUpdateRequest represents a partial typed config (as appose to map[string]interface blob)

type SendFeedbackRequest

type SendFeedbackRequest struct {
	Email       string
	Description string
}

SendFeedbackRequest represents user feedback request.

type ServiceStatusChangeCallback

type ServiceStatusChangeCallback interface {
	OnChange(service string, status string)
}

ServiceStatusChangeCallback represents status callback.

type ServicesState

type ServicesState struct {
	Service string `json:"id"`
	State   string `json:"state"`
}

ServicesState - state of service

type SessionDTO

type SessionDTO struct {
	ID              string   `json:"id"`
	Direction       string   `json:"direction"`
	ConsumerID      string   `json:"consumer_id"`
	HermesID        string   `json:"hermes_id"`
	ProviderID      string   `json:"provider_id"`
	ServiceType     string   `json:"service_type"`
	ConsumerCountry string   `json:"consumer_country"`
	ProviderCountry string   `json:"provider_country"`
	CreatedAt       string   `json:"created_at"`
	Duration        uint64   `json:"duration"`
	BytesReceived   uint64   `json:"bytes_received"`
	BytesSent       uint64   `json:"bytes_sent"`
	Tokens          *big.Int `json:"tokens"`
	Status          string   `json:"status"`
	IPType          string   `json:"ip_type"`
}

SessionDTO mobile session dto

type SessionFilter

type SessionFilter struct {
	StartedFrom string
	StartedTo   string
}

SessionFilter allows to filter by time slice

* arguments will be attempted to be parsed by time.RFC3339 * * @see https://golang.org/pkg/time/ * * @param StartedFrom - e.g. "2006-01-02T15:04:05Z" or null if undetermined * @param StartedTo - e.g. "2006-04-02T15:04:05Z" or null if undetermined

type SessionStorage

type SessionStorage interface {
	List(*session.Filter) ([]session.History, error)
}

SessionStorage provides access to session history

type StatisticsChangeCallback

type StatisticsChangeCallback interface {
	OnChange(duration int64, bytesReceived int64, bytesSent int64, tokensSpent float64)
}

StatisticsChangeCallback represents statistics callback.

type WireguardTunnelSetup

type WireguardTunnelSetup interface {
	NewTunnel()
	AddTunnelAddress(ip string, prefixLen int)
	AddRoute(route string, prefixLen int)
	AddDNS(ip string)
	SetBlocking(blocking bool)
	Establish() (int, error)
	SetMTU(mtu int)
	Protect(socket int) error
	SetSessionName(session string)
}

WireguardTunnelSetup exposes api for caller to implement external tunnel setup

Jump to

Keyboard shortcuts

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