libtelio

package
v0.0.0-...-851e5e8 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package libtelio wraps generated Go bindings so that the rest of the project would not need C dependencies to run unit tests.

Index

Constants

View Source
const (
	// TelioLocalConfigName defines env key for local config value
	TelioLocalConfigName = "TELIO_LOCAL_CFG"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Libtelio

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

Libtelio wrapper around generated Go bindings. Libtelio has 4 related methods and their combinations as following 1. Mesh disabled, calling Start - tunnel must be created with the API provided private key and the default IP address (10.5.0.2) 2. Mesh enabled, calling Start - tunnel must be re-used and connection to the VPN must be done with the meshnet private key and IP address 3. Mesh enabled, calling Stop - tunnel must stay as it is 4. Mesh disabled, calling Stop - tunnel must be destroyed 5. VPN connected, calling Enable - tunnel must be re-initiated with the meshnet private key and IP address, VPN connection must be re-initiated 6. VPN disconnected, calling Enable - tunnel must be initiated with the meshnet private key and IP address 7. VPN connected, calling Disable - tunnel must be re-initiated with the originally saved values provided to Start 8. VPN disconnected, calling Disable - tunnel must be destroyed

func New

func New(prod bool, eventPath string, fwmark uint32,
	vpnLibCfg vpn.LibConfigGetter, deviceID, appVersion string) *Libtelio

func (*Libtelio) Disable

func (l *Libtelio) Disable() error

Disable the meshnet for libtelio. If VPN is not active, disable also destroys the tunnel. However, if it is active, original private key and IP address must be re-set to the ones given by the API because device is likely to be removed from the meshnet map and VPN servers will not recognize mesh IP and private key anymore.

func (*Libtelio) Enable

func (l *Libtelio) Enable(ip netip.Addr, privateKey string) (err error)

Enable initiates the tunnel if it is not initiated yet. It can be initiated in case Start method was called before. If the tunnel is initiated and VPN is active, this function re-initiates the tunnel - sets the meshnet private key to libtelio and sets the meshnet IP address and re-creates a connection to VPN server with the new private key and IP. These should be supported by the VPN server if device is properly registered to meshnet map.

func (*Libtelio) IsActive

func (l *Libtelio) IsActive() bool

func (*Libtelio) NetworkChanged

func (l *Libtelio) NetworkChanged() error

func (*Libtelio) Private

func (l *Libtelio) Private() string

Private key generation.

func (*Libtelio) Public

func (l *Libtelio) Public(private string) string

Public key extraction from private.

func (*Libtelio) Refresh

func (l *Libtelio) Refresh(c mesh.MachineMap) error

func (*Libtelio) Start

func (l *Libtelio) Start(
	creds vpn.Credentials,
	serverData vpn.ServerData,
) (err error)

Start initiates the tunnel if it is not yet initiated and initiates the connection with the VPN server. If only VPN feature is used, tunnel should never be initiated when Start is called. If meshnet was enabled before, tunnel already exists and this function should re-use that and just initiate the connection

func (*Libtelio) State

func (l *Libtelio) State() vpn.State

func (*Libtelio) StatusMap

func (l *Libtelio) StatusMap() (map[string]string, error)

func (*Libtelio) Stop

func (l *Libtelio) Stop() error

Stop breaks the connection with the VPN server. After that it checks if the meshnet is enabled or not. In case Meshnet is still enabled, it should not destroy the tunnel because it is used for meshnet connections. If meshnet is not enabled,

func (*Libtelio) Tun

func (l *Libtelio) Tun() tunnel.T

type TelioConfig

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

func NewTelioConfig

func NewTelioConfig(cm config.Manager) *TelioConfig

func (*TelioConfig) GetConfig

func (tc *TelioConfig) GetConfig(version string) (string, error)

type TelioConfigFetcher

type TelioConfigFetcher interface {
	IsAvailable() bool
	Fetch(appVer string) (string, error)
}

TelioConfigFetcher is abstract interface to cover local and remote config

type TelioLocalConfigFetcher

type TelioLocalConfigFetcher struct{}

func (*TelioLocalConfigFetcher) Fetch

func (*TelioLocalConfigFetcher) IsAvailable

func (c *TelioLocalConfigFetcher) IsAvailable() bool

type TelioRemoteConfigFetcher

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

func (*TelioRemoteConfigFetcher) Fetch

func (c *TelioRemoteConfigFetcher) Fetch(appVer string) (string, error)

func (*TelioRemoteConfigFetcher) IsAvailable

func (c *TelioRemoteConfigFetcher) IsAvailable() bool

Jump to

Keyboard shortcuts

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