localAgent

package
v0.0.0-...-c11aaf6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentConnection

type AgentConnection struct {
	State  State
	Status *StatusMessage
	// contains filtered or unexported fields
}

func NewAgentConnection

func NewAgentConnection(
	clientCertPEM,
	clientKeyPEM,
	serverCAsPEM string,
	host string,
	certServerName string,
	client NativeClient,
	features *Features,
	connectivity bool,
) (*AgentConnection, error)

func (*AgentConnection) Close

func (conn *AgentConnection) Close()

func (*AgentConnection) SendGetStatus

func (conn *AgentConnection) SendGetStatus(withStatistics bool)

func (*AgentConnection) SetConnectivity

func (conn *AgentConnection) SetConnectivity(available bool)

func (*AgentConnection) SetFeatures

func (conn *AgentConnection) SetFeatures(features *Features)

type ConnectionDetails

type ConnectionDetails struct {
	DeviceIp      string `json:"device-ip"`
	DeviceCountry string `json:"device-country"`
	ServerIpv4    string `json:"server-ipv4"`
	ServerIpv6    string `json:"server-ipv6"`
}

type Consts

type Consts struct {
	// States
	StateConnecting                    State
	StateConnected                     State
	StateSoftJailed                    State
	StateHardJailed                    State
	StateConnectionError               State
	StateServerUnreachable             State
	StateWaitingForNetwork             State
	StateServerCertificateError        State
	StateClientCertificateExpiredError State
	StateClientCertificateUnknownCA    State
	StateDisconnected                  State

	// Error codes
	ErrorCodeUnknown                   ErrorCode
	ErrorCodeGuestSession              ErrorCode
	ErrorCodeRestrictedServer          ErrorCode
	ErrorCodeBadCertSignature          ErrorCode
	ErrorCodeCertNotProvided           ErrorCode
	ErrorCodeCertificateExpired        ErrorCode
	ErrorCodeCertificateRevoked        ErrorCode
	ErrorCodeMaxSessionsUnknown        ErrorCode
	ErrorCodeMaxSessionsFree           ErrorCode
	ErrorCodeMaxSessionsBasic          ErrorCode
	ErrorCodeMaxSessionsPlus           ErrorCode
	ErrorCodeMaxSessionsVisionary      ErrorCode
	ErrorCodeMaxSessionsPro            ErrorCode
	ErrorCodeKeyUsedMultipleTimes      ErrorCode
	ErrorCodeServerError               ErrorCode
	ErrorCodePolicyViolationLowPlan    ErrorCode
	ErrorCodePolicyViolationDelinquent ErrorCode
	ErrorCodeUserTorrentNotAllowed     ErrorCode
	ErrorCodeUserBadBehavior           ErrorCode

	LabelPartner    string
	FeatureBouncing string

	// Stats
	StatsNetshieldLevelKey string
	StatsMalwareKey        string
	StatsAdsKey            string
	StatsTrackerKey        string
	StatsSavedBytesKey     string
}

func Constants

func Constants() *Consts

Constants export constants for the client

type ErrorCode

type ErrorCode = int

type ErrorMessage

type ErrorMessage struct {
	Code        int    `json:"code"`
	Description string `json:"description"`
}

type ErrorType

type ErrorType = int
const (
	ErrorClientCertExpired ErrorType = iota
	ErrorClientCertUnknownCA
	ErrorInvalidServerCert
	ErrorUnreachable
	ErrorOther
)

type Features

type Features struct {
	StringToValueMap
}

func NewFeatures

func NewFeatures() *Features

type GetStatusMessage

type GetStatusMessage struct {
	FeaturesStatistics bool `json:"features-statistics"`
}

type MessageSocket

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

func (*MessageSocket) Receive

func (socket *MessageSocket) Receive(reader *bufio.Reader, log func(string)) (string, error)

func (*MessageSocket) Send

func (socket *MessageSocket) Send(writer *bufio.Writer, msg string, log func(string)) error

type NativeClient

type NativeClient interface {
	Log(text string)
	OnState(state State)
	OnError(code int, description string)
	OnStatusUpdate(status *StatusMessage)
	OnTlsSessionStarted()
	OnTlsSessionEnded()
}

type Reason

type Reason struct {
	Code        int    `json:"code"`
	Final       bool   `json:"final"`
	Description string `json:"description"`
}

type State

type State = string

type StatusMessage

type StatusMessage struct {
	State              string             `json:"state"`
	Features           *Features          `json:"features"`
	Reason             *Reason            `json:"reason"`
	SwitchTo           string             `json:"please-switch-to"`
	ConnectionDetails  *ConnectionDetails `json:"connection-details"`
	FeaturesStatistics *StringToValueMap  `json:"features-statistics"`
}

type StringArray

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

StringArray - helper struct introduced because gomobile doesn't support array return types

func (*StringArray) Get

func (arr *StringArray) Get(i int) string

func (*StringArray) GetCount

func (arr *StringArray) GetCount() int

type StringToValueMap

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

func (*StringToValueMap) GetBool

func (feat *StringToValueMap) GetBool(name string) bool

func (*StringToValueMap) GetCount

func (feat *StringToValueMap) GetCount() int

func (*StringToValueMap) GetInt

func (feat *StringToValueMap) GetInt(name string) int64

func (*StringToValueMap) GetIntOrDefault

func (feat *StringToValueMap) GetIntOrDefault(name string, defautVal int64) int64

func (*StringToValueMap) GetKeys

func (feat *StringToValueMap) GetKeys() *StringArray

func (*StringToValueMap) GetMap

func (feat *StringToValueMap) GetMap(name string) *StringToValueMap

func (*StringToValueMap) GetString

func (feat *StringToValueMap) GetString(name string) string

func (*StringToValueMap) GetStringOrDefault

func (feat *StringToValueMap) GetStringOrDefault(name string, defaultVal string) string

func (*StringToValueMap) HasKey

func (feat *StringToValueMap) HasKey(name string) bool

func (*StringToValueMap) MarshalJSON

func (feat *StringToValueMap) MarshalJSON() ([]byte, error)

func (*StringToValueMap) Remove

func (feat *StringToValueMap) Remove(key string)

func (*StringToValueMap) SetBool

func (feat *StringToValueMap) SetBool(name string, value bool)

func (*StringToValueMap) SetInt

func (feat *StringToValueMap) SetInt(name string, value int64)

func (*StringToValueMap) SetString

func (feat *StringToValueMap) SetString(name string, value string)

func (*StringToValueMap) UnmarshalJSON

func (feat *StringToValueMap) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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