mon

package
v0.0.0-...-55bacb3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CRC16("github.com/privatix/dapp-openvpn/adapter/mon") = 0xABB7
	ErrServerOutdated errors.Error = 0xABB7 + iota
	ErrMonitoringCancelled
	ErrCmdReceiveTimeout
)

Errors.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr            string
	ByteCountPeriod uint // In seconds.
	CmdApplyTimeout uint // In seconds.
	CmdRetryTimeout uint // In seconds.
}

Config is a configuration for OpenVPN monitor.

func NewConfig

func NewConfig() *Config

NewConfig creates a default configuration for OpenVPN monitor.

type Monitor

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

Monitor is an OpenVPN monitor for observation of consumed VPN traffic and for killing client VPN sessions.

func NewMonitor

func NewMonitor(conf *Config, logger log.Logger,
	sessionHandler SessionHandler, channel string) *Monitor

NewMonitor creates a new OpenVPN monitor.

func (*Monitor) Close

func (m *Monitor) Close() error

Close immediately closes the monitor making MonitorTraffic() to return.

func (*Monitor) MonitorTraffic

func (m *Monitor) MonitorTraffic(ctx context.Context) error

MonitorTraffic connects to OpenVPN management interfaces and starts monitoring VPN traffic.

type SessionHandler

type SessionHandler interface {
	StartSession(ch string) bool
	UpdateSession(ch string, up, down uint64) bool
	StopSession(ch string) bool
}

SessionHandler is session events handler. If it's method returns false in server mode, then the monitor kills the corresponding session.

Jump to

Keyboard shortcuts

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