plugin

package
Version: v0.0.0-...-986d81d Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package plugin contains the structs and logic to handle arbitrary transforms or management of incoming/outgoing packets.

Currently supported plugin types:

- Compression
- Encryption

Index

Constants

View Source
const (
	// CompressionPlugin configures and injects a compression based plugin.
	CompressionPlugin = "compression"

	// EncryptionPlugin configures and injects an encryption based plugin.
	EncryptionPlugin = "encryption"

	// MockPlugin configures and injects a mock plugin for testing.
	MockPlugin = "mock"
)
View Source
const (
	// CompressionPluginOrder is the location of the compression plugin in the overall plugins enabled within quantum.
	CompressionPluginOrder = iota

	// EncryptionPluginOrder is the location of the encryption plugin in the overall plugins enabled within quantum.
	EncryptionPluginOrder

	// MockPluginOrder is the location of the mock plugin in the overall plugins enabled within quantum.
	MockPluginOrder
)
View Source
const (
	// Incoming a packet is coming from a remote node destined for the local node.
	Incoming = iota

	// Outgoing a packet is coming from the local node destined for a remote node.
	Outgoing
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Compression

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

Compression plugin struct to use for compressing outgoing packets or decompressing incoming packets.

func (*Compression) Apply

func (comp *Compression) Apply(direction Direction, payload *common.Payload, mapping *common.Mapping) (*common.Payload, *common.Mapping, bool)

Apply returns the payload/mapping compressed if the direction is Outgoing and decompressed if the direction is Incoming.

func (*Compression) Close

func (comp *Compression) Close() error

Close which is a noop.

func (*Compression) Name

func (comp *Compression) Name() string

Name returns 'compression'.

func (*Compression) Order

func (comp *Compression) Order() int

Order returns the CompressionPluginOrder value.

type Direction

type Direction int

Direction of the packet when supplied to the plugin in question.

type Encryption

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

Encryption plugin struct to use for encrypting outgoing packets or decrypting incoming packets.

func (*Encryption) Apply

func (enc *Encryption) Apply(direction Direction, payload *common.Payload, mapping *common.Mapping) (*common.Payload, *common.Mapping, bool)

Apply returns the payload/mapping encrypted if the direction is Outgoing and decrypted if the direction is Incoming.

func (*Encryption) Close

func (enc *Encryption) Close() error

Close which is a noop.

func (*Encryption) Name

func (enc *Encryption) Name() string

Name returns 'encryption'.

func (*Encryption) Order

func (enc *Encryption) Order() int

Order returns the EncryptionPluginOrder value.

type Mock

type Mock struct {
}

Mock plugin struct to use for testing.

func (*Mock) Apply

func (mock *Mock) Apply(direction Direction, payload *common.Payload, mapping *common.Mapping) (*common.Payload, *common.Mapping, bool)

Apply returns the payload/mapping unchanged and always true.

func (*Mock) Close

func (mock *Mock) Close() error

Close which is a noop.

func (*Mock) Name

func (mock *Mock) Name() string

Name returns 'mock'.

func (*Mock) Order

func (mock *Mock) Order() int

Order returns the MockPluginOrder value.

type Plugin

type Plugin interface {
	// Apply should apply the plugin to the specified payload and mapping.
	Apply(direction Direction, payload *common.Payload, mapping *common.Mapping) (*common.Payload, *common.Mapping, bool)

	// Close should gracefully destroy the plugin.
	Close() error

	// Name should return the name of the plugin.
	Name() string

	// Order returns the location of the specified plugin in the overall plugins enabled within quantum.
	Order() int
}

Plugin interface for a generic multi-queue network device.

func New

func New(pluginType string, cfg *common.Config) (Plugin, error)

New will generate a new Plugin struct based on the supplied device pluginType and user configuration.

type Plugins

type Plugins []Plugin

Plugins is a collection of plugin structs for quantum to use.

func (Plugins) Len

func (plugins Plugins) Len() int

Len returns the number of plugins.

func (Plugins) Swap

func (plugins Plugins) Swap(i, j int)

Swap will swap the specified plugins in place.

type Sorter

type Sorter struct {
	Plugins
}

Sorter is used to sort the various enabled plugins within quantum.

func (Sorter) Less

func (sorter Sorter) Less(i, j int) bool

Less returns whether or not the plugin at index 'i' is less than the that of the plugin at index 'j'.

Jump to

Keyboard shortcuts

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