plugins

package
Version: v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PluginIsType

func PluginIsType(plugin Plugin, pluginType PluginType) bool

PluginIsType returns true if the plugin is of the specific type

func PluginTypeNames

func PluginTypeNames(pluginType PluginType) []string

PluginTypeNames returns a string list of all plugin types

Types

type Accounter

type Accounter interface {
	Plugin
	HandleAccountingPacket(responseWriter radius.ResponseWriter, request *radius.Request, timestamp time.Time)
	HandleAccountingOnOff(nas string, acctType goradius.AcctStatusType)
	SendAccountingResponse(responseWriter radius.ResponseWriter, request *radius.Request)
	CheckAndLogTimingErrors(timestamp time.Time, acctSessionID, nas string, serviceID int, isService bool, statusType goradius.AcctStatusType, packetAttributes utils.PacketAttributes)
}

A Accounter is called when a subscriber's session needs to be handled

type Authenticater

type Authenticater interface {
	Plugin
	HandleAuthenticationPacket(responseWriter radius.ResponseWriter, request *radius.Request, timestamp time.Time)
}

A Authenticater is called when subscriber authentication needs to be handled

type ConfigReader

type ConfigReader interface {
	Values(sectionName string) map[string]string
	String(sectionName, key string) string
	Integer(sectionName, key string) int
	Duration(sectionName, key string) time.Duration
	Subsections(sectionName string, level int) []string
	SubsectionValues(sectionName, key string) []string

	GetServerAndRestAPIAddress(serverType utils.ServerType) (ipAddress, restAPIAddress string)
}

type Datastorer

type Datastorer interface {
	Plugin
	CheckConnectivity() bool
	Retrieve(collection string, key string) (map[string]interface{}, error)
	Store(collection string, key string, value interface{}) error
	Delete(collection string, key string) error
	RetrieveGroup(key string) (map[string]interface{}, error)
	StoreGroup(key string, value interface{}) error
	RetrieveUser(key string) (map[string]interface{}, error)
	StoreUser(key string, value interface{}) error
	RetrieveSession(key string) (map[string]interface{}, error)
	StoreSession(key string, value interface{}) error
	RetrieveService(key string) (map[string]interface{}, error)
	StoreService(key string, value interface{}) error
	RetrieveAuthARI(key string) (map[string]interface{}, error)
	StoreAuthARI(key string, value interface{}) error
	RetrieveAuthUser(key string) (map[string]interface{}, error)
	StoreAuthUser(key string, value interface{}) error
}

A Datastorer is called when data needs to be stored or retrieved

type Logger

type Logger interface {
	logrus.Ext1FieldLogger
}

type Plugin

type Plugin interface {
	GetPluginInfo() PluginInfo
	Init(Logger, ConfigReader) error
	InitWithPluginSystem(pluginSystem PluginSystem) error
	Start(conf utils.ServerFlagConfig) error
}

A Plugin is called by gorad when defined actions occur. The plugin knows about the business logic.

type PluginInfo

type PluginInfo struct {
	Name      string
	Buildvers buildvers.Buildvers
	Type      PluginType
}

PluginInfo holds all information about the plugin

type PluginSystem

type PluginSystem interface {
	LoadPlugins(pluginDir string) ([]Plugin, error)
	Select(pluginType PluginType, name string) error
	GetByName(name string) (Plugin, error)
	GetAllAuthenticater() (map[string]Authenticater, error)
	GetAllAccounter() (map[string]Accounter, error)
	GetAllDatastorer() (map[string]Datastorer, error)
	GetAllPoolContacter() (map[string]PoolContacter, error)
}

PluginSystem is the interface for plugins to call other plugins

type PluginType

type PluginType int

PluginType represents the type of plugin

const (
	// TypeRadiusHandler is a plugin which is responsible for handling the incoming radius packets
	TypeRadiusHandler PluginType = 1
	// TypeAuthenticater is a plugin which is responsible for authenticating a subscriber
	TypeAuthenticater PluginType = 2
	// TypeAccounter is a plugin which is responsible for accounting a subscriber's session
	TypeAccounter PluginType = 4
	// TypeDatastorer is a plugin which is responsible for storing and retrieving data
	TypeDatastorer PluginType = 8
	// TypePoolContacter is a plugin which is responsible for contacting the pool server
	TypePoolContacter PluginType = 16
)

func (PluginType) String

func (pluginType PluginType) String() string

type PoolContacter

type PoolContacter interface {
	Plugin
	SetIPPool(authenticationInformation utils.AuthenticationInformation, bngName, acctSessionID string, attributes map[string][]interface{}) bool
	ClearIPPool(device string)
	LockSessionIPAddresses(device, poolname, acctSessionID string)
	DeleteSessionIPAddresses(device, acctSessionID string)
}

A PoolContacter is called when a subscriber's session needs to be handled

type RadiusHandler

type RadiusHandler interface {
	Plugin
	GetRadiusHandler() func(radius.ResponseWriter, *radius.Request)
}

A RadiusHandler is called when an incoming radius packet needs to be handled

type RadiusPacketServer

type RadiusPacketServer interface {
	Serve(conn net.PacketConn) error
	ListenAndServe() error
	Shutdown(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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