wrappers

package
v0.0.0-...-5185360 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package wrappers contains wrappers for external libraries such as nDPI in order to use them for flow classification.

Index

Constants

View Source
const LPIWrapperName = "libprotoident"

LPIWrapperName is the identification of the libprotoident library.

View Source
const NDPIWrapperName = "nDPI"

NDPIWrapperName is the identification of the nDPI library.

Variables

This section is empty.

Functions

This section is empty.

Types

type LPIWrapper

type LPIWrapper struct{}

LPIWrapper is the wrapper for the LPI protocol identification library, providing the methods used to interface with it from go-dpi.

func NewLPIWrapper

func NewLPIWrapper() *LPIWrapper

NewLPIWrapper constructs a new LPIWrapper.

func (*LPIWrapper) ClassifyFlow

func (wrapper *LPIWrapper) ClassifyFlow(flow *types.Flow) (types.Protocol, error)

ClassifyFlow classifies a flow using the libprotoident library. It returns the detected protocol and any error.

func (*LPIWrapper) DestroyWrapper

func (wrapper *LPIWrapper) DestroyWrapper() error

DestroyWrapper destroys the libprotoident wrapper.

func (*LPIWrapper) GetWrapperName

func (wrapper *LPIWrapper) GetWrapperName() types.ClassificationSource

GetWrapperName returns the name of the wrapper, in order to identify which wrapper provided a classification.

func (*LPIWrapper) InitializeWrapper

func (wrapper *LPIWrapper) InitializeWrapper() int

InitializeWrapper initializes the libprotoident wrapper.

type NDPIWrapper

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

NDPIWrapper is the wrapper for the nDPI deep inspection library, providing the methods used to interface with it from go-dpi.

func NewNDPIWrapper

func NewNDPIWrapper() *NDPIWrapper

NewNDPIWrapper constructs an NDPIWrapper with the default implementation for its methods.

func (*NDPIWrapper) ClassifyFlow

func (wrapper *NDPIWrapper) ClassifyFlow(flow *types.Flow) (types.Protocol, error)

ClassifyFlow classifies a flow using the nDPI library. It returns the detected protocol and any error.

func (*NDPIWrapper) DestroyWrapper

func (wrapper *NDPIWrapper) DestroyWrapper() error

DestroyWrapper destroys the nDPI wrapper.

func (*NDPIWrapper) GetWrapperName

func (wrapper *NDPIWrapper) GetWrapperName() types.ClassificationSource

GetWrapperName returns the name of the wrapper, in order to identify which wrapper provided a classification.

func (*NDPIWrapper) InitializeWrapper

func (wrapper *NDPIWrapper) InitializeWrapper() int

InitializeWrapper initializes the nDPI wrapper.

type NDPIWrapperProvider

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

NDPIWrapperProvider provides NDPIWrapper with the implementations of the methods to use.

type Wrapper

type Wrapper interface {
	InitializeWrapper() int
	DestroyWrapper() error
	ClassifyFlow(*types.Flow) (types.Protocol, error)
	GetWrapperName() types.ClassificationSource
}

Wrapper is implemented by every wrapper. It contains methods for initializing and destroying the wrapper, as well as for classifying a flow.

type WrapperError

type WrapperError struct {
	WrapperName types.ClassificationSource
	// contains filtered or unexported fields
}

WrapperError contains the error and the name of the wrapper for a wrapper that failed to initialize.

type WrapperModule

type WrapperModule struct {
	WrapperErrors []WrapperError
	// contains filtered or unexported fields
}

WrapperModule is the module that contains wrappers for other protocol identification libraries.

func NewWrapperModule

func NewWrapperModule() *WrapperModule

NewWrapperModule returns a new WrapperModule with the default configuration. By default, all wrappers will be enabled.

func (*WrapperModule) ClassifyFlow

func (module *WrapperModule) ClassifyFlow(flow *types.Flow) (result types.ClassificationResult)

ClassifyFlow applies all the wrappers to a flow and returns the protocol that is detected by a wrapper if there is one. Otherwise, it returns the Undefined protocol.

func (*WrapperModule) ClassifyFlowAll

func (module *WrapperModule) ClassifyFlowAll(flow *types.Flow) (results []types.ClassificationResult)

ClassifyFlowAll applies all the wrappers to a flow and returns the protocols that are detected by each one in an array.

func (*WrapperModule) ConfigureModule

func (module *WrapperModule) ConfigureModule(config WrapperModuleConfig)

ConfigureModule configures this module instance with the given configuration. This should called before the module instance is initialized, otherwise Destroy and Initialize should be called on the module manually.

func (*WrapperModule) Destroy

func (module *WrapperModule) Destroy() error

Destroy destroys all active wrappers.

func (*WrapperModule) Initialize

func (module *WrapperModule) Initialize() error

Initialize initializes all wrappers and filters out the ones that don't get initialized correctly. It returns the errors thrown during the initialization of the wrappers and the names of the wrappers that errored.

type WrapperModuleConfig

type WrapperModuleConfig struct {
	Wrappers []Wrapper
}

WrapperModuleConfig is given to the module's ConfigureModule method, in order to set which wrappers are active and their order.

Jump to

Keyboard shortcuts

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