openvpn

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: AGPL-3.0 Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package openvpn is komando's own OpenVPN client: the control channel (TLS over OpenVPN's reliable transport, with tls-auth or tls-crypt), the key exchange (key-method 2, TLS-EKM or the OpenVPN PRF), the data channel (AES-GCM, ChaCha20-Poly1305, or AES-CBC with HMAC) and the pushed options. It hands IP packets to a userspace network stack, so the computer's own network is never changed and no admin rights are needed.

It is written from the OpenVPN protocol documentation; no OpenVPN code is used. Options it does not implement are refused by name at Parse, so a profile never half works.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthError

type AuthError struct{ Msg string }

AuthError is a login the server refused.

func (*AuthError) Error

func (e *AuthError) Error() string

type Client

type Client struct {

	// Packets is where decrypted IP packets arrive.
	Packets chan []byte
	// contains filtered or unexported fields
}

Client is one connected OpenVPN session.

func Connect

func Connect(ctx context.Context, cfg *Config, login Login, dial func(ctx context.Context, network, addr string) (net.Conn, error)) (*Client, error)

Connect dials the first remote that answers and completes the handshake.

func (*Client) Close

func (c *Client) Close() error

Close ends the session.

func (*Client) Done

func (c *Client) Done() <-chan struct{}

Done is closed when the session ends.

func (*Client) Err

func (c *Client) Err() error

Err is why the session ended, if it did.

func (*Client) Pushed

func (c *Client) Pushed() Pushed

Pushed are the options the server pushed.

func (*Client) WritePacket

func (c *Client) WritePacket(ip []byte) error

WritePacket encrypts and sends one IP packet.

type Config

type Config struct {
	Remotes        []Remote
	CA, Cert, Key  []byte // PEM
	TLSAuth        []byte // the 256-byte static key
	KeyDirection   int    // -1 none, 0 or 1 (tls-auth)
	TLSCrypt       []byte // the 256-byte static key
	Ciphers        []string
	Auth           string // digest for tls-auth and CBC: SHA1, SHA256, SHA512
	AuthUserPass   bool
	RemoteCertTLS  bool // the server's certificate must be for a TLS server
	NSCertServer   bool // ns-cert-type server: the Netscape cert type must say SSL server
	RemoteCertEKU  string
	RemoteCertKU   []uint16 // OpenSSL bit order; not nil: the key usage must hold all bits of one (none listed: any)
	VerifyName     string
	VerifyNameType string // subject (full DN), name (CN), name-prefix
	TLSMin         string
	Compress       string // "", "lzo-no" (comp-lzo no), "stub-v2" (compress stub-v2)
	Setenv         map[string]string
	TunMTU         int
	// Warnings are things in the profile a person should know about (no
	// secrets); the caller shows them.
	Warnings []string
}

Config is what komando uses from a .ovpn profile.

func Parse

func Parse(text string) (*Config, error)

Parse reads a .ovpn profile with its inline <ca>, <cert>, <key>, <tls-auth> and <tls-crypt> blocks.

type Login

type Login struct{ User, Password string }

Login is the user name and password for auth-user-pass (Pritunl puts a PIN or one-time code into the password the way its client does).

type Pushed

type Pushed struct {
	Address     netip.Prefix // ifconfig
	Address6    netip.Prefix
	DNS         []netip.Addr
	Cipher      string
	PeerID      int // -1 when none
	Ping        time.Duration
	PingRestart time.Duration
	EKM         bool
	MTU         int
	Raw         []string
}

Pushed is what the server pushed.

type Remote

type Remote struct {
	Host, Port, Proto string // proto: udp or tcp
}

Remote is one server to try.

Jump to

Keyboard shortcuts

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