Documentation ¶
Index ¶
- Constants
- func Close(conn io.Closer)
- func ConnIDToPort(data []byte) uint16
- func CreateRawMetadata(serviceID byte, serviceTCP []uint32, serviceUDP []uint32, ip string, ...) []byte
- func GetFavoriteSeedRPCServer(path, filenamePrefix string, timeout int32) ([]string, error)
- func GetFavoriteSeedRPCServerContext(ctx context.Context, path, filenamePrefix string, timeout int32) ([]string, error)
- func LoadOrCreateAccount(walletFile, passwordFile string) (*vault.Account, error)
- func LoadPassword(path string) (string, error)
- func ParseEncryptionAlgo(encryptionAlgoStr string) (pb.EncryptionAlgo, error)
- func ParsePrice(priceStr string) (common.Fixed64, common.Fixed64, error)
- func PortToConnID(port uint16) []byte
- func ReadMetadata(metadataString string) (*pb.ServiceMetadata, error)
- func ReadVarBytes(reader io.Reader, maxMsgSize uint32) ([]byte, error)
- func StartReverse(config *EntryConfiguration, wallet *rvs.Wallet) error
- func UpdateMetadata(serviceName string, serviceID byte, serviceTCP []uint32, serviceUDP []uint32, ...)
- func WriteVarBytes(writer io.Writer, b []byte) error
- type Common
- func (c *Common) CreateServerConn(force bool) error
- func (c *Common) GetConnected() bool
- func (c *Common) GetMetadata() *pb.ServiceMetadata
- func (c *Common) GetNumActiveSessions() int
- func (c *Common) GetPaymentReceiver() string
- func (c *Common) GetPrice() (common.Fixed64, common.Fixed64)
- func (c *Common) GetRemoteNknAddress() string
- func (c *Common) GetServerTCPConn(force bool) (net.Conn, error)
- func (c *Common) GetServerUDPConn(force bool) (*net.UDPConn, error)
- func (c *Common) GetServerUDPReadChan(force bool) (chan []byte, error)
- func (c *Common) GetServerUDPWriteChan(force bool) (chan []byte, error)
- func (c *Common) GetSessionsWaitGroup() *sync.WaitGroup
- func (c *Common) GetTCPConn() net.Conn
- func (c *Common) GetTopPerformanceNodes(measureBandwidth bool, n int) (types.Nodes, error)
- func (c *Common) GetTopPerformanceNodesContext(ctx context.Context, measureBandwidth bool, n int) (types.Nodes, error)
- func (c *Common) GetUDPConn() *net.UDPConn
- func (c *Common) SetConnected(connected bool)
- func (c *Common) SetLinger(t time.Duration)
- func (c *Common) SetMetadata(metadata *pb.ServiceMetadata)
- func (c *Common) SetPaymentReceiver(paymentReceiver string) error
- func (c *Common) SetRemoteNknAddress(nknAddr string)
- func (c *Common) SetServerTCPConn(conn net.Conn)
- func (c *Common) SetServerUDPConn(conn *net.UDPConn)
- func (c *Common) SetServerUDPReadChan(udpReadChan chan []byte)
- func (c *Common) SetServerUDPWriteChan(udpWriteChan chan []byte)
- func (c *Common) StartUDPReaderWriter(conn *net.UDPConn)
- func (c *Common) UpdateServerConn(remotePublicKey []byte) error
- func (c *Common) WaitSessions()
- type EntryConfiguration
- type ExitConfiguration
- type ExitServiceInfo
- type OnConnect
- type OnConnectFunc
- type Service
- type ServiceInfo
- type TunaEntry
- type TunaExit
- func (te *TunaExit) Close()
- func (te *TunaExit) GetReverseIP() net.IP
- func (te *TunaExit) GetReverseTCPPorts() []uint32
- func (te *TunaExit) GetReverseUDPPorts() []uint32
- func (te *TunaExit) IsClosed() bool
- func (te *TunaExit) Start() error
- func (te *TunaExit) StartReverse(shouldReconnect bool) error
Constants ¶
const ( DefaultSubscriptionPrefix = "tuna_v1." DefaultReverseServiceName = "reverse" )
const (
TrafficUnit = 1024 * 1024
)
Variables ¶
This section is empty.
Functions ¶
func ConnIDToPort ¶
func CreateRawMetadata ¶
func GetFavoriteSeedRPCServer ¶
GetFavoriteSeedRPCServer wraps GetFavoriteSeedRPCServerContext with background context.
func GetFavoriteSeedRPCServerContext ¶
func GetFavoriteSeedRPCServerContext(ctx context.Context, path, filenamePrefix string, timeout int32) ([]string, error)
GetFavoriteSeedRPCServerContext returns an array of node rpc address from favorite node file. Timeout is in unit of millisecond.
func LoadOrCreateAccount ¶
func LoadPassword ¶
func ParseEncryptionAlgo ¶
func ParseEncryptionAlgo(encryptionAlgoStr string) (pb.EncryptionAlgo, error)
func PortToConnID ¶
func ReadMetadata ¶
func ReadMetadata(metadataString string) (*pb.ServiceMetadata, error)
func StartReverse ¶
func StartReverse(config *EntryConfiguration, wallet *rvs.Wallet) error
func UpdateMetadata ¶
func UpdateMetadata( serviceName string, serviceID byte, serviceTCP []uint32, serviceUDP []uint32, ip string, tcpPort uint32, udpPort uint32, price string, beneficiaryAddr string, subscriptionPrefix string, subscriptionDuration uint32, subscriptionFee string, subscriptionReplaceTxPool bool, client *rvs.MultiClient, closeChan chan struct{}, )
Types ¶
type Common ¶
type Common struct { Service *Service ServiceInfo *ServiceInfo Wallet *rvs.Wallet Client *rvs.MultiClient DialTimeout int32 SubscriptionPrefix string Reverse bool ReverseMetadata *pb.ServiceMetadata OnConnect *OnConnect IsServer bool GeoDBPath string DownloadGeoDB bool GetSubscribersBatchSize int MeasureBandwidth bool MeasureBandwidthTimeout time.Duration MeasureBandwidthWorkersTimeout time.Duration MeasurementBytesDownLink int32 MeasureStoragePath string MaxPoolSize int32 sync.RWMutex // contains filtered or unexported fields }
func NewCommon ¶
func NewCommon( service *Service, serviceInfo *ServiceInfo, wallet *rvs.Wallet, client *rvs.MultiClient, seedRPCServerAddr []string, dialTimeout int32, subscriptionPrefix string, reverse, isServer bool, geoDBPath string, downloadGeoDB bool, getSubscribersBatchSize int32, measureBandwidth bool, measureBandwidthTimeout int32, measureBandwidthWorkersTimeout int32, measurementBytes int32, measureStoragePath string, maxPoolSize int32, sortMeasuredNodes func(types.Nodes), reverseMetadata *pb.ServiceMetadata, ) (*Common, error)
func (*Common) CreateServerConn ¶
func (*Common) GetConnected ¶
func (*Common) GetMetadata ¶
func (c *Common) GetMetadata() *pb.ServiceMetadata
func (*Common) GetNumActiveSessions ¶
func (*Common) GetPaymentReceiver ¶
func (*Common) GetRemoteNknAddress ¶
func (*Common) GetServerUDPConn ¶
func (*Common) GetServerUDPReadChan ¶
func (*Common) GetServerUDPWriteChan ¶
func (*Common) GetSessionsWaitGroup ¶
func (*Common) GetTCPConn ¶
func (*Common) GetTopPerformanceNodes ¶
func (*Common) GetTopPerformanceNodesContext ¶
func (*Common) GetUDPConn ¶
func (*Common) SetConnected ¶
func (*Common) SetLinger ¶
SetLinger sets the behavior of Close when there is at least one active session. t = 0 (default): close all conn when tuna close. t < 0: tuna Close() call will block and wait for all sessions to close before closing tuna. t > 0: tuna Close() call will block and wait for up to timeout all sessions to close before closing tuna.
func (*Common) SetMetadata ¶
func (c *Common) SetMetadata(metadata *pb.ServiceMetadata)
func (*Common) SetPaymentReceiver ¶
func (*Common) SetRemoteNknAddress ¶
func (*Common) SetServerTCPConn ¶
func (*Common) SetServerUDPConn ¶
func (*Common) SetServerUDPReadChan ¶
func (*Common) SetServerUDPWriteChan ¶
func (*Common) StartUDPReaderWriter ¶
func (*Common) UpdateServerConn ¶
func (*Common) WaitSessions ¶
func (c *Common) WaitSessions()
WaitSessions waits for sessions wait group, or until linger times out.
type EntryConfiguration ¶
type EntryConfiguration struct { SeedRPCServerAddr []string `json:"seedRPCServerAddr"` Services map[string]ServiceInfo `json:"services"` DialTimeout int32 `json:"dialTimeout"` UDPTimeout int32 `json:"udpTimeout"` NanoPayFee string `json:"nanoPayFee"` MinNanoPayFee string `json:"minNanoPayFee"` NanoPayFeeRatio float64 `json:"nanoPayFeeRatio"` SubscriptionPrefix string `json:"subscriptionPrefix"` Reverse bool `json:"reverse"` ReverseBeneficiaryAddr string `json:"reverseBeneficiaryAddr"` ReverseTCP int32 `json:"reverseTCP"` ReverseUDP int32 `json:"reverseUDP"` ReverseServiceListenIP string `json:"reverseServiceListenIP"` ReversePrice string `json:"reversePrice"` ReverseClaimInterval int32 `json:"reverseClaimInterval"` ReverseMinFlushAmount string `json:"reverseMinFlushAmount"` ReverseServiceName string `json:"reverseServiceName"` ReverseSubscriptionPrefix string `json:"reverseSubscriptionPrefix"` ReverseSubscriptionDuration int32 `json:"reverseSubscriptionDuration"` ReverseSubscriptionFee string `json:"reverseSubscriptionFee"` ReverseSubscriptionReplaceTxPool bool `json:"reverseSubscriptionReplaceTxPool"` GeoDBPath string `json:"geoDBPath"` DownloadGeoDB bool `json:"downloadGeoDB"` GetSubscribersBatchSize int32 `json:"getSubscribersBatchSize"` MeasureBandwidth bool `json:"measureBandwidth"` MeasureBandwidthTimeout int32 `json:"measureBandwidthTimeout"` MeasureBandwidthWorkersTimeout int32 `json:"measureBandwidthWorkersTimeout"` MeasurementBytesDownLink int32 `json:"measurementBytesDownLink"` MeasureStoragePath string `json:"measureStoragePath"` MaxMeasureWorkerPoolSize int32 `json:"maxMeasureWorkerPoolSize"` SortMeasuredNodes func(types.Nodes) `json:"-"` }
func DefaultEntryConfig ¶
func DefaultEntryConfig() *EntryConfiguration
func MergedEntryConfig ¶
func MergedEntryConfig(conf *EntryConfiguration) (*EntryConfiguration, error)
type ExitConfiguration ¶
type ExitConfiguration struct { SeedRPCServerAddr []string `json:"seedRPCServerAddr"` BeneficiaryAddr string `json:"beneficiaryAddr"` ListenTCP int32 `json:"listenTCP"` ListenUDP int32 `json:"listenUDP"` DialTimeout int32 `json:"dialTimeout"` UDPTimeout int32 `json:"udpTimeout"` SubscriptionPrefix string `json:"subscriptionPrefix"` SubscriptionDuration int32 `json:"subscriptionDuration"` SubscriptionFee string `json:"subscriptionFee"` SubscriptionReplaceTxPool bool `json:"subscriptionReplaceTxPool"` ClaimInterval int32 `json:"claimInterval"` MinFlushAmount string `json:"minFlushAmount"` Services map[string]ExitServiceInfo `json:"services"` Reverse bool `json:"reverse"` ReverseRandomPorts bool `json:"reverseRandomPorts"` ReverseMaxPrice string `json:"reverseMaxPrice"` ReverseNanoPayFee string `json:"reverseNanopayfee"` MinReverseNanoPayFee string `json:"minReverseNanoPayFee"` ReverseNanoPayFeeRatio float64 `json:"reverseNanopayfeeRatio"` ReverseServiceName string `json:"reverseServiceName"` ReverseSubscriptionPrefix string `json:"reverseSubscriptionPrefix"` ReverseEncryption string `json:"reverseEncryption"` GeoDBPath string `json:"geoDBPath"` DownloadGeoDB bool `json:"downloadGeoDB"` GetSubscribersBatchSize int32 `json:"getSubscribersBatchSize"` ReverseIPFilter geo.IPFilter `json:"reverseIPFilter"` ReverseNknFilter filter.NknFilter `json:"reverseNknFilter"` MeasureBandwidth bool `json:"measureBandwidth"` MeasureBandwidthTimeout int32 `json:"measureBandwidthTimeout"` MeasureBandwidthWorkersTimeout int32 `json:"measureBandwidthWorkersTimeout"` MeasurementBytesDownLink int32 `json:"measurementBytesDownLink"` MeasureStoragePath string `json:"measureStoragePath"` MaxMeasureWorkerPoolSize int32 `json:"maxMeasureWorkerPoolSize"` SortMeasuredNodes func(types.Nodes) `json:"-"` }
func DefaultExitConfig ¶
func DefaultExitConfig() *ExitConfiguration
func MergedExitConfig ¶
func MergedExitConfig(conf *ExitConfiguration) (*ExitConfiguration, error)
type ExitServiceInfo ¶
type OnConnect ¶
type OnConnect struct { C chan struct{} Callback OnConnectFunc // contains filtered or unexported fields }
OnConnect is a wrapper type for gomobile compatibility.
func NewOnConnect ¶
func NewOnConnect(size int, cb OnConnectFunc) *OnConnect
NewOnConnect creates an OnConnect channel with a channel size and callback function.
type OnConnectFunc ¶
type OnConnectFunc interface{ OnConnect() }
OnConnectFunc is a wrapper type for gomobile compatibility.
type ServiceInfo ¶
type TunaEntry ¶
type TunaEntry struct { *Common // contains filtered or unexported fields }
func NewTunaEntry ¶
func NewTunaEntry(service Service, serviceInfo ServiceInfo, wallet *rvs.Wallet, client *rvs.MultiClient, config *EntryConfiguration) (*TunaEntry, error)
type TunaExit ¶
type TunaExit struct { *Common OnConnect *OnConnect // override Common.OnConnect // contains filtered or unexported fields }
func NewTunaExit ¶
func NewTunaExit(services []Service, wallet *rvs.Wallet, client *rvs.MultiClient, config *ExitConfiguration) (*TunaExit, error)