ovpnutil

package module
v0.0.0-...-9275a68 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2019 License: MIT Imports: 11 Imported by: 0

README

GoDoc

ovpnutil

Go client for OpenVPN management interface.

Installation

go get github.com/oashnic/ovpnutil

License

MIT License

Documentation

Index

Constants

View Source
const (
	SIGHUP   = Signal(0x1)
	SIGUSER1 = Signal(0xa)
	SIGUSER2 = Signal(0xc)
	SIGTERM  = Signal(0xf)
)

List of signals can be used in the openvpn management interface

Variables

View Source
var (
	ErrNotConnected    = errors.New("not connected")
	ErrNoMatch         = errors.New("no match")
	ErrReadTimeout     = errors.New("read timeout")
	ErrClosed          = errors.New("closed")
	ErrNotEnoughFields = errors.New("not enough fields")
	ErrInvalidData     = errors.New("invalid data")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	VirtualIP      string
	RealIP         string
	CommonName     string
	BytesReceived  string
	BytesSent      string
	ConnectedSince string
}

Client represent an openvpn status user

func ParseClient

func ParseClient(line string) (Client, error)

type Controller

type Controller interface {
	Signal(sig os.Signal) error
	Close()
	Getpid() (int, error)
	GetLogs() (string, error)
	GetStates() ([]State, error)
	GetStatus() (Status, error)
	GetClients() ([]Client, error)
	GetRouting() ([]Route, error)
	GetGlobalStats() (GlobalStats, error)
	SubscribeState(ch chan State) error
	SubscribeByteCount(chIn, chOut chan int64) error
	SubscribeLog(ch chan string) error
}

Controller controls openvpn process via its management interface

func Dial

func Dial(addr string, t string) (Controller, error)

Dial connects to an openvpn management interface and returns a Controller

type GlobalStats

type GlobalStats struct {
	Queue string
}

GlobalStats

type Route

type Route struct {
	VirtualIP  string
	RealIP     string
	CommonName string
	LastRef    string
}

Routing table

func ParseRoute

func ParseRoute(line string) (Route, error)

func (*Route) RealIsIPv4

func (r *Route) RealIsIPv4() bool

func (*Route) RealIsIPv6

func (r *Route) RealIsIPv6() bool

func (*Route) VirtualIsIPv4

func (r *Route) VirtualIsIPv4() bool

func (*Route) VirtualIsIPv6

func (r *Route) VirtualIsIPv6() bool

type Signal

type Signal int

A Signal is a number describing a process signal. It implements os.Signal interface.

func (Signal) Signal

func (s Signal) Signal()

func (Signal) String

func (s Signal) String() string

type State

type State struct {
	Time        time.Time
	Name        string
	Description string
	LocalIP     string
	RemoteIP    string
}

State represent an openvpn state

func ParseState

func ParseState(line string) (State, error)

type Status

type Status struct {
	Clients     []Client
	Routing     []Route
	GlobalStats GlobalStats
}

Status openvpn

Jump to

Keyboard shortcuts

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