openvpn

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SchemeTCP  = "tcp"
	SchemeUnix = "unix"
)
View Source
const (
	ReasonStateExpiredOrInvalid = "client session state invalid or expired"
)

Variables

View Source
var (
	ErrTimeout                              = errors.New("timeout")
	ErrEmptyResponse                        = errors.New("empty response")
	ErrUnknownProtocol                      = errors.New("unknown protocol")
	ErrInvalidPassword                      = errors.New("invalid password")
	ErrErrorResponse                        = errors.New("error response")
	ErrConnectionTerminated                 = errors.New("openvpn management interface connection terminated")
	ErrUnknownClientReason                  = errors.New("unknown client reason")
	ErrUnexpectedResponseFromVersionCommand = errors.New("unexpected response from version command")
	ErrRequireManagementInterfaceVersion5   = errors.New("openvpn-auth-oauth2 requires OpenVPN management interface version 5 or higher")
	ErrClientSessionStateInvalidOrExpired   = errors.New(ReasonStateExpiredOrInvalid)
)

Functions

This section is empty.

Types

type Client added in v1.0.0

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

func New added in v1.19.2

func New(logger *slog.Logger, conf config.Config) *Client

New creates a new Client configured with the provided logger and configuration.

func (*Client) AcceptClient added in v1.8.0

func (c *Client) AcceptClient(ctx context.Context, logger *slog.Logger, client state.ClientIdentifier, reAuth bool, username string)

AcceptClient accepts an OpenVPN client connection. It reads the client configuration from the CCD path if enabled.

func (*Client) Connect added in v1.0.0

func (c *Client) Connect(ctx context.Context) error

Connect establishes the management interface connection and starts the internal handlers. The call blocks until the context is cancelled or the connection terminates.

func (*Client) DenyClient added in v1.8.0

func (c *Client) DenyClient(ctx context.Context, logger *slog.Logger, client state.ClientIdentifier, reason string)

func (*Client) SendCommand added in v1.0.0

func (c *Client) SendCommand(ctx context.Context, cmd string, passthrough bool) (string, error)

SendCommand sends a command to the management interface and waits for its response. When passthrough is true the raw response is returned without any validation.

func (*Client) SendCommandf added in v1.6.0

func (c *Client) SendCommandf(ctx context.Context, format string, a ...any) (string, error)

SendCommandf formats a command using fmt.Sprintf and then calls SendCommand.

func (*Client) SetOAuth2Client added in v1.22.6

func (c *Client) SetOAuth2Client(client oauth2Client)

SetOAuth2Client assigns the OAuth2 client used for token refresh and disconnect callbacks.

func (*Client) Shutdown added in v1.3.0

func (c *Client) Shutdown(ctx context.Context)

Shutdown closes the management connection and stops command processing.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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