protocol

package
v0.0.0-...-846a3b6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Protocol

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

Protocol - TCP interface to communicate with IVPN application

func CreateProtocol

func CreateProtocol() (*Protocol, error)

CreateProtocol - Create new protocol object

func (*Protocol) OnAccountStatus

func (p *Protocol) OnAccountStatus(sessionToken string, accountInfo preferences.AccountStatus)

OnAccountStatus - handler of account status info. Notifying clients.

func (*Protocol) OnDNSChanged

func (p *Protocol) OnDNSChanged(dns net.IP)

OnDNSChanged - DNS changed handler

func (*Protocol) OnKillSwitchStateChanged

func (p *Protocol) OnKillSwitchStateChanged()

OnKillSwitchStateChanged - Firewall change handler

func (*Protocol) OnPingStatus

func (p *Protocol) OnPingStatus(retMap map[string]int)

OnPingStatus - servers ping status

func (*Protocol) OnServiceSessionChanged

func (p *Protocol) OnServiceSessionChanged()

OnServiceSessionChanged - SessionChanged handler

func (*Protocol) OnWiFiChanged

func (p *Protocol) OnWiFiChanged(ssid string, isInsecureNetwork bool)

OnWiFiChanged - handler of WiFi status change. Notifying clients.

func (*Protocol) Start

func (p *Protocol) Start(secret uint64, startedOnPort chan<- int, service Service) error

Start - starts TCP interface to communicate with IVPN application (server to listen incoming connections)

func (*Protocol) Stop

func (p *Protocol) Stop()

Stop - stop communication

type Service

type Service interface {
	// OnControlConnectionClosed - Perform reqired operations when protocol (controll channel with UI application) was closed
	// (for example, we must disable firewall (if it not persistant))
	// Must be called by protocol object
	// Return parameters:
	// - isServiceMustBeClosed: true informing that service have to be closed ("Stop IVPN Agent when application is not running" feature)
	// - err: error
	OnControlConnectionClosed() (isServiceMustBeClosed bool, err error)

	// GetDisabledFunctions returns info about functions which are disabled
	// Some functionality can be not accessible
	// It can happen, for example, if some external binaries not installed
	// (e.g. obfsproxy or WireGuard on Linux)
	GetDisabledFunctions() (wgErr, ovpnErr, obfspErr error)

	ServersList() (*apitypes.ServersInfoResponse, error)
	PingServers(retryCount int, timeoutMs int) (map[string]int, error)
	ServersUpdateNotifierChannel() chan struct{}

	APIRequest(apiAlias string) (responseData []byte, err error)

	KillSwitchState() (isEnabled, isPersistant, isAllowLAN, isAllowLanMulticast bool, err error)
	SetKillSwitchState(bool) error
	SetKillSwitchIsPersistent(isPersistant bool) error
	SetKillSwitchAllowLANMulticast(isAllowLanMulticast bool) error
	SetKillSwitchAllowLAN(isAllowLan bool) error

	Preferences() preferences.Preferences
	SetPreference(key string, val string) error

	SetManualDNS(dns net.IP) error
	ResetManualDNS() error

	ConnectOpenVPN(connectionParams openvpn.ConnectionParams, manualDNS net.IP, firewallOn bool, firewallDuringConnection bool, stateChan chan<- vpn.StateInfo) error
	ConnectWireGuard(connectionParams wireguard.ConnectionParams, manualDNS net.IP, firewallOn bool, firewallDuringConnection bool, stateChan chan<- vpn.StateInfo) error
	Disconnect() error
	Connected() bool

	Pause() error
	Resume() error
	IsPaused() bool

	SessionNew(accountID string, forceLogin bool, captchaID string, captcha string, confirmation2FA string) (
		apiCode int,
		apiErrorMsg string,
		accountInfo preferences.AccountStatus,
		rawResponse string,
		err error)

	SessionDelete() error
	RequestSessionStatus() (
		apiCode int,
		apiErrorMsg string,
		sessionToken string,
		accountInfo preferences.AccountStatus,
		err error)

	WireGuardGenerateKeys(updateIfNecessary bool) error
	WireGuardSetKeysRotationInterval(interval int64)

	GetWiFiCurrentState() (ssid string, isInsecureNetwork bool)
	GetWiFiAvailableNetworks() []string
}

Service - service interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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