-
Notifications
You must be signed in to change notification settings - Fork 54
/
options.go
53 lines (47 loc) · 1.19 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Package godpi provides the main API interface for utilizing the go-dpi library.
package godpi
import (
"github.com/mushorg/go-dpi/modules/classifiers"
"github.com/mushorg/go-dpi/modules/ml"
"github.com/mushorg/go-dpi/types"
)
// Options allow end users init module with custom options
// NOTE. it's necessary to check the module passed in Apply func
type Options interface {
Apply(types.Module)
}
// MLOption take ml module options to override default values
type MLOption struct {
TCPModelPath string
UDPModelPath string
Threshold float32
}
// Apply ml module option to LinearSVCModule
func (o MLOption) Apply(mod types.Module) {
// check module
lsm, ok := mod.(*ml.LinearSVCModule)
if !ok {
return
}
if o.TCPModelPath != "" {
lsm.TCPModelPath = o.TCPModelPath
}
if o.UDPModelPath != "" {
lsm.UDPModelPath = o.UDPModelPath
}
if o.Threshold > 0.0 {
lsm.Threshold = o.Threshold
}
}
// ClassifierOption take classifier options to override default values
// for now this option was added for test
type ClassifierOption struct {
// TODO
}
func (o ClassifierOption) Apply(mod types.Module) {
// check module
if _, ok := mod.(*classifiers.ClassifierModule); !ok {
return
}
// TODO
}