-
Notifications
You must be signed in to change notification settings - Fork 0
/
module_options.go
45 lines (38 loc) · 1.04 KB
/
module_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
package ncrack
import "strings"
type ModuleOption func(*ModuleOptions)
type ModuleOptions struct {
Protocol arg
ServiceOptions arg
}
// Options in this mode apply to all hosts that are associated with the particular service/module
func WithModuleOption(opts ...ModuleOption) Option {
return func(c *Cracker) {
mo := ModuleOptions{}
for _, opt := range opts {
opt(&mo)
}
c.args = append(c.args, "-m")
c.args = append(c.args, mo.String())
}
}
// WithModuleServiceOptions provides ServiceModule to reffering module
// see service_options.go
func WithModuleServiceOptions(opts ...ServiceOption) ModuleOption {
return func(m *ModuleOptions) {
so := ServiceOptions{}
for _, opt := range opts {
opt(&so)
}
m.ServiceOptions.Val = so
}
}
// WithModuleOptionProtocol defines module type
func WithModuleOptionProtocol(p ...string) ModuleOption {
return func(m *ModuleOptions) {
m.Protocol.Val = strings.Join(p, ",")
}
}
func (m ModuleOptions) String() string {
return m.Protocol.WithColonAfter() + m.ServiceOptions.Arg()
}