Adding a module - mushorg/go-dpi GitHub Wiki
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:
Initializeperforms any needed operations for the initialization of the module.Destroyfrees any resources used by the module.ClassifyFlowattempts to classify a flow using the module. It returns atypes.ClassificationResultinstance, which contains the protocol that was guessed and the source of the classification.ClassifyFlowAllworks similarly, but it may return multipletypes.ClassificationResultinstances. 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.