openvpn

package
v0.0.0-...-365054f Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: GPL-3.0 Imports: 28 Imported by: 3

Documentation

Index

Constants

View Source
const AuthSignaturePrefix = "MystVpnSessionId:"

AuthSignaturePrefix is used to prefix with each session string before calculating signature or extracting identity

View Source
const ServiceType = "openvpn"

ServiceType indicates "openvpn" service type

Variables

View Source
var ErrProcessNotStarted = errors.New("process not started yet")

ErrProcessNotStarted represents the error we return when the process is not started yet

Functions

func Bootstrap

func Bootstrap()

Bootstrap is called on program initialization time and registers various deserializers related to OpenVPN service

func NewClient

func NewClient(openvpnBinary, scriptDir, runtimeDir string,
	signerFactory identity.SignerFactory,
	ipResolver ip.Resolver,
) (connection.Connection, error)

NewClient creates a new openvpn connection

func SignatureCredentialsProvider

func SignatureCredentialsProvider(sessionID session.ID, signer identity.Signer) func() (username string, password string, err error)

SignatureCredentialsProvider returns session id as username and id signed with given signer as password

Types

type Client

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

Client takes in the openvpn process and works with it

func (*Client) GetConfig

func (c *Client) GetConfig() (connection.ConsumerConfig, error)

GetConfig returns the consumer-side configuration.

func (*Client) OnStats

func (c *Client) OnStats(cnt openvpn_bytescount.Bytecount) error

OnStats updates connection statistics.

func (*Client) Reconnect

func (c *Client) Reconnect(ctx context.Context, options connection.ConnectOptions) error

Reconnect restarts a connection with a new options.

func (*Client) Start

func (c *Client) Start(ctx context.Context, options connection.ConnectOptions) error

Start starts the connection

func (*Client) State

func (c *Client) State() <-chan connectionstate.State

State returns connection state channel.

func (*Client) Statistics

func (c *Client) Statistics() (connectionstate.Statistics, error)

Statistics returns connection statistics channel.

func (*Client) Stop

func (c *Client) Stop()

Stop stops the connection

type ClientConfig

type ClientConfig struct {
	*config.GenericConfig
	VpnConfig *VPNConfig
}

ClientConfig represents specific "openvpn as client" configuration

func NewClientConfigFromSession

func NewClientConfigFromSession(vpnConfig VPNConfig, scriptDir string, runtimeDir string, options connection.ConnectOptions) (*ClientConfig, error)

NewClientConfigFromSession creates client configuration structure for given VPNConfig, configuration dir to store serialized file args, and configuration filename to store other args TODO this will become the part of openvpn service consumer separate package

func (*ClientConfig) SetClientMode

func (c *ClientConfig) SetClientMode(serverIP string, serverPort, localPort int)

SetClientMode adds config arguments for openvpn behave as client

func (*ClientConfig) SetProtocol

func (c *ClientConfig) SetProtocol(protocol string)

SetProtocol specifies openvpn connection protocol type (tcp or udp)

type ConfigValidator

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

ConfigValidator represents structure which contains list of validating functions

func NewDefaultValidator

func NewDefaultValidator() *ConfigValidator

NewDefaultValidator returns ConfigValidator with predefined list of validating functions

func (*ConfigValidator) IsValid

func (v *ConfigValidator) IsValid(config VPNConfig) error

IsValid function checks if provided config is valid against given config validator and returns first encountered error

type ConsumerConfig

type ConsumerConfig struct {
	IP    string `json:"Ip,omitempty"`
	Ports []int  `json:"Ports,omitempty"`
}

ConsumerConfig is used for sending some configuration from consumer to provider

type VPNConfig

type VPNConfig struct {
	DNSIPs          string `json:"dns_ips"`
	RemoteIP        string `json:"remote"`
	RemotePort      int    `json:"port"`
	LocalPort       int    `json:"lport"`
	Ports           []int  `json:"ports"`
	RemoteProtocol  string `json:"protocol"`
	TLSPresharedKey string `json:"TLSPresharedKey"`
	CACertificate   string `json:"CACertificate"`
}

VPNConfig structure represents VPN configuration options for given session

func FormatTLSPresharedKey

func FormatTLSPresharedKey(config VPNConfig) (VPNConfig, error)

FormatTLSPresharedKey formats preshared key (PEM blocks with data encoded to hex) are taken from openvpn --genkey --secret static.key, which is openvpn specific. it reformats key from single line to multiline fixed length strings.

type ValidateConfig

type ValidateConfig func(config VPNConfig) error

ValidateConfig is function which takes VPNConfig as argument, checks it and returns error if validation fails

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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