mgmt

package
v0.0.0-...-d56bc8d Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 7 Imported by: 0

README

Library for interacting with OpenVPN Management Interface

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseKillSession

func ParseKillSession(input string) (string, error)

ParseKillSession gets kill command result from string

func ParsePid

func ParsePid(input string) (int64, error)

ParsePid gets pid from string

func ParseSignal

func ParseSignal(input string) error

ParseSignal checks for error in response string

func ReadResponse

func ReadResponse(reader *bufio.Reader) (string, error)

ReadResponse .

func SendCommand

func SendCommand(conn net.Conn, cmd string) error

SendCommand passes command to a given connection (adds logging and EOL character)

Types

type Client

type Client struct {
	Protocol string
	Address  string
}

Client is used to connect to OpenVPN Management Interface

func NewClient

func NewClient(network, address string) *Client

NewClient initializes Management Interface client structure

func (*Client) Execute

func (c *Client) Execute(cmd string) (string, error)

Execute connects to the OpenVPN server, sends command and reads response

func (*Client) GetLoadStats

func (c *Client) GetLoadStats() (*LoadStats, error)

GetLoadStats returns number of connected clients and total number of network traffic

func (*Client) GetPid

func (c *Client) GetPid() (int64, error)

GetPid returns process id of OpenVPN server

func (*Client) GetStatus

func (c *Client) GetStatus() (*Status, error)

GetStatus returns list of connected clients and routing table

func (*Client) GetVersion

func (c *Client) GetVersion() (*Version, error)

GetVersion returns version of OpenVPN server

func (*Client) KillSession

func (c *Client) KillSession(cname string) (string, error)

KillSession kills OpenVPN connection

func (*Client) Signal

func (c *Client) Signal(signal string) error

Signal sends signal to daemon

type LoadStats

type LoadStats struct {
	NClients int64
	BytesIn  int64
	BytesOut int64
}

LoadStats .

func ParseStats

func ParseStats(input string) (*LoadStats, error)

ParseStats gets stats from string

type OVClient

type OVClient struct {
	CommonName      string
	RealAddress     string
	VirtualAddress  string
	BytesReceived   uint64
	BytesSent       uint64
	ConnectedSince  string
	ConnectedSinceT string
	Username        string
}

OVClient .

type RoutingPath

type RoutingPath struct {
	VirtualAddress string
	CommonName     string
	RealAddress    string
	LastRef        string
	LastRefT       string
}

RoutingPath .

type Status

type Status struct {
	Title        string
	Time         string
	TimeT        string
	ClientList   []*OVClient
	RoutingTable []*RoutingPath
}

Status .

func ParseStatus

func ParseStatus(input string) (*Status, error)

ParseStatus gets status information from string

type Version

type Version struct {
	OpenVPN    string
	Management string
}

Version .

func ParseVersion

func ParseVersion(input string) (*Version, error)

ParseVersion gets version information from string

Jump to

Keyboard shortcuts

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