vpn

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: 5 Imported by: 0

Documentation

Overview

Package vpn provides interface for vpn management.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVPNAIsAlreadyStarted = errors.New("vpn is already started")
	ErrTunnelAlreadyExists  = errors.New("tunnel already exists")
)

Functions

func InterfaceIPv6

func InterfaceIPv6(serverIP netip.Addr, interfaceID [8]byte) (netip.Addr, error)

InterfaceIPv6 is made from server IP and static interface id and is different per protocol.

Types

type Credentials

type Credentials struct {
	OpenVPNUsername    string
	OpenVPNPassword    string
	NordLynxPrivateKey string
}

Credentials define a possible set of credentials required to connect to the VPN server

func (Credentials) IsOpenVPNDefined

func (c Credentials) IsOpenVPNDefined() bool

IsOpenVPNDefined returns true if both username and password are defined

type LibConfigGetter

type LibConfigGetter interface {
	GetConfig(version string) (string, error)
}

LibConfigGetter is interface to acquire config for vpn implementation library

type ServerData

type ServerData struct {
	IP                netip.Addr
	Hostname          string // used in openvpn server certificate validation
	Country           string // status display only
	City              string // status display only
	Protocol          config.Protocol
	NordLynxPublicKey string
	Obfuscated        bool
	OpenVPNVersion    string
}

ServerData required to connect to VPN server.

type State

type State string

State type represents valid openvpn states type

const (
	// UnknownState is reported when state middleware cannot parse state from string (i.e. it's undefined in list above),
	// usually that means that newer openvpn version reports something extra
	UnknownState State = "UNKNOWN"

	// ConnectingState is reported by client and server mode and is indicator of openvpn startup
	ConnectingState State = "CONNECTING"

	// WaitState is reported by client in udp mode indicating that connect request is send and response is waiting
	WaitState State = "WAIT"

	// AuthenticatingState is reported by client indicating that client is trying to authenticate itself to server
	AuthenticatingState State = "AUTH"

	// GetConfigState indicates that client is waiting for config from server (push based options)
	GetConfigState State = "GET_CONFIG"

	// AssignIPState indicates that client is trying to setup tunnel with provided ip addresses
	AssignIPState State = "ASSIGN_IP"

	// AddRoutesState indicates that client is setuping routes on tunnel
	AddRoutesState State = "ADD_ROUTES"

	// ConnectedState is reported by both client and server and means that client is successfully connected and server is ready
	// to server incoming client connect requests
	ConnectedState State = "CONNECTED"

	// ReconnectingState indicates that client lost connection and is trying to reconnect itself
	ReconnectingState State = "RECONNECTING"

	// ExitingState is reported by both client and server and means that openvpn process is exiting by any reasons (normal shutdown
	// or fatal error reported before this state)
	ExitingState State = "EXITING"

	// ExitedState fake openvpn state which indicated that openvpn has been shutdown
	ExitedState State = "EXITED"
)

func StringToState

func StringToState(arg string) (State, error)

type Substate

type Substate string

Substate type represents custom openvpn sub types

const (
	UnknownSubstate      Substate = "UNKNOWN"
	AuthFlukeSubstate    Substate = "AUTH_FLUKE"
	AuthBadSubstate      Substate = "AUTH_BAD"
	TimeoutFlukeSubstate Substate = "TIMEOUT_FLUKE"
	TimeoutSubstate      Substate = "TIMEOUT"
)

type VPN

type VPN interface {
	Start(Credentials, ServerData) error
	Stop() error
	State() State // required because of OpenVPN
	IsActive() bool
	Tun() tunnel.T // required because of OpenVPN
	NetworkChanged() error
}

VPN defines a set of operations that any type that wants to act as a vpn must implement.

Directories

Path Synopsis
Package nordlynx provides nordlynx vpn technology.
Package nordlynx provides nordlynx vpn technology.
libtelio
Package libtelio wraps generated Go bindings so that the rest of the project would not need C dependencies to run unit tests.
Package libtelio wraps generated Go bindings so that the rest of the project would not need C dependencies to run unit tests.
Package openvpn provides OpenVPN technology.
Package openvpn provides OpenVPN technology.

Jump to

Keyboard shortcuts

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