core

package
v0.0.0-...-8a9afe1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerMode = 1 // OpenVPN running in server mode
	ClientMode = 2 // OpenVPN running in client mode
)

Variables

View Source
var (
	ClientListReg, _ = regexp.Compile("(?ms)OpenVPN CLIENT LIST\n" +
		"Updated,([^\n]*)\n" +
		"(.*)\n" +
		"ROUTING TABLE\n" +
		"(.*)\n" +
		"GLOBAL STATS\n" +
		"(.*)" +
		"\nEND\n")
	ClientEnv, _ = regexp.Compile("([^=\r\n]+)=([^\r\n]*)")
)

Functions

This section is empty.

Types

type CommandParser

type CommandParser struct {
	ClientListReg *regexp.Regexp
	// contains filtered or unexported fields
}

func NewCommandParser

func NewCommandParser() CommandParser

func (CommandParser) Join

func (cp CommandParser) Join(evt []string, start int, sep string) string

func (*CommandParser) ParseClient

func (cp *CommandParser) ParseClient(data *EventData) error

func (*CommandParser) ParseEvent

func (cp *CommandParser) ParseEvent(evt string) *EventData

func (*CommandParser) ParseStatus

func (cp *CommandParser) ParseStatus(out string) ([]utils.Client, error)

type EventData

type EventData struct {
	Event     string
	EventType string
	Completed bool
	HasEnd    bool
	Realtime  bool
	Invalid   bool
	Data      map[string]string
	EventData string
}

func (EventData) EventName

func (ed EventData) EventName() string

func (EventData) Get

func (ed EventData) Get(k string) string

func (*EventData) Merge

func (ed *EventData) Merge(data EventData)

type OpenVpnConnector

type OpenVpnConnector interface {
	Connect() error
	SendCommand(string) (string, error)
	Listen(events chan string)
	Close() error
}

func NewSocketConnector

func NewSocketConnector(socket string, password string, mode int) OpenVpnConnector

func NewTcpConnector

func NewTcpConnector(ipAddress string, port int, password string, mode int) OpenVpnConnector

type SocketConnector

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

func (*SocketConnector) Close

func (s *SocketConnector) Close() error

func (*SocketConnector) Connect

func (s *SocketConnector) Connect() error

func (*SocketConnector) Listen

func (s *SocketConnector) Listen(events chan string)

func (*SocketConnector) SendCommand

func (s *SocketConnector) SendCommand(command string) (string, error)

func (*SocketConnector) Write

func (s *SocketConnector) Write(c net.Conn, cmd string)

type TcpConnector

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

func (TcpConnector) Close

func (s TcpConnector) Close() error

func (*TcpConnector) Connect

func (s *TcpConnector) Connect() error

func (TcpConnector) GetManagementAddress

func (s TcpConnector) GetManagementAddress() string

func (*TcpConnector) Listen

func (s *TcpConnector) Listen(events chan string)

func (*TcpConnector) SendCommand

func (s *TcpConnector) SendCommand(command string) (string, error)

type VpnActions

type VpnActions interface {
	Authenticated(data EventData) string
	UnAuthenticated(data EventData) string
	HoldRelease(data EventData) string
	Usage(duration time.Duration) string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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