vpn

package
Version: 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: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Process

type Process interface {
	// Type just returns VPN type
	Type() Type
	// Init performs basic initializations before connection
	// It is usefull, for example, for WireGuard(Windows) - to ensure that WG service is fully uninstalled
	// (currently, in use by WireGuard(Windows))
	Init() error

	// Connect - SYNCHRONOUSLY execute openvpn process (wait until it finished)
	Connect(stateChan chan<- StateInfo) error
	Disconnect() error
	Pause() error
	Resume() error
	IsPaused() bool

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

	// DestinationIP -  Get destination IP (VPN host server or proxy server IP address)
	// This information if required, for example, to allow this address in firewall
	DestinationIP() net.IP

	OnRoutingChanged() error
}

Process represents VPN object operations

type ReconnectionRequiredError

type ReconnectionRequiredError struct {
	Err error
}

ReconnectionRequiredError object can be returned by vpn.Process.Connect() function which means that it requesting to do re-connect immediately

func (*ReconnectionRequiredError) Error

func (e *ReconnectionRequiredError) Error() string

func (*ReconnectionRequiredError) Unwrap

func (e *ReconnectionRequiredError) Unwrap() error

Unwrap returns inner error

type State

type State int

State - state of VPN

const (
	DISCONNECTED State = iota
	CONNECTING   State = iota // OpenVPN's initial state.
	WAIT         State = iota // (Client only) Waiting for initial response from server.
	AUTH         State = iota // (Client only) Authenticating with server.
	GETCONFIG    State = iota // (Client only) Downloading configuration options from server.
	ASSIGNIP     State = iota // Assigning IP address to virtual network interface.
	ADDROUTES    State = iota // Adding routes to system.
	CONNECTED    State = iota // Initialization Sequence Completed.
	RECONNECTING State = iota // A restart has occurred.
	TCP_CONNECT  State = iota // TCP_CONNECT
	EXITING      State = iota // A graceful exit is in progress.
)

Possible VPN state values (must be applicable for all protocols) Such stetes MUST be in use by ALL supportded VPN protocols:

DISCONNECTED
CONNECTING
CONNECTED
EXITING

func ParseState

func ParseState(stateStr string) (State, error)

ParseState - Converts string representation of OpenVPN state to vpn.State

func (State) String

func (s State) String() string

type StateInfo

type StateInfo struct {
	State       State
	Description string

	VpnType      Type
	Time         int64  // unix time (seconds)
	IsTCP        bool   // applicable only for 'CONNECTED' state
	ClientIP     net.IP // applicable only for 'CONNECTED' state
	ClientPort   int    // applicable only for 'CONNECTED' state (source port)
	ServerIP     net.IP // applicable only for 'CONNECTED' state
	ServerPort   int    // applicable only for 'CONNECTED' state (destination port)
	ExitServerID string // applicable only for 'CONNECTED' state
	IsCanPause   bool   // applicable only for 'CONNECTED' state
	IsAuthError  bool   // applicable only for 'EXITING' state

	// TODO: try to avoid using this protocol-specific parameter in future
	// Currently, in use by OpenVPN connection to inform about "RECONNECTING" reason (e.g. "tls-error", "init_instance"...)
	// UI client using this info in order to determine is it necessary to try to connect with another port
	StateAdditionalInfo string
}

StateInfo - VPN state + additional information

func NewStateInfo

func NewStateInfo(state State, description string) StateInfo

NewStateInfo - create new state object (not applicable for CONNECTED state)

func NewStateInfoConnected

func NewStateInfoConnected(isTCP bool, clientIP net.IP, localPort int, serverIP net.IP, destPort int, isCanPause bool) StateInfo

NewStateInfoConnected - create new state object for CONNECTED state

type Type

type Type int

Type - VPN type

const (
	OpenVPN   Type = iota
	WireGuard Type = iota
)

Supported VPN protocols

func (Type) String

func (t Type) String() string

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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