-
Notifications
You must be signed in to change notification settings - Fork 54
Adding a module
You may also choose to add a new module of your own. Each module's files live in its subdirectory in the modules
directory, and define their own package. A Module
is required to have the following methods:
Initialize() error
Destroy() error
ClassifyFlow(*types.Flow) types.ClassificationResult
ClassifyFlowAll(*types.Flow) []types.ClassificationResult
These have the following purposes:
Initialize
performs any needed operations for the initialization of the module.
Destroy
frees any resources used by the module.
ClassifyFlow
attempts to classify a flow using the module. It returns a types.ClassificationResult
instance, which contains the protocol that was guessed and the source of the classification.
ClassifyFlowAll
works similarly, but it may return multiple types.ClassificationResult
instances. If a module has other submodules that return different results, all of them should be returned here.
Besides these methods, a module can optionally have a configuration method (e.g. module.ConfigureModule
). In that case, the module should also provide, if necessary, a New
method which creates a new instance of the module with a default configuration.
If you wish for your module to be enabled by default, you should add a new instance of it to the moduleList
variable in godpi.go
. This way, when godpi.ClassifyFlow
or godpi.ClassifyFlowAll
is called, your module's appropriate method will be called, in the order that it was put in. Otherwise, you can also manually add your module to the list by calling godpi.SetModules
and providing an instance before calling godpi.InitializeModules
.