Documentation
¶
Overview ¶
Package wrappers contains wrappers for external libraries such as nDPI in order to use them for flow classification.
Index ¶
- Constants
- type IncrementalFlow
- type IncrementalWorker
- type LPIWrapper
- func (wrapper *LPIWrapper) ClassifyFlow(flow *types.Flow) (*types.Classification, error)
- func (wrapper *LPIWrapper) DestroyWrapper() error
- func (wrapper *LPIWrapper) GetSupportedCategories() []types.Category
- func (wrapper *LPIWrapper) GetSupportedProtocols() []types.Protocol
- func (wrapper *LPIWrapper) GetWrapperName() types.ClassificationSource
- func (wrapper *LPIWrapper) InitializeWrapper() int
- type NDPIWrapper
- func (wrapper *NDPIWrapper) ClassifyFlow(flow *types.Flow) (class *types.Classification, err error)
- func (wrapper *NDPIWrapper) DestroyWrapper() error
- func (wrapper *NDPIWrapper) GetSupportedProtocols() []types.Protocol
- func (wrapper *NDPIWrapper) GetWrapperName() types.ClassificationSource
- func (wrapper *NDPIWrapper) InitializeWrapper() int
- type NDPIWrapperProvider
- type Wrapper
- type WrapperError
- type WrapperModule
- func (module *WrapperModule) ClassifyFlow(flow *types.Flow) (result types.ClassificationResult)
- func (module *WrapperModule) ClassifyFlowAll(flow *types.Flow) (results []types.ClassificationResult)
- func (module *WrapperModule) ConfigureModule(config WrapperModuleConfig)
- func (module *WrapperModule) Destroy() error
- func (module *WrapperModule) Initialize() error
- type WrapperModuleConfig
Constants ¶
const LPIWrapperName = "libprotoident"
LPIWrapperName is the identification of the libprotoident library.
const NDPIWrapperName = "nDPI"
NDPIWrapperName is the identification of the nDPI library.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IncrementalFlow ¶ added in v1.5.0
type IncrementalFlow struct {
Results [2]types.ClassificationResult
Count int
// contains filtered or unexported fields
}
IncrementalFlow never retains packet objects. Small unidentified first packets are kept as bytes until a second packet justifies retaining the much larger nDPI state.
type IncrementalWorker ¶ added in v1.5.0
type IncrementalWorker struct {
// contains filtered or unexported fields
}
IncrementalWorker owns a detection context. Calls and its flows must be serialized by its owner.
func NewIncrementalWorker ¶ added in v1.5.0
func NewIncrementalWorker(ndpi, lpi bool) (*IncrementalWorker, error)
NewIncrementalWorker creates private nDPI and libtrace contexts for the enabled engines.
func (*IncrementalWorker) Close ¶ added in v1.5.0
func (w *IncrementalWorker) Close()
Close releases the contexts after the owner has freed every outstanding flow.
func (*IncrementalWorker) Complete ¶ added in v1.5.0
func (w *IncrementalWorker) Complete(f *IncrementalFlow) bool
Complete reports whether all enabled engines have stopped inspecting the flow.
func (*IncrementalWorker) Free ¶ added in v1.5.0
func (w *IncrementalWorker) Free(f *IncrementalFlow)
Free releases inspection state, preserving results. Discard or zero the flow before reuse.
func (*IncrementalWorker) Process ¶ added in v1.5.0
func (w *IncrementalWorker) Process(f *IncrementalFlow, ip, ethernet []byte, millis uint64, direction int, final bool) error
Process advances each enabled engine. A compact first packet is replayed once on promotion. ip is the captured network-layer bytes; ethernet is optional for LPI.
type LPIWrapper ¶
type LPIWrapper struct {
// contains filtered or unexported fields
}
LPIWrapper is the wrapper for the LPI protocol identification library, providing the methods used to interface with it from go-dpi.
func (*LPIWrapper) ClassifyFlow ¶
func (wrapper *LPIWrapper) ClassifyFlow(flow *types.Flow) (*types.Classification, 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) GetSupportedCategories ¶ added in v1.2.4
func (wrapper *LPIWrapper) GetSupportedCategories() []types.Category
GetSupportedCategories returns all categories supported by libprotoident.
func (*LPIWrapper) GetSupportedProtocols ¶ added in v1.2.4
func (wrapper *LPIWrapper) GetSupportedProtocols() []types.Protocol
GetSupportedProtocols returns all protocols supported by libprotoident.
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) (class *types.Classification, err 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) GetSupportedProtocols ¶ added in v1.2.4
func (wrapper *NDPIWrapper) GetSupportedProtocols() []types.Protocol
GetSupportedProtocols returns all protocols supported by nDPI.
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.Classification, 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.
Wrappers are tried in priority order:
- LPI (libprotoident) - lightweight, fast payload inspection
- nDPI - comprehensive deep packet inspection
This order is maintained when ClassifyFlow is called, with the first successful classification being returned.
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.