Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) AcceptClient(ctx context.Context, logger *slog.Logger, client state.ClientIdentifier, ...)
- func (c *Client) Connect(ctx context.Context) error
- func (c *Client) DenyClient(ctx context.Context, logger *slog.Logger, client state.ClientIdentifier, ...)
- func (c *Client) SendCommand(ctx context.Context, cmd string, passthrough bool) (string, error)
- func (c *Client) SendCommandf(ctx context.Context, format string, a ...any) (string, error)
- func (c *Client) SetOAuth2Client(client oauth2Client)
- func (c *Client) Shutdown(ctx context.Context)
Constants ¶
const ( SchemeTCP = "tcp" SchemeUnix = "unix" )
const (
ReasonStateExpiredOrInvalid = "client session state invalid or expired"
)
Variables ¶
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
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
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 (*Client) SendCommand ¶ added in v1.0.0
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
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.